Browse Source

Merge pull request #226 from visuddhinanda/master

pali text 显示和隐藏
visuddhinanda 5 years ago
parent
commit
4f6a172def

+ 24 - 0
app/admin/cs6_para.csv

@@ -0,0 +1,24 @@
+book,para,book1,begin,end
+86,317,an3,39,39
+86,318,an3,39,39
+86,319,an3,39,41
+86,320,an3,39,39
+86,321,an3,39,39
+86,322,an3,39,39
+86,323,an3,39,39
+86,324,an3,39,39
+86,325,an3,39,39
+86,326,an3,39,39
+86,327,an3,39,39
+86,328,an3,40,40
+86,329,an3,40,40
+86,330,an3,40,40
+86,331,an3,40,40
+86,332,an3,40,40
+86,333,an3,40,40
+86,334,an3,40,40
+86,335,an3,40,40
+86,336,an3,40,40
+86,337,an3,40,40
+86,338,an3,40,40
+86,339,an3,40,40

+ 12 - 104
app/admin/db_update_cs6_para.php

@@ -2,124 +2,39 @@
 require_once "../public/_pdo.php";
 require_once "../path.php";
 
-if (PHP_SAPI  == "cli") {
-	echo $argc;
-	if($argc>=3){
-		$from=$argv[1];
-		$to=$argv[2];
-		echo "From: {$from} To:{$to}";
-	}
-	else if($argc>=1){
-		$from=0;
-		$to = 216;
-		echo "生成全部217本书";
-	}
-	else{
-		echo "参数错误";
-		exit;
-	}
-
-}
-else{
-
-}
-
-
-$g_wordCounter=0;
-$g_wordIndexCounter=0;
-$iAllWordIndex=array();
-$sAllWord=array();
-
-$dirLog=_DIR_LOG_."/";
-
-$dirXmlBase=_DIR_PALI_CSV_."/";
-
-$filelist=array();
-$fileNums=0;
-$log="";
-echo " $from \n";
-
-
-if(($handle=fopen("filelist.csv",'r'))!==FALSE){
-	while(($filelist[$fileNums]=fgetcsv($handle,0,','))!==FALSE){
-		$fileNums++;
-	}
-}
-if($to==0 || $to>=$fileNums) $to=$fileNums-1;
 
 	$db_file = _FILE_DB_PAGE_INDEX_;
 	PDO_Connect("sqlite:$db_file");
