visuddhinanda 3 лет назад
Родитель
Сommit
5657879efd

+ 7 - 2
public/app/nissaya/get.php

@@ -31,6 +31,11 @@ if (isset($_GET["end"])) {
 } else {
     $end = 0;
 }
+if (isset($_GET["nsyid"])) {
+    $nsyid = substr($_GET["nsyid"],1) ;
+} else {
+    $nsyid = '';
+}
 add_edit_event(_NISSAYA_FIND_, "{$book}-{$para}-{$begin}-{$end}");
 
 PDO_Connect("" . _FILE_DB_PAGE_INDEX_);
@@ -42,8 +47,8 @@ foreach ($Fetch as $key => $value) {
     $Fetch_nsy_book = PDO_FetchRow($query, array($value["book"], $value["page1"]));
     if ($Fetch_nsy_book) {
         $prefix = $Fetch_nsy_book["table"];
-        $query = "SELECT * from {$prefix}_pagematch where bookid=? and bookpagenumber=?";
-        $Fetch_nsy_index = PDO_FetchRow($query, array($Fetch_nsy_book["bookid"], $value["page2"]));
+        $query = "SELECT * from {$prefix}_pagematch where bookid=? and bookpagenumber=? and nsyid = ?";
+        $Fetch_nsy_index = PDO_FetchRow($query, array($Fetch_nsy_book["bookid"], $value["page2"],$nsyid ));
         $Fetch_nsy_index["dir"] = $prefix;
         $result["data"][] = $Fetch_nsy_index;
     } else {

+ 57 - 0
public/app/nissaya/get_book_list.php

@@ -0,0 +1,57 @@
+<?php
+require_once "../public/_pdo.php";
+require_once "../config.php";
+require_once "../ucenter/active.php";
+
+$result["error"] = "";
+$result["data"] = array();
+
+if (isset($_GET["book"])) {
+    $book = $_GET["book"];
+} else {
+    $result["error"] = "no param";
+    echo json_encode($result, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+if (isset($_GET["para"])) {
+    $para = $_GET["para"];
+} else {
+    $result["error"] = "no param";
+    echo json_encode($result, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
+if (isset($_GET["begin"])) {
+    $begin = $_GET["begin"];
+} else {
+    $begin = 0;
+}
+if (isset($_GET["end"])) {
+    $end = $_GET["end"];
+} else {
+    $end = 0;
+}
+add_edit_event(_NISSAYA_FIND_, "{$book}-{$para}-{$begin}-{$end}");
+
+PDO_Connect("" . _FILE_DB_PAGE_INDEX_);
+$query = "SELECT * from m where book=? and para=?";
+$Fetch = PDO_FetchRow($query, array($book, $para));
+    $query = "SELECT * from book_match where book_vri=? and vol=?";
+    $Fetch_nsy_book = PDO_FetchRow($query, array($Fetch["book"], $Fetch["page1"]));
+    if ($Fetch_nsy_book) {
+        $prefix = $Fetch_nsy_book["table"];
+		
+        $query = "select nsyid from {$prefix}_pagematch where bookid = ? and bookpagenumber = ? group by nsyid";
+        $Fetch_nsy_book = PDO_FetchAll($query, array($Fetch_nsy_book["bookid"],$Fetch["page2"]));
+		foreach ($Fetch_nsy_book as $key => $book) {
+			# code...
+			$query = "select nsyname from {$prefix}_pagematch where nsyid = ? ";
+			$Fetch_nsy_book[$key]['name'] = PDO_FetchRow($query, array($book["nsyid"]))['nsyname'];
+			$Fetch_nsy_book[$key]['type'] = $prefix;
+		}
+		$result["data"] =  json_encode($Fetch_nsy_book, JSON_UNESCAPED_UNICODE);
+        
+    } else {
+        $result["error"] = "error: in table book_match";
+    }
+echo json_encode($result, JSON_UNESCAPED_UNICODE);

+ 7 - 1
public/app/nissaya/index.php

@@ -23,6 +23,12 @@ if(isset($_GET["book"])){
 else{
 	$book = 0;
 }
+if(isset($_GET["nsyid"])){
+	$nsyid = $_GET["nsyid"];
+}
+else{
+	$nsyid = 0;
+}
 if(isset($_GET["par"])){
 	$para = $_GET["par"];
 }
@@ -44,7 +50,7 @@ else{
 ?>
 <script>
 $(document).ready(function () {
-	nissaya_get(<?php echo "{$book},{$para},{$begin},{$end}";?>);
+	nissaya_load(<?php echo "'{$nsyid}',{$book},{$para},{$begin},{$end}";?>);
 });
 </script>
 

+ 49 - 2
public/app/nissaya/nissaya.js

@@ -1,7 +1,46 @@
 var _nsy_book_dir = "";
 var _nsy_book_id = "";
 
-function nissaya_get(book, para, begin = 0, end = 0) {
+function nissaya_load(nsyid,book, para, begin = 0, end = 0){
+	if(nsyid==0){
+		nissaya_get_books(book, para);
+	}else{
+		nissaya_get(nsyid,book, para, begin, end );
+	}
+}
+function render_nissaya_books(list,book,para,begin=0,end=0){
+	let books = JSON.parse(list);
+	let html ="<ol>";
+	for (const iterator of books) {
+		html += "<li>";
+		html += "<a href='index.php?book="+book+"&par="+para+"&begin="+begin+"&end="+end+"&nsyid=a"+iterator.nsyid+"'>";
+		html +=  iterator.nsyid + "-" + iterator.name;
+		html += "</a>";
+		html += "</li>";
+	}
+	html += "</ol>";
+	return html;
+}
+function nissaya_get_books(book, para) {
+	$.get(
+		"../nissaya/get_book_list.php",
+		{
+			book: book,
+			para: para,
+		},
+		function (data) {
+			let result = JSON.parse(data);
+			if (result.error == "") {
+				if (result.data.length > 0) {
+					//找到的书的列表
+					$("#contence").html(render_nissaya_books(result.data,book,para));
+				}
+			}
+		}
+	);
+
+}
+function nissaya_get(nissayabook,book, para, begin = 0, end = 0) {
 	if (book == 0 || para == 0) {
 		return;
 	}
@@ -12,6 +51,7 @@ function nissaya_get(book, para, begin = 0, end = 0) {
 			para: para,
 			begin: begin,
 			end: end,
+			nsyid:nissayabook,
 		},
 		function (data) {
 			let result = JSON.parse(data);
@@ -29,7 +69,14 @@ function nissaya_get(book, para, begin = 0, end = 0) {
 }
 
 function render_on_page(params) {
-	let filename = params.dir + "/" + params.book + "_" + params.page + ".gif";
+	//加入前导零补足3位
+	let prefix='';
+	if(params.page < 10){
+		prefix='00';
+	}else if(params.page < 100){
+		prefix='0';
+	}
+	let filename = params.dir + "/" + params.book + "/" + prefix + params.page + ".png";
 	let html = "";
 
 	html += "<div class='img_box' dir='" + params.dir + "' book='" + params.book + "' page='" + params.page + "'>";