Sfoglia il codice sorgente

复刻支持channel

visuddhinanda 5 anni fa
parent
commit
0d2d50ce33

+ 168 - 72
app/doc/fork.php

@@ -1,12 +1,19 @@
 <?php
-/*
+/*拷贝其他人的文件
 *
 *
 */
-
+require_once '../studio/index_head.php';
+?>
+<body id="file_list_body" >
+<?php
     require_once "../public/_pdo.php";
     require_once "../public/function.php";
-    require_once "../path.php";
+	require_once "../path.php";
+
+	require_once '../studio/index_tool_bar.php';
+
+	echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
 
     if($_COOKIE["uid"]){
         $uid=$_COOKIE["uid"];
@@ -15,13 +22,91 @@
         echo "尚未登录";
         echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
         exit;
-    }
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-    if(isset($_GET["doc_id"])){
-        $doc_id=$_GET["doc_id"];
-        $query = "select * from fileindex where id='{$doc_id}' ";
-        $Fetch = PDO_FetchAll($query);
-        $iFetch=count($Fetch);
+	}
+	if(isset($_GET["doc_id"])==false){
+		echo "没有 文档编号";
+		exit;
+	}
+	PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+	$doc_id=$_GET["doc_id"];
+	$query = "select * from fileindex where id= ? ";
+	$Fetch = PDO_FetchAll($query,array($doc_id));
+	$iFetch=count($Fetch);
+	if($iFetch>0){
+		//文档信息
+		$mbook=$Fetch[0]["book"];
+		$paragraph=$Fetch[0]["paragraph"];
+	}
+
+	if(isset($_GET["channel"])==false){
+		echo '<div class="file_list_block">';
+		echo "<h2>选择一个空白的版风存储新的文档</h2>";
+		echo "<form action='fork.php' method='get'>";
+		echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+		PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+		$query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+		$Fetch = PDO_FetchAll($query);
+		$i=0;
+		foreach($Fetch as $row){
+			echo '<div class="file_list_row" style="padding:5px;display:flex;">';
+		
+			echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+			echo '<input name="channel" value="'.$row["id"].'" ';
+			if($i==0){
+				echo "checked";
+			}
+			echo ' type="radio" />';
+			echo '</div>';
+			echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["name"].'</div>';
+			echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+			$query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+			$FetchWBW = PDO_FetchOne($query);
+			echo '</div>';
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			if($FetchWBW==0){
+				echo $_local->gui->blank;
+			}
+			else{
+				echo $FetchWBW.$_local->gui->para;
+				echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+			}
+			echo '</div>';
+
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+			$query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+			$FetchWBW = PDO_FetchOne($query);
+			echo '</div>';
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			if($FetchWBW==0){
+				echo $_local->gui->blank;
+			}
+			else{
+				echo $FetchWBW.$_local->gui->para;
+			}
+			echo '</div>';
+
+			echo '<div class="summary"  style="flex:1;padding-bottom:5px;">'.$row["status"].'</div>';
+			echo '<div class="author"  style="flex:1;padding-bottom:5px;">'.$row["create_time"].'</div>';
+			
+			echo '</div>';
+			$i++;
+		}
+		echo "<input type='submit' />";
+		echo "</form>";
+		echo "</div>";
+		exit;
+	}
+    
+	//if(isset($_GET["doc_id"]))
+	{
+		PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+		$doc_id=$_GET["doc_id"];
+		$query = "select * from fileindex where id= ? ";
+		$Fetch = PDO_FetchAll($query,array($doc_id));
+		$iFetch=count($Fetch);
         if($iFetch>0){
             //文档信息
             $orgFileInfo = $Fetch[0];
@@ -97,23 +182,25 @@
                                     $stmt = $dbhSent->prepare($query);
                                     $stmt->execute(array($blockid));
                                     $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
-                                    $newBlockId = UUID::V4();
-                                    $newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
+									$newBlockId = UUID::V4();
+									//不复刻译文
+                                    //$newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
                                     $arrSentBlockTransform[$fBlock[0]["id"]] = $newBlockId;
                                     if(count($fBlock)>0){
-                                        array_push( $arrSentNewBlock,array($newBlockId,
-                                                                        $fBlock[0]["id"],
-                                                                        $fBlock[0]["book"],
-                                                                        $fBlock[0]["paragraph"],
-                                                                        $_COOKIE["userid"],
-                                                                        $fBlock[0]["lang"],
-                                                                        $fBlock[0]["author"],
-                                                                        $fBlock[0]["editor"],
-                                                                        $fBlock[0]["tag"],
-                                                                        $fBlock[0]["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrSentNewBlock,
+													array($newBlockId,
+                                                          $fBlock[0]["id"],
+                                                          $fBlock[0]["book"],
+                                                          $fBlock[0]["paragraph"],
+                                                          $_COOKIE["userid"],
+                                                          $fBlock[0]["lang"],
+                                                          $fBlock[0]["author"],
+                                                          $fBlock[0]["editor"],
+                                                          $fBlock[0]["tag"],
+                                                          $fBlock[0]["status"],
+                                                          mTime(),
+                                                          mTime()
+                                                        ));
                                     }
 
                                     $query = "select * from sentence where block_id= ? ";
@@ -121,22 +208,24 @@
                                     $stmtSent->execute(array($fBlock[0]["id"]));
                                     $fBlockData = $stmtSent->fetchAll(PDO::FETCH_ASSOC);
                                     foreach($fBlockData as $value){
-                                        array_push( $arrSentNewBlockData,array(UUID::V4(),
-                                                                        $arrSentBlockTransform[$value["block_id"]],
-                                                                        $value["book"],
-                                                                        $value["paragraph"],
-                                                                        $value["begin"],
-                                                                        $value["end"],
-                                                                        $value["tag"],
-                                                                        $value["author"],
-                                                                        $_COOKIE["userid"],
-                                                                        $value["text"],
-                                                                        $value["language"],
-                                                                        $value["ver"],
-                                                                        $value["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrSentNewBlockData,
+													array(UUID::V4(),
+														$arrSentBlockTransform[$value["block_id"]],
+														$value["book"],
+														$value["paragraph"],
+														$value["begin"],
+														$value["end"],
+														$value["channal"],
+														$value["tag"],
+														$value["author"],
+														$_COOKIE["userid"],
+														$value["text"],
+														$value["language"],
+														$value["ver"],
+														$value["status"],
+														mTime(),
+														mTime()
+													));
 
                                     }
                                     
@@ -147,7 +236,8 @@
                                 break;
                                 case 5:
                                 break;
-                                case 6:
+								case 6: 
+									#逐词解析
                                     $blockid = $blocks[$i]->block_id;
                                     $query = "select * from wbw_block where id= ? ";
                                     $stmt = $dbhWBW->prepare($query);
@@ -157,17 +247,19 @@
                                     $newDocBlockList[]=array('type' => 6,'block_id' => $newBlockId);
                                     $arrBlockTransform[$fBlock[0]["id"]] = $newBlockId;
                                     if(count($fBlock)>0){
-                                        array_push( $arrNewBlock,array($newBlockId,
-                                                                        $fBlock[0]["id"],
-                                                                        $_COOKIE["userid"],
-                                                                        $fBlock[0]["book"],
-                                                                        $fBlock[0]["paragraph"],
-                                                                        $fBlock[0]["style"],
-                                                                        $fBlock[0]["lang"],
-                                                                        $fBlock[0]["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrNewBlock,
+													array($newBlockId,
+														$fBlock[0]["id"],
+														$_GET["channel"],
+														$_COOKIE["userid"],
+														$fBlock[0]["book"],
+														$fBlock[0]["paragraph"],
+														$fBlock[0]["style"],
+														$fBlock[0]["lang"],
+														$fBlock[0]["status"],
+														mTime(),
+														mTime()
+													));
                                     }
 
                                     $query = "select * from wbw where block_id= ? ";
@@ -175,18 +267,19 @@
                                     $stmtWBW->execute(array($fBlock[0]["id"]));
                                     $fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
                                     foreach($fBlockData as $value){
-                                        array_push( $arrNewBlockData,array(UUID::V4(),
-                                                                        $arrBlockTransform[$value["block_id"]],
-                                                                        $value["book"],
-                                                                        $value["paragraph"],
-                                                                        $value["wid"],
-                                                                        $value["word"],
-                                                                        $value["data"],
-                                                                        mTime(),
-                                                                        mTime(),
-                                                                        $value["status"],
-                                                                        $_COOKIE["userid"]
-                                                                    ));
+										array_push( $arrNewBlockData,
+													array(UUID::V4(),
+														$arrBlockTransform[$value["block_id"]],
+														$value["book"],
+														$value["paragraph"],
+														$value["wid"],
+														$value["word"],
+														$value["data"],
+														mTime(),
+														mTime(),
+														$value["status"],
+														$_COOKIE["userid"]
+													));
 
                                     }
                                 break;
@@ -200,10 +293,9 @@
                         
                         if(count($arrNewBlock)>0){
                             $dbhWBW->beginTransaction();
-                            $query="INSERT INTO wbw_block ('id','parent_id','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?)";
+                            $query="INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
                             $stmtNewBlock = $dbhWBW->prepare($query);
                             foreach($arrNewBlock as $oneParam){
-                                //print_r($oneParam);
                                 $stmtNewBlock->execute($oneParam);
                             }
                             // 提交更改 
@@ -239,10 +331,11 @@
                                 echo "new wbw $count recorders.";
                             }   
                         }
-                        
+						
+						//不复刻译文
                         
                         //译文 block数据块
-                        
+                        /*
                         if(count($arrSentNewBlock)>0){
                             $dbhSent->beginTransaction();
                             $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
@@ -267,7 +360,7 @@
                         if(count($arrSentNewBlockData)>0){
                             // 开始一个事务,逐词解析数据 关闭自动提交
                             $dbhSent->beginTransaction();
-                            $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
+                            $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','channal','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
                             $stmtSentData = $dbhSent->prepare($query);
                             foreach($arrSentNewBlockData as $oneParam){
                                 $stmtSentData->execute($oneParam);
@@ -284,7 +377,7 @@
                                 echo "new translation $count recorders.";
                             }   
                         }
-                        
+                        */
 
                         //插入记录到文件索引
                         $filesize=0;
@@ -360,5 +453,8 @@
         }
     }
 
+	echo "</div>";
+?>
 
-?>
+</body>
+</html>

+ 189 - 66
app/doc/pcs2db.php

@@ -7,27 +7,125 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-echo "<h2>转换pcs 到数据库格式</h2>";
-$dir = _DIR_USER_BASE_.'/'.$_COOKIE["userid"]._DIR_MYDOCUMENT_;
+require_once '../studio/index_head.php';
+echo '<body id="file_list_body" >';
+echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
+
+echo "<h2>转换PCS 到数据库格式</h2>";
+
+if($_COOKIE["uid"]){
+	$uid=$_COOKIE["uid"];
+}
+else{
+	echo "尚未登录";
+	echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
+	exit;
+}
+if(isset($_GET["doc_id"])==false){
+	echo "没有 文档编号";
+	exit;
+}
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-$query = "select file_name, doc_info, modify_time from fileindex where id='".$_GET["doc_id"]."' ";
-$Fetch = PDO_FetchAll($query);
+$doc_id=$_GET["doc_id"];
+$query = "select * from fileindex where id= ? ";
+$Fetch = PDO_FetchAll($query,array($doc_id));
+$iFetch=count($Fetch);
+if($iFetch>0){
+	//文档信息
+	$mbook=$Fetch[0]["book"];
+	$paragraph=$Fetch[0]["paragraph"];
+}
+
+if(isset($_GET["channel"])==false){
+	echo '<div class="file_list_block">';
+	echo "<h2>选择一个空白的版风存储新的文档</h2>";
+	echo "<form action='pcs2db.php' method='get'>";
+	echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+	PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+	$query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+	$Fetch = PDO_FetchAll($query);
+	$i=0;
+	foreach($Fetch as $row){
+		echo '<div class="file_list_row" style="padding:5px;display:flex;">';
+	
+		echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+		echo '<input name="channel" value="'.$row["id"].'" ';
+		if($i==0){
+			echo "checked";
+		}
+		echo ' type="radio" />';
+		echo '</div>';
+		echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["name"].'</div>';
+		echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["lang"].'</div>';
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+		$query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+		$FetchWBW = PDO_FetchOne($query);
+		echo '</div>';
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		if($FetchWBW==0){
+			echo $_local->gui->blank;
+		}
+		else{
+			echo $FetchWBW.$_local->gui->para;
+			echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+		}
+		echo '</div>';
+
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+		$query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+		$FetchWBW = PDO_FetchOne($query);
+		echo '</div>';
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		if($FetchWBW==0){
+			echo $_local->gui->blank;
+		}
+		else{
+			echo $FetchWBW.$_local->gui->para;
+		}
+		echo '</div>';
 
-if(count($Fetch)>0){
+		echo '<div class="summary"  style="flex:1;padding-bottom:5px;">'.$row["status"].'</div>';
+		echo '<div class="author"  style="flex:1;padding-bottom:5px;">'.$row["create_time"].'</div>';
+		
+		echo '</div>';
+		$i++;
+	}
+	echo "<input type='submit' />";
+	echo "</form>";
+	echo "</div>";
+	exit;
+}
+
+$dir = _DIR_USER_DOC_.'/'.$_COOKIE["userid"]._DIR_MYDOCUMENT_;
+PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+$query = "SELECT file_name, doc_info, modify_time from fileindex where id=? ";
+$Fetch = PDO_FetchRow($query,array($_GET["doc_id"]));
+
+if($Fetch===false){
+	echo "文件不存在";
+    exit;    
+}
+else{
     $file_modify_time = $Fetch[0]["modify_time"];
     if(empty($Fetch[0]["doc_info"])){
         $file = $dir.'/'.$Fetch[0]["file_name"];    
     }
     else{
-        echo "已经是数据库格式了。无需转换";
+		echo "已经是数据库格式了。无需转换";
+		exit;
     }
 }
-else{
-    echo "文件不存在";
-    exit;    
+if(!file_exists($file)){
+	echo "文件不存在";
+	exit;
 }
-
 $xml = simplexml_load_file($file);
+if($xml==false){
+	echo "载入pcs文件错误";
+	exit;
+}
 $xml_head = $xml->xpath('//head')[0];
 $strHead = "<head>";
 $strHead .= "<type>{$xml_head->type}</type>";
@@ -77,7 +175,6 @@ $dataBlock = $xml->xpath('//block');
                 echo "translate:".$block->info->book."<br>";
             break;
         }
-    
     }
 
     foreach($dataBlock as $block) {
@@ -86,8 +183,9 @@ $dataBlock = $xml->xpath('//block');
             break;
             case "translate":
                 //译文
-                $blockid = sprintf("%s",$block->info->id);
-                $newDocBlockList[]=array('type' => 2,'block_id' => $blockid);
+				$blockid = UUID::V4();
+				//译文不加入块列表 因为译文用channel解决 不需要渲染译文块
+                //$newDocBlockList[]=array('type' => 2,'block_id' => $blockid);
                 $arrSentBlockTransform["{$blockid}"] = $blockid;
                 //if(count($fBlock)>0)
                 {
@@ -118,46 +216,52 @@ $dataBlock = $xml->xpath('//block');
                     else{
                         $sent_end="";
                     }
-                    if(isset($sen->text)){
+                    if(isset($sen->text) && strlen(trim($sen->text))>0){
                         $paraText=$sen->text;
                         if( $block->info->level>0 &&  $block->info->level<8){
                             $toc.=$sen->text;
-                        }
+						}
+						array_push( $arrSentNewBlockData,
+									array(UUID::V4(),
+										$blockid,
+										$block->info->book,
+										$block->info->paragraph,
+										$sent_begin,
+										$sent_end,
+										"",
+										$block->info->author,
+										$_COOKIE["userid"],
+										$paraText,
+										mb_strlen($paraText,"UTF-8"),
+										$block->info->language,
+										"1",
+										"7",
+										$file_modify_time,
+										mTime(),
+										mTime(),
+										$_GET["channel"]
+									));						
                     }
-                    array_push( $arrSentNewBlockData,array(UUID::V4(),
-                                    $blockid,
-                                    $block->info->book,
-                                    $block->info->paragraph,
-                                    $sent_begin,
-                                    $sent_end,
-                                    "",
-                                    $block->info->author,
-                                    $_COOKIE["userid"],
-                                    $paraText,
-                                    $block->info->language,
-                                    "1",
-                                    "7",
-                                    $file_modify_time,
-                                    mTime()
-                                ));
                 }
             break;
             case "wbw":
-                $blockid = sprintf("%s",$block->info->id);
+                $blockid = UUID::V4();
                 $newDocBlockList[]=array('type' => 6,'block_id' => $blockid);
                 $arrBlockTransform["{$blockid}"] = $blockid;
                 {
-                    array_push( $arrNewBlock,array($blockid,
-                                                    "",
-                                                    $_COOKIE["userid"],
-                                                    $block->info->book,
-                                                    $block->info->paragraph,
-                                                    "",
-                                                    $block->info->language,
-                                                    "",
-                                                    $file_modify_time,
-                                                    mTime()
-                                                ));
+					array_push( $arrNewBlock,
+								array($blockid,
+								"",
+								$_GET["channel"],
+								$_COOKIE["userid"],
+								$block->info->book,
+								$block->info->paragraph,
+								"",
+								$block->info->language,
+								"",
+								$file_modify_time,
+								mTime()
+							));
                 }
 
                 $currWordId = "";
@@ -194,13 +298,13 @@ $dataBlock = $xml->xpath('//block');
                     $sWordData .= "<pali>{$word->pali}</pali>";
                     $sWordData .= "<real>{$word->real}</real>";
                     $sWordData .= "<id>{$word->id}</id>";
-                    $sWordData .= "<type status=\"0\">{$word->type}</type>";
-                    $sWordData .= "<gramma status=\"0\">{$word->gramma}</gramma>";
-                    $sWordData .= "<mean status=\"0\">{$word->mean}</mean>";
-                    $sWordData .= "<org status=\"0\">{$word->org}</org>";
-                    $sWordData .= "<om status=\"0\">{$word->om}</om>";
-                    $sWordData .= "<case status=\"0\">{$word->case}</case>";
-                    $sWordData .= "<note status=\"0\">{$word->note}</note>";
+                    $sWordData .= "<type status='0'>{$word->type}</type>";
+                    $sWordData .= "<gramma status='0'>{$word->gramma}</gramma>";
+                    $sWordData .= "<mean status='0'>{$word->mean}</mean>";
+                    $sWordData .= "<org status='0'>{$word->org}</org>";
+                    $sWordData .= "<om status='0'>{$word->om}</om>";
+                    $sWordData .= "<case status='0'>{$word->case}</case>";
+                    $sWordData .= "<note status='0'>{$word->note}</note>";
                     $sWordData .= "<style>{$word->style}</style>";
                     $sWordData .= "<status>{$word->status}</status>";
                     $sWordData .= "<parent>{$word->parent}</parent>";
@@ -221,18 +325,19 @@ $dataBlock = $xml->xpath('//block');
 
                      $iWordCount++;
                 }
-                array_push( $arrNewBlockData,array(UUID::V4(),
-                $blockid,
-                $block->info->book,
-                $block->info->paragraph,
-                $word_id,
-                $word->real,
-                $sWordData,
-                $file_modify_time,
-                mTime(),
-                $word->status,
-                $_COOKIE["userid"]
-            ));
+				array_push( $arrNewBlockData,
+							array(UUID::V4(),
+							$blockid,
+							$block->info->book,
+							$block->info->paragraph,
+							$word_id,
+							$word->real,
+							$sWordData,
+							$file_modify_time,
+							mTime(),
+							$word->status,
+							$_COOKIE["userid"]
+            			));
             break;
             case 2:
 
@@ -241,12 +346,26 @@ $dataBlock = $xml->xpath('//block');
 
     }
     
-    //逐词解析block数据块
+    //逐词解析block数据块结束
 
 
+	#插入逐词解析块数据
     if(count($arrNewBlock)>0){
         $dbhWBW->beginTransaction();
-        $query="INSERT INTO wbw_block ('id','parent_id','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?)";
+        $query="INSERT INTO wbw_block (
+										'id',
+										'parent_id',
+										'channal',
+										'owner',
+										'book',
+										'paragraph',
+										'style',
+										'lang',
+										'status',
+										'modify_time',
+										'receive_time'
+										) 
+										VALUES (?,?,?,?,?,?,?,?,?,?,?)";
         $stmtNewBlock = $dbhWBW->prepare($query);
         foreach($arrNewBlock as $oneParam){
             $stmtNewBlock->execute($oneParam);
@@ -312,7 +431,7 @@ $dataBlock = $xml->xpath('//block');
     if(count($arrSentNewBlockData)>0){
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhSent->beginTransaction();
-        $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
+        $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','strlen','language','ver','status','modify_time','receive_time','create_time','channal') VALUES (? , ? , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
         $stmtSentData = $dbhSent->prepare($query);
         foreach($arrSentNewBlockData as $oneParam){
             $stmtSentData->execute($oneParam);
@@ -374,4 +493,8 @@ $dataBlock = $xml->xpath('//block');
     }          
                 
 }
-?>
+?>
+
+</div>
+</body>
+</html>

+ 1 - 0
app/install/step1.php

@@ -28,6 +28,7 @@ $dir[]=_DIR_DICT_SYSTEM_;
 $dir[]=_DIR_DICT_3RD_;
 
 $dir[]=_DIR_USER_BASE_;
+$dir[]=_DIR_USER_DOC_;
 $dir[]=_DIR_PALI_CSV_;
 $dir[]=_DIR_TEMP_;
 $dir[]=_DIR_LOG_;

+ 54 - 0
app/palicanon/get_chapter_children.php

@@ -0,0 +1,54 @@
+<?php
+require_once '../path.php';
+
+$dns = "sqlite:"._FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+$dns = "sqlite:"._FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+if(isset($_GET["book"])){
+	$book = $_GET["book"];
+}
+if(isset($_GET["para"])){
+	$para = $_GET["para"];
+}
+
+$query = "SELECT chapter_len FROM pali_text WHERE book = ? and paragraph = ?";
+$stmt = $dbh_pali_text->prepare($query);
+$stmt->execute(array($book,$para));
+$paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
+if($paraInfo){
+	$query = "SELECT level FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 0,1";
+	$stmt = $dbh_pali_text->prepare($query);
+	$stmt->execute(array($book,$para+1,$para+$paraInfo["chapter_len"]));
+	$paraMax = $stmt->fetch(PDO::FETCH_ASSOC);
+	if($paraMax){
+		$query = "SELECT book, paragraph, level , toc as title FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 0,1000";
+		$stmt = $dbh_pali_text->prepare($query);
+		$stmt->execute(array($book,$para,$para+$paraInfo["chapter_len"],$paraMax["level"]));
+		$paraList = $stmt->fetchAll(PDO::FETCH_ASSOC);	
+		foreach ($paraList as $key => $value) {
+			# 查进度
+			$query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
+			$stmt = $dbh_toc->prepare($query);
+			$sth_toc = $dbh_toc->prepare($query);
+			$sth_toc->execute(array($book,$para));
+			$paraProgress = $sth_toc->fetchAll(PDO::FETCH_ASSOC);
+			$paraList[$key]["progress"]=$paraProgress;
+		}
+		echo json_encode($paraList, JSON_UNESCAPED_UNICODE);
+	}
+	else{
+		echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+	}
+	
+}
+else{
+	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+}
+
+
+?>

+ 43 - 3
app/palicanon/index.php

@@ -1,5 +1,5 @@
 <?PHP
-include "../pcdl/html_head.php";
+require_once "../pcdl/html_head.php";
 ?>
 
 <body>
@@ -96,7 +96,7 @@ include "../pcdl/html_head.php";
 
         .sutta_row div {
             padding: 10px;
-            display: flex;
+            /*display: flex;*/
             justify-items: center;
         }
 
@@ -104,6 +104,34 @@ include "../pcdl/html_head.php";
             background-color: var(--drop-bg-color);
         }
 
+		.c_level_1 {
+			padding-top: 15px;
+			padding-bottom: 15px;
+			background-color: var(--main-color1);
+		}
+		.c_level_1 .chapter_title{
+			font-size:120%;
+			font-weight:700;
+		}
+		#book_list{
+			display: flex;
+			flex-wrap: wrap;
+		}
+		.chapter_list{
+			display:none;
+		}
+		.chapter_book{
+			display:block;
+		}
+		.chapter_progress{
+			display:block;
+		}
+		.parent_chapter{
+			width:350px;
+		}
+		.parent_chapter .chapter_book,.parent_chapter .chapter_progress{
+			display:none;
+		}
         @media screen and (max-width:800px) {
             .sutta_row {
                 grid-template-columns: 100px 1fr 1fr;
@@ -150,8 +178,20 @@ include "../pcdl/html_head.php";
     echo "</div>";
     echo '</div>';
     ?>
-    <div id="book_list" class='index_inner' style='display: flex;flex-wrap: wrap;'>
+	<div class='index_inner'>
+	<div id="chapter_shell" style="display:flex;" >
 
+    <div id="book_list" class="chapter_list" list="1" >
+    </div>
+
+    <div id="chapter_list_1" class="chapter_list"  >
+    </div>
+    <div id="chapter_list_2" class="chapter_list" >
+    </div>
+    <div id="chapter_list_3" class="chapter_list" >
+    </div>
+
+    </div>
     </div>
 
     <script>

+ 41 - 4
app/palicanon/palicanon.js

@@ -90,19 +90,21 @@ function tag_changed() {
 					}
 				}
 
+				let level_class = "c_level_" + iterator[0].level;
 				//html += "<div style='width:100%;'>";
-				html += "<div class='sutta_row' >";
+				html += "<div class='sutta_row  " + level_class + "' >";
 				html += "<div class='sutta_box'>" + tag0 + "</div>";
+
 				html +=
-					"<div class='sutta_box'><a href='../reader/?view=chapter&book=" +
+					"<div class='chapter_title'><a href='../reader/?view=chapter&book=" +
 					iterator[0].book +
 					"&para=" +
 					iterator[0].para +
 					"' target = '_blank'>" +
 					iterator[0].title +
 					"</a></div>";
-				html += "<div class='sutta_box'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
-				html += "<div class='sutta_tag'>tag=" + iterator[0].tag + "</div>";
+				html += "<div class='chapter_book'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
+				html += "<div class='chapter_progress'>tag=" + iterator[0].tag + "</div>";
 				html += "</div>";
 				//html += "</div>";
 			}
@@ -120,6 +122,41 @@ function tag_changed() {
 		}
 	);
 }
+
+function palicanon_load_chapter(book, para) {
+	$.get(
+		"get_chapter_children.php",
+		{
+			book: book,
+			para: para,
+		},
+		function (data, status) {
+			let arrChapterList = JSON.parse(data);
+			let html = "";
+			for (const iterator of arrChapterList) {
+				html += palicanon_render_chapter_row(iterator);
+			}
+			$("#chapter_list_1").html(html);
+			$("#chapter_list_1").show();
+			$("#book_list").addClass("parent_chapter");
+		}
+	);
+}
+function palicanon_render_chapter_row(chapter) {
+	let html = "";
+	html += "<div class='sutta_row' >";
+	html += "<div class='chapter_title'><a>" + chapter.title + "</a></div>";
+	html += "<div class='chapter_book'>book:" + chapter.book + " para:" + chapter.para + "</div>";
+	html += "<div class='chapter_progress'>";
+	if (chapter.progress) {
+		for (const iterator of chapter.progress) {
+			html += "<div>" + iterator.lang + "-" + iterator.all_trans + "</div>";
+		}
+	}
+	html += "</div>";
+	html += "</div>";
+	return html;
+}
 function tag_get_local_word(word) {
 	let termKey = term_lookup_my(word, "", getCookie("userid"), getCookie("language"));
 	if (termKey) {

+ 1 - 0
app/path.php

@@ -63,6 +63,7 @@ define("_DIR_BOOK_INDEX_" , __DIR__."/../app/public/book_index");
 
 /*user data*/
 define("_DIR_USER_BASE_" , __DIR__."/../tmp/user");
+define("_DIR_USER_DOC_" , __DIR__."/../tmp/user_doc");
 define("_DIR_USER_IMG_" , __DIR__."/../tmp/user/media/3");
 define("_DIR_USER_IMG_LINK_" , "../../tmp/user/media/3");
 define("_DIR_MYDOCUMENT_" , "/my_document");

+ 1 - 1
app/studio/dom_http.php

@@ -24,7 +24,7 @@ PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 $query="select file_name from fileindex where user_id='{$_COOKIE["uid"]}' AND  id='{$fileid}'";
 $Fetch = PDO_FetchOne($query);
 $purefilename=$Fetch;
-$FileName =_DIR_USER_BASE_."/".$_COOKIE["userid"]._DIR_MYDOCUMENT_."/".$Fetch;
+$FileName =_DIR_USER_DOC_."/".$_COOKIE["userid"]._DIR_MYDOCUMENT_."/".$Fetch;
 
 
 if($_COOKIE["uid"]){

+ 1 - 1
app/studio/editor.php

@@ -112,7 +112,7 @@ else{$currDevice="computer";}
 		
 		var g_device="computer";
 		var strSertch = location.search;
-		var gConfigDirMydocument="<?php echo _DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_; ?>/";
+		var gConfigDirMydocument="<?php echo _DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_; ?>/";
 		
 		if(strSertch.length>0){
 			strSertch = strSertch.substr(1);

+ 1 - 1
app/studio/file_index_refresh.php

@@ -3,7 +3,7 @@ include "../path.php";
 include "./_pdo.php";
 
 //获取服务器端文件列表
-$dir= _DIR_USER_BASE_.'/'.$_COOKIE["userid"].'/'._DIR_MYDOCUMENT_."/";
+$dir= _DIR_USER_DOC_.'/'.$_COOKIE["userid"].'/'._DIR_MYDOCUMENT_."/";
 
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 

+ 4 - 4
app/studio/project.php

@@ -408,7 +408,7 @@ switch($op){
 			
 			echo '<div class="pd-10"  style="max-width:2em;flex:1;">New Channal 新建频道</div>';
 			echo '<div class="title" style="flex:3;padding-bottom:5px;">';
-			echo '<input type="input" placeholder="Channal Title"></div>';
+			echo '在studio中新建版本风格</div>';
 			echo '<div class="author"  style="flex:1;padding-bottom:5px;"><button>New 新建</button></div>';
 			
 			echo '</div>';
@@ -435,7 +435,7 @@ switch($op){
 		$create_para=$paragraph;
 		
 		$FileName = $book."_".$paragraph."_".time().".pcs";
-		$sFullFileName=_DIR_USER_BASE_."/".$USER_ID._DIR_MYDOCUMENT_."/".$FileName;
+		$sFullFileName=_DIR_USER_DOC_."/".$USER_ID._DIR_MYDOCUMENT_."/".$FileName;
 		echo "filename:".$sFullFileName;
 		$myfile = fopen($sFullFileName, "w") or die("Unable to open file!");
 		
@@ -961,8 +961,8 @@ switch($op){
 							$query = "select userid from user where id='$owner'";
 							$FetchUid = PDO_FetchOne($query);
 							if($FetchUid){
-								$source=_DIR_USER_BASE_."/".$FetchUid._DIR_MYDOCUMENT_."/".$filename;
-								$dest=_DIR_USER_BASE_."/".$_COOKIE["userid"] ._DIR_MYDOCUMENT_."/".$filename;
+								$source=_DIR_USER_DOC_."/".$FetchUid._DIR_MYDOCUMENT_."/".$filename;
+								$dest=_DIR_USER_DOC_."/".$_COOKIE["userid"] ._DIR_MYDOCUMENT_."/".$filename;
 							}
 							echo "<div>源文件{$source}</div>";
 							echo "<div>目标文件{$dest}</div>";

+ 1 - 1
app/studio/project_load.php

@@ -7,7 +7,7 @@ require_once "../public/_pdo.php";
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 $query="select file_name from fileindex where user_id='{$_COOKIE["uid"]}' AND  id='{$_GET["id"]}'";
 $Fetch = PDO_FetchOne($query);
-$FileName =_DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_."/".$Fetch;
+$FileName =_DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_."/".$Fetch;
 if(file_exists($FileName)){
     echo file_get_contents($FileName);
 }

+ 2 - 2
app/ucenter/index.php

@@ -82,7 +82,7 @@ require_once "../public/function.php";
 				}
 				else{
 					//created user recorder 
-					$newUserPath=_DIR_USER_BASE_.'/'.$new_userid;
+					$newUserPath=_DIR_USER_DOC_.'/'.$new_userid;
 					$userDirMyDocument=$newUserPath._DIR_MYDOCUMENT_;
 					if(!file_exists($newUserPath)){
 						if(mkdir($newUserPath)){
@@ -132,7 +132,7 @@ require_once "../public/function.php";
 					if(isset($_COOKIE["url"])){
 						setcookie("pwd_set", "on", time()+60,"/");
 					}
-					$newUserPath=_DIR_USER_BASE_.'/'.$userid.'/';
+					$newUserPath=_DIR_USER_DOC_.'/'.$userid.'/';
 					if(!file_exists($newUserPath)){
 						echo "error:cannot find user dir:$newUserPath<br/>";
 					}

+ 1 - 1
app/ucenter/setting.php

@@ -24,7 +24,7 @@ require_once '../public/function.php';
 		
 		var g_device="computer";
 		var strSertch = location.search;
-		var gConfigDirMydocument="<?php echo _DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_; ?>/";
+		var gConfigDirMydocument="<?php echo _DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_; ?>/";
 		
 		if(strSertch.length>0){
 			strSertch = strSertch.substr(1);

+ 22 - 0
app/upgrade/pali_toc.sql

@@ -0,0 +1,22 @@
+--
+-- 由SQLiteStudio v3.1.1 产生的文件 周五 2月 12 16:26:34 2021
+--
+-- 文本编码:UTF-8
+--
+PRAGMA foreign_keys = off;
+BEGIN TRANSACTION;
+
+-- 表:course
+CREATE TABLE course (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lesson_id CHAR (36), start INTEGER, "end" INTEGER);
+
+-- 表:nissaya
+CREATE TABLE nissaya (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), media INTEGER);
+
+-- 表:progress
+CREATE TABLE progress (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), all_strlen INTEGER, public_strlen INTEGER);
+
+-- 表:progress_chapter
+CREATE TABLE progress_chapter (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), all_trans REAL, public REAL);
+
+COMMIT TRANSACTION;
+PRAGMA foreign_keys = on;

+ 1 - 2
app/upgrade/upgrade_pali_toc.php

@@ -46,7 +46,7 @@ $sth_toc->execute();
 
 /* 开始一个事务,关闭自动提交 */
 $dbh_toc->beginTransaction();
-$query = "INSERT INTO progress (book, para , lang , all_strlen,public_strlen) VALUES (?, ?, ? , ? ,? )";
+$query = "INSERT INTO progress (book, para , lang , all_strlen , public_strlen) VALUES (?, ?, ? , ? ,? )";
 $sth_toc = $dbh_toc->prepare($query);
 foreach ($result_lang as $lang) {
 	# 第二步 生成para progress 1,2,15,zh-tw
@@ -87,7 +87,6 @@ foreach ($result_lang as $lang) {
 			$sth_toc->execute(array($para["book"],$para["paragraph"],$lang["language"],$para_strlen,0));
 		}
 	}
-
 }
 $dbh_toc->commit();
 if (!$sth_toc || ($sth_toc && $sth_toc->errorCode() != 0)) {