Quellcode durchsuchen

显示相关段落

visuddhinanda vor 5 Jahren
Ursprung
Commit
e8fd7dc4bd
7 geänderte Dateien mit 2483 neuen und 2400 gelöschten Zeilen
  1. 2388 2388
      app/admin/cs6_para.csv
  2. 4 4
      app/admin/db_update_cs6_para.php
  3. 1 1
      app/path.php
  4. 1 0
      app/pcdl/html_head.php
  5. 2 0
      app/term/note.js
  6. 62 0
      app/term/related_para.js
  7. 25 7
      app/term/related_para.php

Datei-Diff unterdrückt, da er zu groß ist
+ 2388 - 2388
app/admin/cs6_para.csv


+ 4 - 4
app/admin/db_update_cs6_para.php

@@ -2,11 +2,11 @@
 require_once "../public/_pdo.php";
 require_once "../path.php";
 
-$db_file = _FILE_DB_PALITEXT_;
-PDO_Connect("sqlite:$db_file");
+	$db_file = _FILE_DB_PALITEXT_;
+	PDO_Connect("sqlite:$db_file");
 
-$query = "select * from books where 1";
-$books = PDO_FetchAll($query);
+	$query = "select * from books where 1";
+	$books = PDO_FetchAll($query);
 
 
 	$db_file = _FILE_DB_PAGE_INDEX_;

+ 1 - 1
app/path.php

@@ -8,7 +8,7 @@ define("_DIR_PALICANON_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text
 define("_DIR_PALICANON_WBW_" , __DIR__."/../tmp/appdata/palicanon/wbw");
 define("_DIR_PALICANON_TRAN_" , __DIR__."/../tmp/appdata/palicanon/translate");
 
-//pali canon db file
+//pali canon db file 语料库
 define("_FILE_DB_RESRES_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/res.db3");
 define("_FILE_DB_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text.db3");
 define("_FILE_DB_STATISTICS_" , __DIR__."/../tmp/appdata/palicanon/word_statistics.db3");

+ 1 - 0
app/pcdl/html_head.php

@@ -66,6 +66,7 @@ else{
 	<script src="../usent/historay.js"></script>
 	<script src="../term/pali_sim_sent.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/pali_sim_dlg.css"/>
+	<script src="../term/related_para.js"></script>
 
 
 	<script src="../widget/click_dropdown.js"></script>

+ 2 - 0
app/term/note.js

@@ -37,6 +37,7 @@ function note_create() {
 	note_sent_edit_dlg_init();
 	term_edit_dlg_init();
 	pali_sim_dlg_init();
+	related_para_dlg_init();
 }
 function note_sent_edit_dlg_init() {
 	$("body").append(
@@ -431,6 +432,7 @@ function note_json_html(in_json) {
 	if (typeof _reader_view != "undefined" && _reader_view != "sent") {
 		output += "<a onclick='junp_to(this)'>跳转至此句</a>";
 	}
+	output += "<a  onclick='related_para_dlg_open(" + in_json.book + "," + in_json.para + ")'>相关段落</a>";
 	output += "<a  onclick='goto_nissaya(" + in_json.book + "," + in_json.para + ")'>Nissaya</a>";
 	output +=
 		"<a onclick=\"copy_ref('" +

+ 62 - 0
app/term/related_para.js

@@ -0,0 +1,62 @@
+function related_para_dlg_init(title = "Related") {
+	$("body").append(
+		'<div id="related_para_dlg" title="' + title + '"><div id="related_para_dlg_content"></div></div>'
+	);
+
+	$("#related_para_dlg").dialog({
+		autoOpen: false,
+		width: 550,
+		buttons: [
+			{
+				text: "Close",
+				click: function () {
+					$(this).dialog("close");
+				},
+			},
+		],
+	});
+}
+function related_para_dlg_open(book, para) {
+	$.get(
+		"../term/related_para.php",
+		{
+			book: book,
+			para: para,
+		},
+		function (data) {
+			let para = JSON.parse(data);
+			let html = related_para_dlg_render(para);
+			$("#related_para_dlg_content").html(html);
+			$("#related_para_dlg").dialog("open");
+		}
+	);
+}
+
+function related_para_dlg_render(para) {
+	let output = "";
+	for (const iterator of para.book_list) {
+		output += "<div>";
+		if (para.curr_book_id == iterator.id) {
+			output += "<b>" + iterator.title + "</b>";
+		} else {
+			//找到与这个书匹配的段落
+			let paraList = new Array();
+			for (const ipara of para.data) {
+				if (ipara.bookid == iterator.id) {
+					paraList.push(ipara);
+				}
+			}
+			output +=
+				"<a href='../reader/?view=para&book=" +
+				paraList[0].book +
+				"&para=" +
+				paraList[0].para +
+				"' target='_blank'>" +
+				iterator.title +
+				"</a>";
+		}
+		output += "</div>";
+	}
+
+	return output;
+}

+ 25 - 7
app/term/related_para.php

@@ -27,20 +27,38 @@ else{
 }
 
 	PDO_Connect("sqlite:"._FILE_DB_PAGE_INDEX_);
-	$query="select bookid,cspara ,book_name from cs6_para where book = ? and para=?";
+	$query="SELECT bookid,cspara ,book_name FROM cs6_para where book = ? and para= ? ";
 	$fetch = PDO_FetchAll($query,array($book,$para));
 	if(count($fetch)>0){
+		$aBookid=array();
 		$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"];
+		$query="SELECT book, para,bookid from cs6_para where book_name = ? and cspara in  ($place_holders)  ";
+		$param[] = $fetch[0]["book_name"];
 
 		foreach ($fetch as $key => $value) {
 			$param[] =$value["cspara"];
 		}
-		$param[] = $fetch[0]["book_name"];
-		$fetch = PDO_FetchAll($query,$param);
-		$result["data"]=$fetch;
+		$fetchAllPara = PDO_FetchAll($query,$param);
+		foreach ($fetchAllPara as  $bookid) {
+			$aBookid["{$bookid["bookid"]}"] = 1;
+		}
+		$result["data"]=$fetchAllPara;
+		$result["curr_book_id"]=$fetch[0]["bookid"];
+
+		//获取书名 列表
+		$book_list= array();
+		$db_file = _FILE_DB_PALITEXT_;
+		PDO_Connect("sqlite:$db_file");
+		
+		foreach ($aBookid as $bookkey => $bookvalue ) {
+			# code...
+			$query = "select * from books where id=".$bookkey;
+			$book_list[] = PDO_FetchRow($query);
+		}
+		$result["book_list"]=$book_list;
+
 	}
-echo json_encode($result, JSON_UNESCAPED_UNICODE);
+
+	echo json_encode($result, JSON_UNESCAPED_UNICODE);
 
 ?>

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.