= 0){
$query = "select toc from 'pali_text' where book='$book' and paragraph='$par_parent'";
$FetchToc = PDO_FetchAll($query);
if(count($FetchToc)>0){
$_parent_title = $FetchToc[0]["toc"];
}
}
$query = "select paragraph,toc from 'pali_text' where book='$book' and parent='$paragraph' and level < '8'";
$FetchParent = PDO_FetchAll($query);
foreach ($FetchParent as $key => $value) {
$tocHtml .= "
";
}
//查询标题
if($_view=="chapter"){
$par_title = $FetchParInfo[0]["toc"];
}
else{
$par_title = $_parent_title;
}
//导航按钮
if($_view=="sent"){
$next_para_link = "";
$prev_para_link = "";
}
else{
if($par_next != -1){
$query = "select paragraph , toc from 'pali_text' where book='$book' and paragraph='$par_next' ";
$FetchPara = PDO_FetchAll($query);
if(count($FetchPara)>0){
$next_para_link = "
{$FetchPara[0]["toc"]} ";
$next_para_link .= " ";
$next_para_link .= " ";
}
else{
$next_para_link = "没有查询到标题";
}
}
else{
$next_para_link = "没了";
}
if($par_prev != -1){
$query = "select paragraph , toc from 'pali_text' where book='$book' and paragraph='$par_prev' ";
$FetchPara = PDO_FetchAll($query);
if(count($FetchPara)>0){
$prev_para_link = "
";
$prev_para_link .= " ";
$prev_para_link .= " {$FetchPara[0]["toc"]} ";
}
else{
$prev_para_link = "没有查询到标题";
}
}
else{
$prev_para_link = "没了";
}
}
}
//设置标题栏的经文名称
echo "";
//上一级
echo "
";
//生成一个段落空壳 等会儿查询数据,按照不同数据类型填充进去
PDO_Connect("sqlite:"._FILE_DB_PALI_SENTENCE_);
if($_display=="sent"){
//逐句显示
for($iPar=$par_begin;$iPar<=$par_end;$iPar++){
if($_view=="sent"){
$query = "select text, begin, end from 'pali_sent' where book='$book' and paragraph='$paragraph' and begin='{$_GET["begin"]}' and end ='{$_GET["end"]}'";
}
else{
$query = "select text, begin, end from 'pali_sent' where book='$book' and paragraph='$iPar'";
}
$FetchSent = PDO_FetchAll($query);
echo "
";
echo "
$iPar ";
foreach ($FetchSent as $key => $value) {
echo "
";
$pali_sent = str_replace("{","",$value["text"]);
$pali_sent = str_replace("}"," ",$pali_sent);
echo "".$pali_sent." ";
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
}
echo "
";
}
}
else{
//段落显示
for($iPar=$par_begin;$iPar<=$par_end;$iPar++){
$query = "select text , begin, end from 'pali_sent' where book='$book' and paragraph='$iPar'";
$FetchSent = PDO_FetchAll($query);
echo "
";
echo "
";
echo "
$iPar ";
foreach ($FetchSent as $key => $value) {
$sent_text = str_replace("{","
",$value["text"]) ;
$sent_text = str_replace("}"," ",$sent_text) ;
echo "
{$sent_text} ";
}
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
echo "
";
}
}
if(isset($_GET["sent_mode"])){
}
PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
$dbh = new PDO("sqlite:"._FILE_DB_PALI_SENTENCE_, "", "");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
for($iPar=$par_begin;$iPar<=$par_end;$iPar++){
if($_view=="sent"){
$FetchPaliSent = array(array("begin" => $_GET["begin"] , "end" => $_GET["end"]));
}
else{
$query = "select begin, end from 'pali_sent' where book='$book' and paragraph='$iPar'";
$stmt = $dbh->query($query);
$FetchPaliSent = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
foreach ($FetchPaliSent as $key => $value) {
$begin = $value["begin"];
$end = $value["end"];
if($_view=="sent"){
$query="SELECT * FROM \"sentence\" WHERE (book = '{$book}' AND \"paragraph\" = ".$PDO->quote($iPar)." AND begin = '$begin' AND end = '$end' AND length(text)>0 ) order by modify_time DESC";
}
else{
$query = "SELECT * FROM \"sentence\" WHERE book = '{$book}' AND \"paragraph\" = ".$PDO->quote($iPar)." AND begin = '$begin' AND end = '$end' AND length(text)>0 order by modify_time DESC limit 0, 1";
}
$query_count = "SELECT count(book) FROM \"sentence\" WHERE book = '{$book}' AND \"paragraph\" = ".$PDO->quote($iPar)." AND begin = '$begin' AND end = '$end' AND length(text)>0 ";
$sent_count = PDO_FetchOne($query_count);
if($sent_count>9){
$sent_count = "9+";
}
$FetchText = PDO_FetchAll($query);
$iFetchText=count($FetchText);
if($iFetchText>0){
for($i=0;$i<$iFetchText;$i++){
$currParNo=$iPar;
if($_display=="sent"){
$sent_style = "display:block";
}
else{
$sent_style = "";
}
$tran_text = str_replace("[[","
",$FetchText[$i]["text"]);
$tran_text = str_replace("]]"," ",$tran_text);
echo "
".$tran_text;
if($_view!="sent" && $_display=="sent"){
echo "$sent_count ";
}
echo " ";
echo "";
}
}
}
}
//查询句子译文内容
//查询句子译文内容结束
echo "
";
echo "
";
echo "
";
echo "$prev_para_link
";
echo "
$next_para_link";
echo "
";
echo "
";
echo "
";
if(isset($album)){
/*
//自动逐词译
$db_file = "../appdata/palicanon/templet/p".$book."_tpl.db3";
PDO_Connect("sqlite:$db_file");
for($iPar=$par_begin;$iPar<=$par_end;$iPar++){
$query="SELECT * FROM \"main\" WHERE (\"paragraph\" = ".$PDO->quote($iPar)." ) ";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
echo "
";
for($i=0;$i<$iFetch;$i++){
$type=$Fetch[$i]["type"];
if($type!=".ctl."){
echo "
";
echo "
".$Fetch[$i]["word"]."
";
echo "
".$Fetch[$i]["mean"]."
";
echo "
";
}
}
echo "
";
echo "";
}
}
////自动逐词译结束
*/
PDO_Connect("sqlite:"._FILE_DB_RESRES_INDEX_);
$query = "select * from 'album' where id='$album'";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
switch($Fetch[0]["type"]){
case 1://巴利原文
break;
case 2://逐词译
$db_file =_DIR_PALICANON_WBW_."/p{$book}_wbw.db3";
PDO_Connect("sqlite:$db_file");
for($iPar=$par_begin;$iPar<=$par_end;$iPar++){
$table="p{$book}_wbw_data";
$query="SELECT * FROM \"{$table}\" WHERE (\"paragraph\" = ".$PDO->quote($iPar)." ) and album_id={$album} ";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
echo "
";
for($i=0;$i<$iFetch;$i++){
$wordtype=$Fetch[$i]["type"];
if($wordtype!=".ctl."){
echo "
";
echo "
{$Fetch[$i]["word"]}
";
echo "
{$Fetch[$i]["mean"]}
";
echo "
{$wordtype}#{$Fetch[$i]["gramma"]}
";
echo "
";
}
}
echo "
";
echo "";
}
}
break;
case 3:
//译文
$tocHtml="";
//打开翻译数据文件
$db_file =_DIR_PALICANON_TRAN_."/p{$book}_translate.db3";
PDO_Connect("sqlite:{$db_file}");
$this_album_id=$album;
$table="p{$book}_translate_info";
if($par_begin==-1){
//全文
$query="SELECT * FROM '{$table}' WHERE album_id=$this_album_id ";
}
else{
//部分段落
$query="SELECT * FROM '{$table}' WHERE (\"paragraph\" BETWEEN ".$PDO->quote($par_begin)." AND ".$PDO->quote($par_end).") and album_id=$this_album_id ";
}
//查询翻译经文内容
$FetchText = PDO_FetchAll($query);
$iFetchText=count($FetchText);
if($iFetchText>0){
for($i=0;$i<$iFetchText;$i++){
$currParNo=$FetchText[$i]["paragraph"];
//查另一个表,获取段落文本。一句一条记录。有些是一段一条记录
$table_data="p{$book}_translate_data";
$query="SELECT * FROM '{$table_data}' WHERE info_id={$FetchText[$i]["id"]}";
$aParaText = PDO_FetchAll($query);
$par_text="";
foreach($aParaText as $sent){
$par_text.=$sent["text"];
}
//获取段落文本结束。
$par_text=str_replace("
","
",$par_text);
echo "
";
echo "
";
echo "
".$par_text."
";
echo "";
echo "
";
echo "";
//目录字符串
$tocLevel=$par_level["$currParNo"]+1-1;
if($tocLevel>0 && $tocLevel<8){
$tocHtml.="
";
}
}
//设置标题栏的经文名称
echo "";
}
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
}
}
//添加注解
PDO_Connect("sqlite:"._FILE_DB_COMMENTS_);
if($par_begin==-1){
$query="SELECT * FROM \"comments\" WHERE album='$album' order by id DESC";
}
else{
$query="SELECT * FROM \"comments\" WHERE album='$album' AND (\"paragraph\" BETWEEN ".$PDO->quote($par_begin)." AND ".$PDO->quote($par_end).") order by id DESC ";
}
//查询注解内容
$FetchText = PDO_FetchAll($query);
$iFetchText=count($FetchText);
if($iFetchText>0){
for($i=0;$i<$iFetchText;$i++){
$currParNo=$FetchText[$i]["paragraph"];
$comm_id=$FetchText[$i]["id"];
echo "";
echo "";
}
}
if($par_next!=-1){
echo "
Next ";
}
}
?>