-for($iFile=$from;$iFile<=$to;$iFile++){
-    echo "{$iFile}\n";
-	$FileName=$filelist[$iFile][1].".htm";
-	$fileId=$filelist[$iFile][0];
-
-	$inputFileName=$FileName;
-	$outputFileNameHead=$filelist[$iFile][1];
-	$bookId=$filelist[$iFile][2];
-
-	$dirXml=$outputFileNameHead."/";
-
-	$xmlfile = $inputFileName;
-	echo "doing:".$xmlfile."\n";
-	$log=$log."$iFile,$FileName,open\r\n";
-
-	$arrInserString=array();
-
 
 	// 打开文件并读取数据
 	$irow=0;
-	if(($fp=fopen($dirXmlBase.$dirXml.$outputFileNameHead.".csv", "r"))!==FALSE){
+	if(($fp=fopen("cs6_para.csv", "r"))!==FALSE){
 		// 开始一个事务,关闭自动提交
 		$PDO->beginTransaction();
 		$query="INSERT INTO cs6_para ('book','para','bookid','cspara') VALUES (  ? , ? , ? , ? )";
 		$stmt = $PDO->prepare($query);
 
-		$currCSPara=0;
-		$currPara = 0;
-		$iCount = 0;
-
-
 		// 提交更改 
 		try{
 			while(($data=fgetcsv($fp,0,','))!==FALSE){
 				$irow++;
 				if($irow>1){
-					if($data[6]==".ctl." && mb_substr($data[5],0,4,"UTF-8")=="para"){
-						$currCSPara= (int)mb_substr($data[5],4,NULL,"UTF-8");
+					if($data[3]==$data[4]){
+						$stmt->execute(array($data[0],$data[1],$data[2],$data[3]));
 					}
-					$para = $data[3];
-					$arr = explode("-",$currCSPara);
-					if($currPara != $data[3] && $data[6] != ".ctl."){
-						$currPara=(int)$data[3];
-						$book = mb_substr($data[2],1, null ,"UTF-8");
-						$para = $currPara;
-						$csPara = $currCSPara;
-						$book2 = 0;
-						if(count($arr)>1){
-							$iBegin = (int)$arr[0];
-							$iEnd = (int)$arr[1];
-							
-						}
-						else{
-							$iBegin = (int)$arr[0];
-							$iEnd = (int)$arr[0];						
-						}
-						if($iEnd<$iBegin){
-							$iEnd =(int)(mb_substr($arr[0],0,0-mb_strlen($arr[1])).$arr[1]);
-						}
+					else{
+						$begin = (int)$data[3];
+						$end = (int)$data[4];
 						$arr1=array();
-						for($i=$iBegin; $i<=$iEnd; $i++){
+						for($i=$begin; $i<=$end; $i++){
 							$arr1[] = $i;
 						}
 						foreach ($arr1 as $key => $value) {
-							$stmt->execute(array($book,$para,$book2,$value));
-							$iCount++;
-						}
-						
+							$stmt->execute(array($data[0],$data[1],$data[2],$value));
+						}						
 					}
+
 				}
-					
 			}
 			$PDO->commit();
 		}catch (Exception $e){
@@ -130,25 +45,18 @@ for($iFile=$from;$iFile<=$to;$iFile++){
 		if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
 			$error = PDO_ErrorInfo();
 			echo "error - $error[2] \n";
-			$log.="$from, $FileName, error, $error[2] \r\n";
 		}
 		else{
 			echo "updata  recorders.\n";
-			$log.="updata  recorders.\r\n";
 		}			
 
 		fclose($fp);
-		echo "单词表load:".$dirXmlBase.$dirXml.$outputFileNameHead.".csv\n";
 	}
 	else{
 		echo "can not open csv file. filename=".$dirXmlBase.$dirXml.$outputFileNameHead.".csv";
 	}
 	
-}
-	echo "齐活!功德无量!all done!";	
-?>
 
 
-
-</body>
-</html>
+	echo "齐活!功德无量!all done!";	
+?>

+ 18 - 15
app/dict/index.php

@@ -46,22 +46,25 @@ require_once "../pcdl/html_head.php";
 			flex:2;
         }
 		.dict_word_card{
-		border-bottom: 1px solid var(--border-line-color);
-    	padding: 5px 0;			
-		display: block;
-		border-radius: unset;
-		margin: 10px 0;
-		transition: unset;
-		box-shadow: unset;
+			border-bottom: 1px solid var(--border-line-color);
+			padding: 5px 0;			
+			display: block;
+			border-radius: unset;
+			margin: 10px 0;
+			transition: unset;
+			box-shadow: unset;
 		}
 		.dict_word{
-		border-bottom: 1px solid var(--border-line-color);
-    	padding: 5px 0;			
-		display: block;
-		border-radius: unset;
-		margin: 10px 0;
-		transition: unset;
-		box-shadow: unset;
+			border-left: none;
+			border-right: none;
+			border-top: none;
+			border-bottom: 1px solid var(--border-line-color);
+			padding: 5px 0;			
+			display: block;
+			border-radius: unset;
+			margin: 10px 0;
+			transition: unset;
+			box-shadow: unset;
 		}
 		.dict_word>.dict {
 			font-size: 110%;
@@ -93,7 +96,7 @@ require_once "../pcdl/html_head.php";
             display:none;
         }
         .dropdown_ctl>.menu{
-		background-color: white;
+			background-color: white;
         }
         .dropdown_ctl>.content>.main_view>part{
             margin:0 0.5em;

+ 0 - 3
app/install/db_insert_page_index.php

@@ -61,8 +61,6 @@ if(($handle=fopen("filelist.csv",'r'))!==FALSE){
 	}
 }
 if($to==0 || $to>=$fileNums) $to=$fileNums-1;
-
-
 	
 for($iFile=$from;$iFile<=$to;$iFile++){
     echo "<h3>{$iFile}</h3>";
@@ -96,7 +94,6 @@ for($iFile=$from;$iFile<=$to;$iFile++){
 		while(($data=fgetcsv($fp,0,','))!==FALSE){
 			$irow++;
 			if($irow>1){
-
 				if($data[6]==".ctl." && mb_substr($data[5],0,1,"UTF-8")=="M"){
 					$sPage= mb_substr($data[5],1,6,"UTF-8");
 					$aPage = explode(".",$sPage);

+ 1 - 0
app/reader/index.php

@@ -247,6 +247,7 @@ require_once "../pcdl/html_head.php";
 
 	<div>
 		<span>
+		<input type="checkbox" onchange="setVisibility('palitext',this)" checked>Pali Text Visible
 		<?php
 		echo "<button class='icon_btn'  title='{$_local->gui->modify} {$_local->gui->composition_structure}'>";
 		echo "<a href='";

+ 16 - 0
app/term/note.js

@@ -893,3 +893,19 @@ function tool_bar_show(element) {
 		$(element).css("visibility", "");
 	}
 }
+
+function setVisibility(key, value) {
+	switch (key) {
+		case "palitext":
+			if ($(value).is(":checked")) {
+				$(".palitext").show();
+			} else {
+				$(".palitext").hide();
+			}
+
+			break;
+
+		default:
+			break;
+	}
+}

+ 42 - 0
app/term/related_para.php

@@ -0,0 +1,42 @@
+<?php
+require_once "../public/_pdo.php";
+require_once "../path.php";
+
+$result["error"]="";
+$result["data"]=array();
+
+if(isset($_GET["book"])){
+	$book = $_GET["book"];
+}
+else{
+	$result["error"]="no param:book";
+	echo json_encode($result, JSON_UNESCAPED_UNICODE);
+	exit;
+}
+if(isset($_GET["para"])){
+	$para = $_GET["para"];
+}
+else{
+	$result["error"]="no param :para";
+	echo json_encode($result, JSON_UNESCAPED_UNICODE);
+	exit;
+}
+
+	PDO_Connect("sqlite:"._FILE_DB_PAGE_INDEX_);
+	$query="select bookid,cspara ,book_name from cs6_para where book = ? and para=?";
+	$fetch = PDO_FetchAll($query,array($book,$para));
+	if(count($fetch)>0){
+		$place_holders = implode(',', array_fill(0, count($fetch), '?'));
+		$query="SELECT book, para from cs6_para where bookid = ? and cspara in  ($place_holders) and book_name <> ?  ";
+		$param[] = $fetch[0]["bookid"];
+
+		foreach ($fetch as $key => $value) {
+			$param[] =$value["cspara"];
+		}		
+		$param[] = $fetch[0]["book_name"];
+		$fetch = PDO_FetchAll($query,$param);
+		$result["data"]=$fetch;
+	}
+echo json_encode($result, JSON_UNESCAPED_UNICODE);
+
+?>