// ============
// DICTIONNAIRE
// ============
$t["a"] = array("","ā","á","ǎ","à","a");
$t["e"] = array("","ē","é","ě","è","e");
$t["i"] = array("","ī","í","ǐ","ì","i");
$t["o"] = array("","ō","ó","ǒ","ò","o");
$t["u"] = array("","ū","ú","ǔ","ù","u");
$t["v"] = array("","ǖ","ǘ","ǚ","ǜ","v");
function pinyin_accentue($py)
{
global $t;
$py = trim($py);
$py = str_replace ("u:","v",$py);
ereg ("^([bcdfghjklmnpqrstwxyz]*h?)([aeiouv]+)([ngr]*)([12345]?)$",$py,$reg);
list(,$cons,$voy,$fin,$ton) = $reg;
ereg ("^([aeiouv])([aeiouv]?)([aeoiuv]?)$",$voy,$reg);
list(,$v1,$v2,$v3) = $reg;
if ($v2 != "" and ($v1 == "i" or $v1 == "u")) $voy = $v1.$t[$v2][$ton].$v3;
else $voy = $t[$v1][$ton].$v2.$v3;
$voy = str_replace("v","ü",$voy);
$pyt = "$cons$voy$fin";
return "$pyt";
}
function pinyin_numero($py) // MARCHE PAS
{
global $t;
$py = trim($py);
if (!ereg ("([[:alpha:]];)",$py,$reg)) return $py;
$accent = $reg[1];
$voy = array_search($accent,$t);
//echo $voy;
// remplace aussi "ü" et "v" par "u:"
$py = str_replace ("ü","u:",$py);
$py = str_replace ("v","u:",$py);
return "$py";
}
function lien_dico($texte)
{
if ($GLOBALS['m']==NOzh) return "";
$texte=trim($texte);
$res = lien_dico_b5($texte);
$res = lien_dico_ent($res);
return $res;
// return str_replace("§§ET§§","&",$res); // bidouille pour eviter de recode deux fois les var simplifiées
}
function lien_dico_ent($texte,$file_name="")
{
$tab = explode("&",$texte);
$res = "";
foreach ($tab as $car)
{
if (ereg("^#[0-9]{3,6};",$car))
{
list($le_car,$le_reste) = explode(";",$car,2);
$res.= lien_dico_traduction("&$le_car;",$file_name);
$res.="\n"; // met des espaces entre les carchis
$res.= $le_reste;
}
else $res.= $car;
}
return $res;
}
function lien_dico_b5($texte)
{
$res = "";
//$texte=str_replace("¡C","",$texte); // ôte les points ### PAS BON
//$texte=str_replace("¡B","",$texte); // ôte les virgules ### PAS BON
$i=0;
while ($i $texte
else $res.= " $trad $nom_traducteur $ref \n $titre 原文 $no \n\n $texte_chinois \n\n \n\n $texte_chinois \n\n \n";
$legende.= " ".L_courant." \n";
$legende.= " ".L_binome." \n";
$legende.= " ".L_echange_trig." \n";
$legende.= " ".L_oppose." \n";
$legende.= " ".L_tetenbas." \n";
$legende.= "X ".L_maitre_gouvernant." \n";
$legende.= "X ".L_maitre_constituant;
$legende.= " ".lien_dico($zh2)." ', "
",$texte);
$texte = convertir_entites($texte);
foreach (explode(",",$ref) as $une_ref)
if (trim($une_ref)!="")
$ref_lien.= " – $une_ref";
if ($lang == "fr") $format_date = "d/m/Y";
else $format_date = "Y/m/d";
$infos = "
";
return $res;
}
// NETTOYE HTML (tout sauf )
function safeHTML($text) {
$text = stripslashes($text);
$text = str_replace("
","
",$text);
return $text;
}
function u_notes_Xref($livre,$no) // LES REFERENCES CROISéES DANS LE CORPS DES TEXTES
{
if ($_GET["debug"] != "ok") return ""; // DESACTIVé
if ($livre = "") return "";
$res = "";
$where = " WHERE cacher NOT LIKE 'ok' "; //ne pas afficher les notes cachées
$where .= "AND type LIKE '%Xref%' ";
$where .= "AND ref LIKE '%$livre $no%' ";
$req = "SELECT ref,texte FROM _notes_utilisateurs $where $order";
$reqres = requete($req);
while (list($ref,$texte) = mysql_fetch_array($reqres))
{
$res.= "
)*","",$trad)."
";
// $ref.= "
";
if ($_GET["debug"] == "ok")
{ $debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=".$l."_tr&sql_col=texte&sql_where=id%3D$id";
$ref.= " debug"; }
if ($nom_traducteur) $nom_traducteur = convertir_entites($nom_traducteur);
else $nom_traducteur = $traducteur;
$res.= "\n\n
$texte_chinois_brut \n\n
",$texte_chinois_brut);
if (ereg("coupe_ponctuation",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$coupe_ponctuation_trans);
if (ereg("coupe_virgule",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$coupe_virgule_trans);
if (ereg("vire_ponctuation",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$vire_ponctuation_trans);
if (ereg("mod_ponctuation",$type))
{
$texte_chinois_brut = str_replace("
","",$texte_chinois_brut); // PAS SUR QUE CE SOIT BIEN
$texte_chinois_brut = strtr($texte_chinois_brut,$mod_ponctuation_trans);
$texte_chinois_brut = ereg_replace("^[,.]+","",$texte_chinois_brut); // vire ., au debut
$texte_chinois_brut = ereg_replace(", *,*",",",$texte_chinois_brut); // ,,, => ,
$texte_chinois_brut = ereg_replace("[,.]+\.",".",$texte_chinois_brut); // ,.. => .
$texte_chinois_brut = ereg_replace("\.[,.]+",".",$texte_chinois_brut); // ., => .
$texte_chinois_brut = str_replace(",",",
",$texte_chinois_brut);
$texte_chinois_brut = str_replace(".",".
",$texte_chinois_brut);
$mode_affichage = "avec_ponctuation";
}
$texte_chinois_brut = ereg_replace("
\n*$","",$texte_chinois_brut);// vire fin
if (ereg("(auto_angle[_.,/0-9]*)",$type,$parse))
$taille.= " ".$parse[1]; // propage
if (ereg("auto_taille",$type))
$texte_chinois_brut = auto_taille_chinois($texte_chinois_brut,$taille);
if (!ereg("pas_de_taille",$type))
$texte_chinois_brut = taille_chinois($texte_chinois_brut,$taille);
if (ereg("centre",$taille) and !ereg("force_droite",$taille))
$type = str_replace("vert_droite","vertical",$type); // centrage
if (ereg("vertical",$type))
$res = "
",$texte_chinois_brut);
$texte_chinois = "";
foreach ($tab_texte_chinois as $ligne)
{
$texte_chinois.=lien_dico(trim($ligne))."\n
\n";
}
$texte_chinois = nettoye_fin($texte_chinois);
$res = "
", // pour virgule
"¡B" => "
",
"¡C" => "
",
"¡D" => "
",
"¡E" => "
",
"¡F" => "
",
"¡G" => "
",
"¡H" => "
",
"¡I" => "
",
"¡u" => "
", // crochet simple gauche
"¡v" => "
", // crochet simple droit
"¡y" => "
", // crochet double gauche
"¡z" => "
", // crochet double droit
"," => "
", // pour virgule 1
"、" => "
", // pour virgule 2
"﹐" => "
", // pour virgule 3
";" => "
", // pour ;
"。" => "
", // pour o
"!" => "
", // pour !
"「" => "
", // pour crochet 1
"」" => "
", // pour crochet 2
"『" => "
", // pour crochet double gauche
"』" => "
", // pour crochet double droit
"?" => "
", // pour ?
":" => "
"); // pour :
$coupe_virgule_trans = array(
"¡A" => "¡A
", // pour virgule
"¡B" => "¡B
", // pour virgule
"," => ",
", // pour virgule 1
"、" => "、
", // pour virgule 2
"﹐" => "﹐
", // pour virgule 3
";" => ";
", // pour ;
":" => ":
"); // pour :
$vire_ponctuation_trans = array(
"¡A" => "", // pour virgule
"¡B" => "",
"¡C" => "",
"¡D" => "",
"¡E" => "",
"¡F" => "",
"¡G" => "",
"¡H" => "",
"¡Q" => "", // ;
"¡J" => "", // :
"﹖" => "", // pour ?
"," => "", // pour virgule 1
"、" => "", // pour virgule 2
"﹐" => "", // pour virgule 3
";" => "", // pour ;
"。" => "", // pour o
"!" => "", // pour !
"《" => "", // crochet double gauche
"》" => "", // crochet double gauche
"「" => "", // pour crochet 1
"」" => "", // pour crochet 2
":" => ""); // pour :
$mod_ponctuation_trans = array(
"﹖" => ".", // pour ?
"?" => ".", // pour ?
"‘" => ",", "’" => ".", // pour single quotes
"“" => ",", "”" => ".", // pour double quotes
"(" => "", ")" => "", // pour ( )
"─" => ".", // pour barre horizontale
"," => ",", // pour virgule 1
"、" => ",", // pour virgule 2
"﹐" => ",", // pour virgule 3
";" => ",", // pour ;
"。" => ".", // pour o
"!" => ".", // pour !
"《" => "", // crochet double gauche
"》" => "", // crochet double gauche
"「" => "", "」" => "", // pour crochets simples
"『" => "", "』" => "", // pour crochets doubles
":" => "," // pour :
);
$requete = "SELECT * FROM $l WHERE numero = $no ";
$resu = mysql_fetch_array( requete( $requete ));
$numero = $resu['numero'];
$titre = $resu['titre'];
$texte_zh = $resu['texte_zh'];
$taille = $resu['taille'];
if ($_GET["debug"] == "ok")
{$debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=$l&sql_col=texte_zh&sql_where=numero%3D$no";
$liens_debug = "$no Deb - ";
$debug_href = "files/Travail.php?action=edite&submit=voir&sql_table=$l&sql_col=taille&sql_where=numero%3D$no";
$liens_debug.= " T:$taille"; }
if (($_GET["debug"] == "ok") and !ereg("auto_taille",$type) and ($l=="Lunyu"))
$type="vert_droite mod_ponctuation auto_taille"; //TESTER AUTO TAILLE seulement pour lunyu
// VARIANTES
if (ereg("comment",$taille)) $type = ""; // si commentaire, aff horizontal + ponctuation
$texte_chinois_brut = trim($texte_zh);
$titre = trim($titre);
// if ($titre=="") $titre=" "; //espace ideographique
if (ereg("preformatted",$type))
$texte_chinois_brut = str_replace("\r\n","
",$texte_chinois_brut);
if (ereg("coupe_ponctuation",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$coupe_ponctuation_trans);
if (ereg("coupe_virgule",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$coupe_virgule_trans);
if (ereg("vire_ponctuation",$type))
$texte_chinois_brut = strtr($texte_chinois_brut,$vire_ponctuation_trans);
if (ereg("mod_ponctuation",$type))
{
$texte_chinois_brut = str_replace("
","",$texte_chinois_brut); // PAS SUR QUE CE SOIT BIEN
$texte_chinois_brut = strtr($texte_chinois_brut,$mod_ponctuation_trans);
$texte_chinois_brut = ereg_replace("^[,.]+","",$texte_chinois_brut); // vire ., au debut
$texte_chinois_brut = ereg_replace(", *,*",",",$texte_chinois_brut); // ,,, => ,
$texte_chinois_brut = ereg_replace("[,.]+\.",".",$texte_chinois_brut); // ,.. => .
$texte_chinois_brut = ereg_replace("\.[,.]+",".",$texte_chinois_brut); // ., => .
$texte_chinois_brut = str_replace(",",",
",$texte_chinois_brut);
$texte_chinois_brut = str_replace(".",".
",$texte_chinois_brut);
$mode_affichage = "avec_ponctuation";
}
$texte_chinois_brut = ereg_replace("
\n*$","",$texte_chinois_brut);// vire fin
if (ereg("(auto_angle[_.,/0-9]*)",$type,$parse))
$taille.= " ".$parse[1]; // propage
if (ereg("auto_taille",$type))
$texte_chinois_brut = auto_taille_chinois($texte_chinois_brut,$taille);
if (!ereg("pas_de_taille",$type))
$texte_chinois_brut = taille_chinois($texte_chinois_brut,$taille);
if (ereg("centre",$taille) and !ereg("force_droite",$taille))
$type = str_replace("vert_droite","vertical",$type); // centrage
if (ereg("vertical",$type))
$res = "
",$texte_chinois_brut);
$texte_chinois = "";
foreach ($tab_texte_chinois as $ligne)
{
$texte_chinois.=lien_dico(trim($ligne))."\n
\n";
}
$texte_chinois = nettoye_fin($texte_chinois);
$res = "
","",$tx);
$t = explode("&",$tx); $tc = count($t); $coupe_v = 0;
if (ereg(" v<=([0-9]{1,2}) ",$c,$r1)) $coupe_v = $r1[1];
if (ereg(" h=([0-9]{1,2}) ",$c,$r2))
if ($r2[1]>0) $coupe_v = ceil($tc / $r2[1]);
if (ereg(" v=([0-9_]+) ",$c,$r3)) $t_coupe = explode("_",$r3[1]);
$reste = 0;
if ($t_coupe)
foreach ($t_coupe as $point_coupe)
$t[$reste+=$point_coupe].= "
";
if ($coupe_v)
for ($i=1;$i<=$tc;$i++)
if ($i % $coupe_v == 0) $t[$i].="
";
return implode("&",$t);
}
// ne marche que pour les tx encodés avec &xxxx;
function auto_taille_chinois($tx,& $taille)
{
$max_hauteur_max = 18;
$hauteur_min = 2;
$seuil_pour_centrage = 70;
$seuil_pour_interdiction_hauteur_trop_courte = 10;
$tx = str_replace("
","",$tx); // reset
// if ($_GET["debug"] == "ok") echo "$tx
";
$t = explode("&",$tx); $tc = count($t);
$hauteur_max = round($tc/2) + 2;
if ($tc <= $seuil_pour_interdiction_hauteur_trop_courte) $hauteur_max = $tc;
if ($hauteur_max > $max_hauteur_max) $hauteur_max = $max_hauteur_max; //limite hauteur col
if ($tc > $seuil_pour_centrage) $taille .= " centre";
if ($tc >= $seuil_pour_interdiction_hauteur_trop_courte) $hauteur_min = 4;
// PARSE LA CHAINE $taille pour instructions
if (ereg(" auto_v<=([0-9]{1,2}) "," $taille ",$parse)) $hauteur_max = $parse[1];
if (ereg(" auto_v>=([0-9]{1,2}) "," $taille ",$parse)) $hauteur_min = $parse[1];
if (ereg(" auto_v=([0-9]{1,2}) "," $taille ",$parse))
{ $hauteur_min = $parse[1]; $hauteur_max = $parse[1]; }
$meilleure_note = -100000;
$meilleur_res = $tx;
for ($hauteur = $hauteur_min; $hauteur <= $hauteur_max; $hauteur++)
{
if (ereg("coupe_brute",$taille)) $res_t = coupe_rigide($t,$hauteur);
else $res_t = coupe_souple($t,$hauteur);
$res = implode("&",$res_t);
$res = ereg_replace("
\n*$","",$res);// vire fin
$note = calcule_note($res,$hauteur,$taille);
if ($note>$meilleure_note)
{
$meilleure_note = $note;
$meilleur_res = $res;
}
}
return $meilleur_res;
}
function coupe_souple($t,$hauteur)
{
if (count($t)<=$hauteur) return $t; //break recursion
$coupe = 1;
for ($i=$coupe;$i <= $hauteur; $i++)
if (strpos($t[$i],".")) $coupe = $i;
for ($i=$coupe;$i <= $hauteur; $i++)
if (strpos($t[$i],",")) $coupe = $i;
// if (($hauteur>7) and ($coupe_virgule-$coupe <= 3) and ($coupe_virgule>$hauteur/2))
// $coupe_virgule = $coupe; // tente d'eviter les "le maitre a dit" orphelins
// $coupe = $coupe_virgule;
if ($coupe < 2) $coupe = $hauteur;
$t[$coupe].= "
";
$premiere_col = array_splice($t,0,$coupe);
$suite = coupe_souple($t,$hauteur);
return array_merge($premiere_col,$suite);
}
function coupe_rigide($t,$hauteur)
{
if ($hauteur == 0) return $t;
$tc = count($t);
for ($i=1;$i<=$tc;$i++)
if ($i % $hauteur == 0) $t[$i].="
";
return $t;
}
function calcule_note ($tx,$hauteur,$taille)
{
$rectangularite_ideale = 7/2;
$nb_ideal_colonnes = 2;
$poids_pour_ideal_colonnes = 4;
$poids_pour_rectangularite = 1;
$poids_cases_vides = 3;
$poids_coupe_point = 13;
$poids_coupe_virgule = 8;
$poids_mauvaise_coupe = 15;
$penalite_depassement_largeur_14 = 100;
if (ereg("centre",$taille))
{
$rectangularite_ideale = 4/8;
$nb_ideal_colonnes = 10;
$poids_mauvaise_coupe = 7;
$poids_cases_vides = 2;
}
if (ereg(" auto_angle_?([.,/0-9]+) "," $taille ",$parse)) $angle_voulu = $parse[1];
if (ereg(" angle_?([.,/0-9]+) "," $taille ",$parse)) $angle_voulu = $parse[1];
$angle_voulu = (float) $angle_voulu;
if ($angle_voulu) $rectangularite_ideale = $angle_voulu;
$note = 0;
$nb_col = substr_count($tx,"
") + 1;
$nb_car = substr_count($tx,"&");
if ($nb_car < 10) $nb_ideal_colonnes = 1;
if ($nb_col > 14) $note -= $penalite_depassement_largeur_14;
if ($nb_col > 14*2) $note -= $penalite_depassement_largeur_14;
if ($nb_col > 14*3) $note -= $penalite_depassement_largeur_14;
// rectangularité
$angle_reel = rad2deg(atan($hauteur / $nb_col));
$angle_ideal = rad2deg(atan($rectangularite_ideale));
$dist = abs($angle_ideal - $angle_reel);
$note_rect = - round($poids_pour_rectangularite*$dist,2) ;
// nb ideal colonnes
$dist = abs($nb_col - $nb_ideal_colonnes);
$note_nb_col = - $poids_pour_ideal_colonnes * $dist ;
//compte les vides
$nb_vides = 0;
$t = explode("
",$tx); $tc = count($t);
foreach ($t as $i => $col)
{
if ($i<$tc) $nb_vides += $hauteur - substr_count($col,"&");
else $nb_vides += ($hauteur - substr_count($col,"&"))/2;
$debug_cols .= substr_count($col,"&").".";
}
$note_vides = $poids_cases_vides * $nb_vides;
//compte les bonnes coupures
$nb_total_coupes = substr_count($tx,"
"); if ($nb_total_coupes==0) $nb_total_coupes = 1;
$tx_coupes_point = substr_count($tx,".
")/$nb_total_coupes;
$tx_coupes_virgule = substr_count($tx,",
")/$nb_total_coupes;
$tx_mauvaises_coupes = 1 - $tx_coupes_point - $tx_coupes_virgule;
$note_coupes = $poids_coupe_point*$tx_coupes_point + $poids_coupe_virgule*$tx_coupes_virgule - $poids_mauvaise_coupe*$tx_mauvaises_coupes;
$note_coupes = round($note_coupes,2);
if (substr_count($tx,"
")==0) $note_coupes = $poids_coupe_point; // si pas de coupes
$note+= $note_rect + $note_coupes - $note_vides;
if ($_GET["debug"] == "ok")
{
echo "";
echo "h$hauteur : (".round($note,2).") ";
echo "vides = $poids_cases_vides*$nb_vides ; ";
echo "coupes = $note_coupes ($poids_coupe_point*".round($tx_coupes_point,2)." + $poids_coupe_virgule*".round($tx_coupes_virgule,2)." - $poids_mauvaise_coupe*".round($tx_mauvaises_coupes,2)."); ";
echo "rect = $note_rect ; ";
echo "cols $debug_cols";
echo "
";
}
return $note;
}
function affiche_poeme_vertical($titre,$tx,$mode = "normal")
{
$tx = ereg_replace("
[ \r\n]*
","
",$tx); // dédoublonne
$tx = ereg_replace("
[ \r\n]*$","",$tx); // vire fin
if ($tx == "") $tx = "¡@"; // ajoute blanc big5 si vide
$lignes_alendroit = explode("
",trim($tx));
$nb_col = count($lignes_alendroit);
//echo "XXX $nb_col XXX";
if ($nb_col>14)
{
$res = affiche_poeme_vertical($titre,implode("
",array_splice($lignes_alendroit,0,$nb_col/2)),$mode);
$res.= affiche_poeme_vertical($titre,implode("
",$lignes_alendroit),$mode);
return $res;
}
$lignes = inverse_tableau($lignes_alendroit);
$nb_col = count($lignes);
if (!$titre) $mod_pas_de_titre = "style='background-color:white'";
$res ="\n";
// PREMIERE LIGNE (decorative)
$res.="
\n\n";
$point = "";
$virgule = "";
$res = str_replace("\n";
$res.=" ";
// DEUXIEME LIGNE (le texte)
$res.="\n";
$res.=" \n";
for ($i=2;$i<=$nb_col;$i++)
$res.=" \n";
if ($titre) $res.=" ";
$res.=" ";
$res.=" \n";
$res.=" ";
//TROISIEME LIGNE (decorative)
$res.="\n";
while(list($clef,$ligne) = each($lignes))
$res.=" ".lien_dico($ligne)." \n";
if (ereg("
",$titre)) // pour aller avec titres du Tangshi mais à modifier (ne prend que le debut
{
$split_titre = split("
",$titre);
$res.= "".lien_dico($split_titre[2])." \n";
}
elseif ($titre)
$res.= "".lien_dico($titre)." \n";
$res.= "\n";
$res.= " \n";
$res.=" \n";
// FIN TABLEAU
$res.= "\n";
$res.=" \n";
for ($i=2;$i<=$nb_col;$i++)
$res.=" \n";
if ($titre) $res.=" \n";
$res.=" \n";
$res.="
",$res);
$res = ereg_replace("
[ \n\r\p]*,","$virgule
\n",$res);
$res = ereg_replace("
[ \n\r\p]*\.","$point
\n",$res);
return $res;
}
function affiche_poeme___EX___()
{
//if ($mode != "avec_ponctuationXXXXX")
//if ($mode == "avec_ponctuationXXXXX")
// {
// modifie taille des carchis selon le nombre de colonnes
if ( $nb_col<10) $taille = 3;
elseif ( $nb_col<17) $taille = 2;
elseif ( $nb_col<25) $taille = 1;
elseif ( $nb_col>24) $taille = 0;
$taille_carchis = 14 + 4*$taille;
$taille_colchi = 16 + 6*$taille;
$style_taille = "font-size:$taille_carchis px; width:$taille_colchi px; ";
if ($mode == "avec_ponctuation") $style_taille = "width:1.1em; nowrap;";
$res ="
\n\n";
}
?>
// =====================
// POUR TOUTES LES PAGES
// =====================
function pied_navigation($l,$titre_py,$s,$c,$no,$param_inf,$param_sup)
{
if (!$GLOBALS["est_livre"]) return ""; // escape si pas livre
$url_intro = autoURL("s=&c=&no=0");
$url_toc = autoURL("s=&c=&no=-1");
$intro.= "
";
for ($i=2;$i<=$nb_col;$i++)
$res.="

\n";
$res.="

";
$res.="
";
$res.="
";
$res.="
";
while(list($clef,$ligne) = each($lignes))
{
$res.=" ";
// $res.= lien_dico($ligne);
$res.= str_replace(""," ";
}
if (ereg("
",lien_dico($ligne));
$res.= "
",$titre)) // pour aller avec titres du Tangshi mais à modifier
{
$split_titre = split("
",$titre);
$res.= "";
// $res.= lien_dico($split_titre[2]);
$res.= str_replace(""," ";
}
else
{
$res.= "
",lien_dico($split_titre[2]));
$res.= "";
// $res.= lien_dico($titre);
if ($titre) $titre_lie = lien_dico($titre);
else $titre_lie = " ";
$res.= str_replace(""," ";
}
$res.= "
",$titre_lie);
$res.= "

";
for ($i=2;$i<=$nb_col;$i++)
$res.= "

\n";
$res.= "

\n";
$res.= "


";
$table.= "
";
$precedent = "".L_Page_precedente."";
$suivant = "".L_Page_suivante."";
// efface les liens redondants
// if (ereg("no=0",$param_inf)) $precedent =""; // cas où on est en no=1 (ou s=1 et c=1)
// if (ereg("no=-1",$param_inf)) $precedent =""; // cas où on est en no=0
// if (ereg("no=0",$param_sup)) $suivant =""; // cas où on est en no=-1
// if (ereg("no=-1",$param_sup)) $suivant =""; // cas où on est en no=MAX
if ($s>0) $scn.= arabe_vers_romain($s).". ";
if ($c>0) $scn.= "$c. ";
if ($no>0) $scn.= "($no)";
if ($no == 0) $intro= "";
if ($no == -1) $table= "";
// $res = "$intro – $precedent $titre_py $scn $suivant – $table";
$res = "$titre_py $scn $intro$table
$precedent
$suivant";
return $res;
}
function titre_separateur($l,$s,$c,$no)
{
if ($s>0) $tx.= arabe_vers_romain($s).". ";
if ($c>0) $tx.= "$c. ";
if ($no>0 and $c <> $no) $affno = "($no)";
if (!$_GET["no"]) $affno = "$affno";
if (ereg("par_chapitre|par_section",TYPE_AFFICHAGE)) $affno = "";
$res = "$l $tx $affno";
return $res;
}
function TOC($l,$s,$c,$no,$lang,$param_inf,$param_sup)
{
// if ($no===0) { $s = 0; $c = 0; }
if ($l == "Yijing") return TOC_Yijing($no,$lang);
$sql = "SELECT code FROM _code_php WHERE type ='TOC' AND livre = '$l'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
else
{
$sql = "SELECT code FROM _code_php WHERE type ='TOC' AND livre = 'defaut'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
}
return $res;
}
function sous_titre($l,$s,$c,$no,$lang)
{
if ($no===0) return L_Introduction;
$sql = "SELECT code FROM _code_php WHERE type ='sous-titre' AND livre = '$l'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
else
{
$sql = "SELECT code FROM _code_php WHERE type ='sous-titre' AND livre = 'defaut'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
}
return $res;
}
function sous_TOC($l,$titre_py,$s,$c,$no,$param_inf,$param_sup)
{
$sql = "SELECT code FROM _code_php WHERE type ='sous-TOC' AND livre = '$l'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
else
{
$sql = "SELECT code FROM _code_php WHERE type ='sous-TOC' AND livre = 'defaut'";
$temp = mysql_fetch_array(requete($sql));
if ($temp[0]) eval ($temp[0]);
}
return $res;
}
function determine_param_inf_et_param_sup ($l,$s,$c,$no,&$param_inf,&$param_sup)
{
if ($GLOBALS["est_livre"])
{
$li = $l; $ls = $l;
if (!empty($no) or $GLOBALS["aff_intro_livre"]) // PAGE INTRO ou NO defini
{
list($no_max) = mysql_fetch_array(requete("SELECT max(numero) FROM $l"));
$noi = interieur_segment($no-1,-1,$no_max);
$nos = interieur_segment($no+1,-1,$no_max);
}
elseif (!empty($s) and empty($c)) // seul section est defini
{
list($s_max) = mysql_fetch_array(requete("SELECT max(section) FROM $l"));
$si = $s-1;
$ss = $s+1;
if ($ss>$s_max) { $ss = ""; $no = 0; }
if ($si<1) { $si = ""; $no = 0;}
}
elseif (!empty($s) and !empty($c)) // section et chapitre definis
{
list($s_max) = mysql_fetch_array(requete("SELECT max(section) FROM $l"));
list($c_max) = mysql_fetch_array(requete("SELECT max(chapitre) FROM $l WHERE section = $s"));
$si = $s; $ss = $s; $ci = $c-1; $cs = $c+1;
if ($cs>$c_max)
{ $ss = interieur_segment($ss + 1,1,$s_max); $cs = 1; }
if ($ci<1)
{ $si = interieur_segment($si - 1,1,$s_max); list($ci) = mysql_fetch_array(requete("SELECT max(chapitre) FROM $l WHERE section = $si")); }
}
}
else // cas des pages
{
$tab_pages = split(",",LISTE_LIENS);
$li = $tab_pages[array_search($l,$tab_pages)-1];
$ls = $tab_pages[array_search($l,$tab_pages)+1];
}
// EXCEPTIONS
if (ereg("par_section",TYPE_AFFICHAGE))
{ if ($nos==1) {$nos=""; $ss=1; }
if ($noi>1 and $noi==$no_max) {$noi=0;}
}
if (ereg("par_chapitre",TYPE_AFFICHAGE))
{
if ($nos==1) {$nos=""; $ss=1; $cs=1;}
if ($noi>1 and $noi==$no_max) {$noi=0;}
}
$param_inf = "l=$li&s=$si&c=$ci&no=$noi";
$param_sup = "l=$ls&s=$ss&c=$cs&no=$nos";
}
function autoURL($param) // génère l'URL en ôtant les var. superflues
{
if ($param{0} == "#") return ereg_replace("#.*$","",$PHP_SELF).$param;
$param = str_replace("&","&",$param);
$tab = $_GET;
// vire les param non voulus
foreach(split(",","x,y,i,force_lang,pub,ch,chmax,tire,u_ref,u_ajout,auteur") as $temp) $tab[$temp] = "";
// efface s et c si no existe
if ($tab["no"] != "") { $tab["c"] = ""; $tab["s"] = ""; }
// efface les var superflues
if ($tab["debug"] != "ok") $tab["debug"] = "";
if ($tab["a"] == "tous") $tab["a"] = "";
$in_tab = explode("#",$param);
$param = $in_tab[0];
$ancre = $in_tab[1];
$in_tab = explode("&",$param);
foreach ($in_tab as $in_val)
{
$in_egalite = explode("=",$in_val);
$tab[$in_egalite[0]] = $in_egalite[1];
}
$param = "";
foreach ($tab as $cle => $val)
{
if ($val != "") $param .= "&$cle=$val";
}
if ($param) $param = "?$param";
if ($ancre) $param .= "#$ancre";
$param = str_replace("?&","?",$param);
$param = str_replace("&","&",$param);
return $PHP_SELF.$param ;
}
function illustration_pied($livre,$no,$nb_images_dispo,$offset)
{
if ($offset == -1) return;
$no_img = ($offset+$no) % $nb_images_dispo;
$tag = ".".jpg";
$tag.= ")
";
$nav.= "";
$nav.= "";
$nav.= "
";
$nav.= "";
$nav.= "
";
$nav.= "";
$nav.= "";
$nav.= "
";
$nav.= "";
$nav.= "$texte
$texte
";
$res.= "";
$res.= "";
$res.= "
";
$res.= "";
return $res;
}
function titre_fenetre(&$infos,$l,$s,$c,$no,$est_livre,$lang)
{
$car_separation = "-" ;
if ($est_livre)
{
$res = convertir_entites($infos["titre_$lang"])." $car_separation ";
$res.= $infos['titre_py'];
if ($s==0) $res.= "";
else $res.= " ".arabe_vers_romain($s);
if ($c==0) $res.= "";
else $res.= ". $c.";
if (($no==0) or (ereg("chapitre=numero",TYPE_AFFICHAGE))) $res.= "";
else $res.= " ($no)";
}
else
{
if ($l == "intro") $res = "Wengu $car_separation ".($lang=="fr" ? "Classiques chinois" : "Chinese Classics");
else $res = $infos['titre_py']." $car_separation ".$infos["titre_$lang"];
if ($l == "rech") $res.= " (".$_GET["ch"].")";
}
$res = str_replace("-1",L_table,$res);
if ($l == "Yijing")
{
$res = str_replace(" I "," ",$res);
$res = str_replace("(","",$res);
$res = str_replace(")","",$res);
}
return $res;
}
function titre_livre(&$tab_infos,$lang,$l,$no)
{
$titre_livre = "".lien_dico($tab_infos['titre_zh'])."";
$titre_livre.= $tab_infos['titre_py'];
// CAS PAS LIVRE
if (!$GLOBALS["est_livre"])
{
$url_intro = autoURL("l=intro&s=&c=&no=");
$url_TOC = autoURL("l=intro&s=&c=&no=-1");
}
// CAS PAS INTRO DE LIVRE
elseif (!$GLOBALS["aff_intro_livre"])
{
$url_intro = autoURL("&l=$l&no=0&s=&c=");
if ($no != -1) $url_TOC = autoURL("&l=$l&no=-1&s=&c=");
}
// CAS INTRO DE LIVRE
else $url_TOC = autoURL("&l=$l&no=-1&s=&c=");
if ($l == "intro" and $no != -1) $url_intro = ""; // vire logo sur intro
if ($l == "intro" and $no == -1) $url_TOC = ""; // vire logo sur intro
if ($url_intro) $titre_livre.= "
";
if ($url_TOC) $titre_livre.="
";
if ($tab_infos["titre_$lang"])
{
$titre_livre.= " –";
$titre_livre.= " ".convertir_entites($tab_infos["titre_$lang"]);
}
return $titre_livre;
}
// ======================
// TRAITEMENTS DE CHAINES
// ======================
define('NOMBRES_CHINOIS','一,二,三,四,五,六,七,八,九,十');
define('PONCTUATION_CHINOISE','﹖,,,、,﹐,;,。,!,「,」,」,」,:');
//for ($i = 12250; $i <12420; $i++) echo "$i --- $i;
"; // chiffres
//for ($i = 65100; $i <65130; $i++) echo "$i --- $i;
"; // chiffres
//for ($i = 8200; $i <8300; $i++) echo "$i --- $i;
";
function nettoye_fin($tx)
{
$tx = ereg_replace("(
| |\r|\n)*$","",$tx);
return $tx;
}
function enleve_ponctuation_chinoise($in_texte)
{
$ponct_chinoise = explode(",",PONCTUATION_CHINOISE);
foreach($ponct_chinoise as $car)
{
$in_texte = str_replace($car,"",$in_texte);
}
return ($in_texte);
}
function un_htmlentities($string)
{
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip($trans_tbl);
return strtr($string, $trans_tbl);
}
// fonction convertir les caractères spéciaux
function convertir_entites($in_texte)
{
$out_texte = "";
$in_texte = trim($in_texte);
//$in_texte = ereg_replace("&","&",$in_texte);
$in_texte = str_replace("\$PHP_SELF&",$_SERVER['REQUEST_URI']."&",$in_texte);
$in_texte = str_replace("\$PHP_SELF?",$_SERVER['PHP_SELF']."?",$in_texte);
$longueur = strlen($in_texte);
for ($i = 0 ; $i < $longueur ; $i++)
{
if (ord($in_texte[$i]) >127) $out_texte .= "".ord($in_texte[$i]).";";
//elseif (ord($in_texte[$i]) == 13) $out_texte .= "
";
else $out_texte .= $in_texte[$i];
}
// autres corrections
$correction = array(
//"" => "'",
//"" => '"',
//"" => '"' ,
"---" => "—",
"--" => "–",
"" => "'", // "‘",
"" => "'", // "’",
"" => '“',
"" => '”' ,
"" => 'œ' ,
"« "=>"« ", // «
" »"=>" »", // »
" ?"=>" ?",
" ;"=>" ;",
" :"=>" :",
" !"=>" !",
"
"=>"
\n");
$out_texte = strtr($out_texte,$correction);
$out_texte = ereg_replace("(
\n)+$","",$out_texte); // pour nettoyer la fin
return $out_texte;
}
function arabe_vers_romain ( $nombre )
{
if ( ! $nombre || $nombre > 3999 )
return "";
if ($nombre<0) return $nombre;
if ($nombre>0) return arabe_vers_romain_interne ($nombre);
}
function arabe_vers_romain_interne ( $nombre )
{
if ( ! $nombre || $nombre > 3999 )
return "";
$symbole = array("I","V","X","L","C","D","M","M");
$longueur = strlen( $nombre );
$chiffre = (int)( $nombre / pow(10,$longueur-1) );
$chaine = "";
if ( $chiffre )
{if ( $chiffre > 5 )
{if ( $chiffre < 9 )
{$chaine .= $symbole[ ($longueur-1)*2+1 ];
for ( $i=1 ; $i<=($chiffre%5) ; $i++ ) $chaine .= $symbole[ ($longueur-1)*2 ];
}
else $chaine .= $symbole[ ($longueur-1)*2 ].$symbole[ ($longueur)*2 ];
}
else
{
if ( $chiffre < 4 )
{for ($i=1; $i<=$chiffre; $i++) $chaine .= $symbole[ ($longueur-1)*2 ]; }
else
$chaine .= ($chiffre%5 ? $symbole[($longueur-1)*2] : "").$symbole[($longueur-1)*2+1];
}
}
return $chaine.arabe_vers_romain_interne( $nombre - $chiffre*pow(10,$longueur-1) );
}
// ==================
// TRAITEMENTS DIVERS
// ==================
function interieur_segment($n,$ni,$ns)
{
if ($n < $ni) $n = $ns;
if ($n > $ns) $n = $ni;
return $n;
}
function inverse_tableau($in_array)
{
$size = count($in_array);
end($in_array);
for ($i=0; $i<$size; ++$i)
{
$key = key($in_array);
$out_array[$key] = $in_array[$key];
prev($in_array);
}
return $out_array;
}
function mysql_mktime($timestamp){
$hour = substr($timestamp, 8, 2);
$minute = substr($timestamp, 10, 2);
$second = substr($timestamp, 12, 2);
$month = substr($timestamp, 4, 2);
$day = substr($timestamp, 6, 2);
$year = substr($timestamp, 0, 4);
return mktime($hour, $minute, $second, $month, $day, $year);
}
function affiche_tableau_select($resu)
{
$nbcol = mysql_num_fields($resu);
$compte = 0;
$tx = "
";
$tx.= "contient $compte ligne(s)";
for ($i=0;$i<$nbcol;$i++)
{
$tx.= " ".mysql_field_name($resu,$i)." ";
}
while ($res = mysql_fetch_array($resu))
{
$compte++;
$tx.= "";
for ($i=0;$i<$nbcol;$i++)
{
//$tx.= " ";
}
$tx.= "".$res[$i]." ";
$tx.= "".substr($res[$i],0,300)." \n";
}
$tx.= "
\n";
return $tx;
}
?>
// TEXTES ANGLAIS
define('L_Anglais_francais', 'English / French');
define('L_Logo', 'Wengu, Chinese Classics multilingual text base');
define('L_DESC', 'CHINESE CLASSICS & TRANSLATIONS');
// titres des liens
define('L_Affiche_tout', 'Display all');
define('L_Section_precedente', 'Previous section');
define('L_Section_suivante', 'Next section');
define('L_Debut_livre', 'Book begining');
define('L_Chapitre_precedent', 'Previous chapter');
define('L_Chapitre_suivant', 'Next chapter');
define('L_Debut_section', 'Section begining');
define('L_Chant_precedent', 'Previous ode');
define('L_Chant_suivant', 'Next ode');
define('L_Debut_chapitre', 'Chapter begining');
define('L_Page_precedente', 'Previous page');
define('L_Page_suivante', 'Next page');
define('L_Prec', 'Prev.');
define('L_Haut', 'Up');
define('L_Bas', 'Down');
define('L_Suiv', 'Next');
// noms des pages
define('L_Index', 'Index');
define('L_Bienvenue', 'Welcome');
define('L_Notes_utilisateurs', 'User notes');
define('L_Liens', 'Links');
define('L_Recherche', 'Search');
define('L_Aide', 'Help');
// mots dans les pages
define('L_Traductions', 'Translations');
define('L_Livre', 'Book');
define('L_Section', 'Section');
define('L_Chapitre', 'Chapter');
define('L_Chants', 'Odes');
define('L_Chant', 'Ode');
define('L_Poemes', 'Poems');
define('L_Poeme', 'Poem');
define('L_Texte_chinois', 'Chinese text');
define('L_Introduction', 'Introduction');
define('L_Sources', 'Sources');
define('L_Table_matieres', 'Table of content');
define('L_Illustration', 'Illustration');
define('L_Table_incipits', 'Table & incipit');
define('L_Table_generale', 'Table of content');
define('L_Table_genres', 'Table by types');
define('L_Table_auteurs', 'Table by authors');
define('L_Extraits_aleatoires', 'Random samples');
define('L_Rechercher', 'Search');
define('L_Changer', 'Change');
define('L_Moteur_interne', 'Internal tool');
define('L_Pas_de_pubs', 'No commercials');
// divers
define('L_Paysage_chinois_sur_plateau','Chinese landscape on plate');
define('L_Pas_trouve','Not found');
define('L_lunyu_Liens_sections','(Click on sections above
and chapters will appear here)');
// notes utilisateurs
define('L_Ajouter_note', 'Add note');
define('L_Notes_et_illustration','Notes & illustration');
define('L_notes_sur_cette_page','notes on this page');
define('L_une_note_sur_cette_page','One note on this page');
define('L_Aucune_note_sur_cette_page','No note on this page');
define('L_Notes', 'Notes');
define('L_Note_de', 'Note from');
define('L_Commentaires', 'Commentaries');
define('L_Nom_pseudo', 'Name/pseudo');
define('L_Email_clef', 'E-mail/key');
define('L_Ajouter', 'Add');
define('L_Ajout_note', 'Add note');
define('L_Commentaire', 'Commentar');
define('L_Traduction', 'Translation');
define('L_Reponse', 'Answer');
define('L_Bogue', 'Bug report');
define('L_A_propos_du_site', 'About the site');
define('L_Autre_note', 'Other note');
define('L_Envoyer', 'Send in database');
define('L_Voir_modifications', 'See modification');
define('L_Vous_pouvez_modifier','You can change your note');
define('L_Votre_note', 'Your note');
define('L_Verification', 'Check');
define('L_Insertion', 'Insert');
define('L_Notes_utilisateurs', 'User notes');
define('L_Modification', 'Modify');
define('L_Type_note', 'Note category');
define('L_Reference', 'Reference');
define('L_Langue', 'Language');
define('L_Votre_note_est_enregistree', 'Your note has been saved (reload page to check)');
define('L_Revenir_a_la_page_annotee', 'Back to the annotated page');
define('L_retour', 'go back');
define('L_avec', 'with');
define('L_sur_ce_site', 'on this site');
define('L_sur_le_web', 'on the web');
define('L_AIDE_notes', 'N.B. : "E-mail/key" field is used as password and will not be displayed on site. "Text" field accept following tags : <i>, <b>, <u>, and <a>. Use $PHP_SELF string for inner links (i.e. <a href="$PHP_SELF?l=Lunyu&no=3"> links on the third analect).');
define('L_Annuler', 'Cancel');
define('L_dernieres_notes', 'last updated');
// recherche
define('L_Chercher', 'Search');
define('L_dans', 'in');
define('L_Tous', 'All');
define('L_tous', 'all');
define('L_resultat_trouve_dans', 'result found in the');
define('L_resultats_trouves_dans', 'results found in the');
define('L_Aucuns_resultats_trouves_dans', 'No results found in the');
define('L_ou_plus', 'or more');
define('L_Attention', 'Attention !');
define('L_la_chaine', 'the string');
define('L_est_trop_courte', 'is too short');
// pied de page
define('L_table', 'table');
define('L_la_suite', 'Next...');
define('L_Contact', 'Contact');
define('L_Haut_de_page', 'Top');
define('L_Chinois', 'Chinese');
define('L_oui', 'on');
define('L_non', 'off');
define('L_Ne_pas_afficher_caracteres', 'Do not display chinese characters');
define('L_Afficher_caracteres', 'Display chinese characters');
// tables
define('L_Versions', 'Versions');
define('L_pages', 'pages');
// Yijing
define("L_Trigrammes","Trigrams");
define("L_Hexagrammes","Hexagrams");
define("L_courant","current");
define("L_binome","binomial");
define("L_precedent","previous");
define("L_suivant","next");
define("L_echange_trig","swap trig.");
define("L_oppose","opposite");
define("L_tetenbas","flip");
define("L_maitre_gouvernant","leading master");
define("L_maitre_constituant","constituent master");
define("L_traits_ciel","Sky's two strokes");
define("L_traits_homme","Man's two strokes");
define("L_traits_terre","Earth's two strokes");
define("L_Tire","Cast");
define("L_RAZ","Reset");
define("L_Au_hasard","Random");
define("L_Commencer_par_le_bas_","Bottom first !");
define("L_Pas_de_mutation","No mutation, hexagram is static");
?>
function Yijing_tire_hexagramme($lang)
{
$res = <<
";
$ligne_img[0] = "
";
$tab_hexag[1]=array("", "1","43","14","34", "9", "5","26","11");
$tab_hexag[2]=array("","10","58","38","54","61","60","41","19");
$tab_hexag[3]=array("","13","49","30","55","37","63","22","36");
$tab_hexag[4]=array("","25","17","21","51","42", "3","27","24");
$tab_hexag[5]=array("","44","28","50","32","57","48","18","46");
$tab_hexag[6]=array("", "6","47","64","40","59","29", "4", "7");
$tab_hexag[7]=array("","33","31","56","62","53","39","52","15");
$tab_hexag[8]=array("","12","45","35","16","20", "8","23", "2");
if ($lang == "en")
{
$trig_comment[1] = "Ch´ien, the Creative\n strong\n heaven\n father";
$trig_comment[2] = "Tui, the Joyous\n joyful\n lake\n third daughter";
$trig_comment[3] = "Li, the Clinging\n light-giving\n fire\n second daughter";
$trig_comment[4] = "Chên, the Arousing\n inciting movement\n thunder\n first son";
$trig_comment[5] = "Sun, the Gentle\n penetrating\n wind, wood\n first daughter";
$trig_comment[6] = "K´an, the Abysmal\n dangerous\n water\n second son";
$trig_comment[7] = "Kên, Keeping Still\n resting\n mountain\n third son";
$trig_comment[8] = "K´un, the Receptive\n devoted yielding\n earth\n mother";
}
else
{
$trig_comment[1] = "K´ien, le créateur\n fort\n le ciel\n père";
$trig_comment[2] = "Touei, le joyeux, le serein\n joyeux\n le lac\n 3e fille";
$trig_comment[3] = "Li, ce qui adhère\n lumineux\n le feu\n 2e fille";
$trig_comment[4] = "Tchen, l´éveilleur\n en mouvement\n le tonnerre\n 1er fils\n";
$trig_comment[5] = "Souen, le doux\n pénétrant\n le vent\n 1re fille";
$trig_comment[6] = "K´an, l´insondable, l´abîme\n dangereux\n l´eau\n 2e fils";
$trig_comment[7] = "Ken, l´immobilisation\n en repos\n la montagne\n 3e fils";
$trig_comment[8] = "K´ouen, le réceptif\n soumis, abandonné\n la terre\n mère\n";
}
// $TOC GENERALE YIJING (ET INTRO)
if ($no == -1 or $no == 0)
{
// tableau 8 x 8 des hexagrammes
$tabhex = "$ii";
if (strpos(" 02 08 14 20 26 30 34 36 42 48 54 60 "," $ii ")>0) $liste.="
";
elseif ($i % 2 == 1 and $i != 64) $liste.=$sep[($i-1)/2];
else $liste.=" ";
}
$list.= "";
$toc = "";
$toc.= "
";
if ($no == 0) return $toc;
// TRIGRAMMES
$ord_trigs = array("","1","8","4","6","7","5","3","2");
$trigs = separateur(L_Trigrammes,$GLOBALS['param_inf'],$GLOBALS['param_sup'],$no_ancre);
$trigs.= "$tabhex ";
$toc.= "$liste ";//";
$toc.= " ";
$toc.= "";
$toc.= Yijing_tire_hexagramme($lang);
$toc.= " ";
for ($j = 1; $j <=8; $j++)
{
$i = $ord_trigs[$j];
$trigs.= "
";
// HEXAGRAMMES
$tx = separateur(L_Hexagrammes,$GLOBALS['param_inf'],$GLOBALS['param_sup'],$no_ancre);
$tx.= "";
$trigs.= " ";
}
$trigs.= " ";
$trigs.= "
".lien_dico("".$zh_trig[$i])." ";
$trigs.= "".str_replace("\n"," ",$trig_comment[$i])." ";
$trigs.= "";
//$tx.= "
";
return $toc.$trigs.$tx;
}
// TOC POUR CHAQUE PAGE
// cherche infos constituants
$rsql = requete("SELECT titre_zh,titre_py,titre_en,titre_fr,trig_bas,trig_haut,traits_maitres FROM Yijing_TOC WHERE numero = $no");
list ($titre_zh,$titre_py,$titre_en,$titre_fr,$trig_bas,$trig_haut,$traits_maitres) = mysql_fetch_array($rsql);
$traits = array_reverse(explode(",",",".$tab_trig[$trig_haut].",".$tab_trig[$trig_bas].","));
// cherche trigrammes nucléaires
$trig_nuc_haut = array_search($traits[5].",".$traits[4].",".$traits[3],$tab_trig);
$trig_nuc_bas = array_search($traits[4].",".$traits[3].",".$traits[2],$tab_trig);
// nom de l'hexa
$nom_hexa = "$no. ".lien_dico($titre_zh)." ";
//$nom_hexa.= "$titre_py — ";
$nom_hexa.= convertir_entites(($lang=="fr"? $titre_fr : $titre_en));
// legende
// $col_hexa = "#ccfccc";
// $col_prec = "#ffdef5";
// $col_suiv = "#ffc1de";
$col_hexa = "#ffc1de";
$col_prec = "#ccfccc";
$col_suiv = "#ccfccc";
$col_invt = "#ffee99"; // inverse les trigrammes
$col_oppo = "#ffd5cc"; // ##### échange chaque trait
$col_oppo = "#ccd5ff"; // échange chaque trait
$col_flip = "#FFCCAA"; // retourne l'hexa
$col_trait_gouvernant = "#0099FF";
$col_trait_constituant = "#FF0000";
$legende = " ";
$rsql = requete("SELECT numero,titre_zh,titre_$lang,trig_bas,trig_haut FROM Yijing_TOC");
while (list($numero,$titre_zh,$titre_tx,$trig_bas,$trig_haut) = mysql_fetch_array($rsql))
{
$url = autoURL("no=$numero");
if ($numero<10) $numero = "0$numero";
$tx.= " ";
$tx.= " \n ";
}
$tx.= " \n";
$tx.= "

".lien_dico($titre_zh)." \n";
$tx.= "".convertir_entites($titre_tx)." \n";
$tx.= "$numero \n";
$tx.= "
';
// remplacements dans code HTML
$TOChex = str_replace("_TRIG_HAUT_",
//$py_trig[$trig_haut].
" ".lien_dico("".$zh_trig[$trig_haut])."".
"
_TRIG_HAUT_
![]()

![]()
_6_
![]()
_5_
_TRIG_NUC_HAUT_
_TRIG_NUC_BAS_

![]()
_4_
_TRIG_BAS_
![]()
_3_

![]()
_2_
![]()
_1_
",
$TOChex);
$TOChex = str_replace("_TRIG_BAS_",
//$py_trig[$trig_bas].
" ".lien_dico("".$zh_trig[$trig_bas])."".
"
",
$TOChex);
$TOChex = str_replace("_TRIG_NUC_HAUT_",
"
".
//$py_trig[$trig_nuc_haut].
" ".lien_dico("".$zh_trig[$trig_nuc_haut])."",
$TOChex);
$TOChex = str_replace("_TRIG_NUC_BAS_",
"
".
//$py_trig[$trig_nuc_bas].
" ".lien_dico("".$zh_trig[$trig_nuc_bas])."",
$TOChex);
for ($i = 1; $i<=6; $i++)
{
$temp_no_trait = $_GET["tire"]{$i-1};
if (!($temp_no_trait > 5)) $temp_no_trait = $traits[$i];
$TOChex = str_replace("_TRAIT".$i."_",$temp_no_trait,$TOChex);
list($traits_gouvernants,$traits_constituants) = split(",",$traits_maitres);
if (ereg($i,$traits_gouvernants))
$TOChex = str_replace("_".$i."_","$i",$TOChex);
elseif (ereg($i,$traits_constituants))
$TOChex = str_replace("_".$i."_","$i",$TOChex);
else
$TOChex = str_replace("_".$i."_","$i",$TOChex);
}
// compile la TOC
$toc = "";
$toc.= "
";
$toc.= $legende;
return $toc;
}
// ==============================================================
function texte_Yijing($no,$lang,$type,$tirage = "",$deduit= "")
{
if ($no == "" and $_GET["s"] == 1)
{
for ($i=1;$i<=64;$i++) $aff_tout.= " ";
$toc.= "$tabhex ";
$toc.= "$nom_hexa ";
$toc.= "$TOChex ";
$toc.= "$hexa_corr
".texte_Yijing($i,$lang,$type,"","");
return $aff_tout;
}
// traite tirages
if ($tirage == "") $tirage = $_GET["tire"];
$ancient_tirage = $tirage;
if ($deduit == "DEDUIT")
{ $tirage = str_replace("6","7",$tirage);
$tirage = str_replace("9","8",$tirage); }
$tab_trig = array("","111","011","101","001","110","010","100","000");
$tab_hexag[1]=array("", "1","43","14","34", "9", "5","26","11");
$tab_hexag[2]=array("","10","58","38","54","61","60","41","19");
$tab_hexag[3]=array("","13","49","30","55","37","63","22","36");
$tab_hexag[4]=array("","25","17","21","51","42", "3","27","24");
$tab_hexag[5]=array("","44","28","50","32","57","48","18","46");
$tab_hexag[6]=array("", "6","47","64","40","59","29", "4", "7");
$tab_hexag[7]=array("","33","31","56","62","53","39","52","15");
$tab_hexag[8]=array("","12","45","35","16","20", "8","23", "2");
$temp = $tirage;
$temp = ereg_replace("[68]","0",$temp);
$temp = ereg_replace("[79]","1",$temp);
$trig_bas = array_search($temp{2}.$temp{1}.$temp{0},$tab_trig);
$trig_haut = array_search($temp{5}.$temp{4}.$temp{3},$tab_trig);
// LE CADRE POUR LA MUTATION
if ($deduit == "DEDUIT")
{
$no = $tab_hexag[$trig_bas][$trig_haut];
$debut = "
HEXAGRAMME $i
".L_Pas_de_mutation."";
for ($i=5; $i>=0; $i--)
{
$debut.= "
";
}
if ($tirage=="")
{
$rsql = requete("SELECT trig_haut,trig_bas FROM Yijing_TOC WHERE numero = $no");
list ($trig_haut,$trig_bas) = mysql_fetch_array($rsql);
}
$img_hexa.="";
$debut.= " ";
}
$debut.= " ";
$debut.= "
";
$debut.= "
";
$debut.= "

";
$img_hexa.= "
".$trad['trigrammes'];
// avorte si vide
if (trim($zh2) == "" and trim($tx) == "") continue;
// avorte si le trait est stable (7 ou 8)
list($junk,$temp_tirage) = explode("trait_",$champ);
$temp_tirage = $tirage{$temp_tirage-1};
if ($temp_tirage == 7 or $temp_tirage == 8) continue;
// formatte le texte chinois
if (ereg("vertical",$type))
{
$zh2 = str_replace("¡D","
",$zh2); // virgule
list ($vtitre2,$zh2) = explode ("
",$zh2,2);
$zh2 = ereg_replace("
[ \r\n]*$","",$zh2); // nettoie fin
}
if (ereg("vire_ponctuation",$type)) $zh2 = trim(strtr($zh2,$vire_ponctuation_trans));
if (ereg("vertical",$type))
$affzh = "
",$tx);
$trans = array("
";
$res.= lien_dico(str_replace("\r\n","
",$tab_zh["notes"]))."