瀏覽代碼

阅读器回车存盘

visuddhinanda 5 年之前
父節點
當前提交
fd38a009dc

+ 29 - 22
app/channal/function.php

@@ -1,29 +1,12 @@
 <?php
 require_once "../path.php";
 require_once "../share/function.php";
+require_once "../db/table.php";
 
-function channel_get_title($id)
+class Channal extends Table
 {
-    if (isset($id)) {
-		PDO_Connect( _FILE_DB_CHANNAL_);
-		$query = "SELECT name FROM channal  WHERE id = ? ";
-		$channel = PDO_FetchRow($query, array($id));
-		if ($channel) {
-			return $channel["name"];
-		} else {
-			return "";
-		}
-    } else {
-        return "";
-    }
-}
-
-class Channal
-{
-    private $dbh;
-    public function __construct() {
-        $this->dbh = new PDO(_FILE_DB_CHANNAL_, "", "",array(PDO::ATTR_PERSISTENT=>true));
-        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+    function __construct($redis=false) {
+		parent::__construct(_FILE_DB_CHANNAL_, "channal", "", "",$redis);
     }
 
     public function getChannal($id){
@@ -53,10 +36,30 @@ class Channal
 		} else {
 			return "";
 		}
+	}
+	public function insert($data){
+
+	}
+	public function update($data){
+
+	}
+	public function delete($data){
+
 	}
 	public function getPower($id){
 		#查询用户对此channel是否有权限		
-
+		if(isset($_COOKIE["userid"])){
+			$userId = $_COOKIE["userid"];
+		}
+		else{
+			$userId='0';
+		}
+		if($this->redis!==false){
+			$power = $this->redis->hGet("power://channel/".$id,$userId);
+			if($power!==FALSE){
+				return $power;
+			}
+		}
 		$channelPower = 0;
 		$query = "SELECT owner,status FROM channal WHERE id=? and status>0 ";
 		$stmt = $this->dbh->prepare($query);
@@ -88,6 +91,10 @@ class Channal
 		if($sharePower>$channelPower){
 			$channelPower=$sharePower;
 		}
+		if($this->redis){
+			$this->redis->hSet("power://channel/".$id,$_COOKIE["userid"],$channelPower);
+		}
+		
 		return $channelPower;
 	}
 

+ 13 - 20
app/channal/my_channal_post.php

@@ -2,31 +2,18 @@
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
+require_once '../channal/function.php';
+require_once '../redis/function.php';
 require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 
 #先查询对此channal是否有权限修改
-   PDO_Connect(""._FILE_DB_CHANNAL_);
+PDO_Connect(_FILE_DB_CHANNAL_);
 $cooperation = 0;
 if(isset($_POST["id"])){
-    $query = "SELECT owner FROM channal WHERE id=?";
-    $fetch = PDO_FetchOne($query,array($_POST["id"]));
-    if($fetch && $fetch==$_COOKIE["userid"]){
-        #自己的channal
-        $cooperation = 1;
-    }
-    else{
-        $query = "SELECT count(*) FROM cooperation WHERE channal_id= ? and user_id=? ";
-        $fetch = PDO_FetchOne($query,array($_POST["id"],$_COOKIE["userid"]));
-        if($fetch>0){
-            #有协作权限
-            $cooperation = 1;
-        }
-        else{
-            #无协作权限
-            $cooperation = 0;
-        }
-    }
+	$redis = redis_connect();
+	$channel = new Channal($redis);
+	$channelPower = $channel->getPower($_POST["id"]);
 }
 else{
     $respond["status"] = 1;
@@ -34,13 +21,14 @@ else{
     echo json_encode($respond, JSON_UNESCAPED_UNICODE);
     exit;
 }
-if($cooperation==0){
+if($channelPower<30){
     $respond["status"] = 1;
     $respond["message"] = 'error 无修改权限';
     echo json_encode($respond, JSON_UNESCAPED_UNICODE);
     exit;
 }
 
+$channelOldInfo = $channel->getChannal($_POST["id"]);
 
 $query="UPDATE channal SET name = ? ,  summary = ?,  status = ? , lang = ? , receive_time= ?  , modify_time= ?   where  id = ?  ";
 $sth = $PDO->prepare($query);
@@ -52,6 +40,11 @@ if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$respond['message']=$error[2];
 }
 else{
+	if($redis){
+		if($channelOldInfo["status"]!=$_POST["status"]){
+			$redis->del("power://channel/".$_POST["id"]);
+		}
+	}
     // 设置 句子库和逐词译库可见性
     PDO_Connect(""._FILE_DB_SENTENCE_);
     $query="UPDATE sentence SET language = ?  , status = ? where  channal = ?  ";

+ 2 - 1
app/channal/my_channal_put.php

@@ -1,11 +1,12 @@
 <?php
+#新建channel
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 $respond=array("status"=>0,"message"=>"");
 if(isset($_COOKIE["userid"])){
-	PDO_Connect(""._FILE_DB_CHANNAL_);
+	PDO_Connect(_FILE_DB_CHANNAL_);
 	$query="INSERT INTO channal ( id,  owner  , name  , summary ,  status  , lang, create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ?  ) ";
 	$sth = $PDO->prepare($query);
 	$sth->execute(array(UUID::v4() , $_COOKIE["userid"] , $_POST["name"] , "" , $_POST["status"] ,$_POST["lang"]  ,  mTime() ,  mTime() , mTime() ));

+ 16 - 0
app/db/table.php

@@ -0,0 +1,16 @@
+<?php
+class Table
+{
+    protected $dbh;
+	protected $table;
+    protected $redis;
+    function __construct($db,$table,$user="",$password="",$redis=false) {
+        $this->dbh = new PDO($db, $user, $password,array(PDO::ATTR_PERSISTENT=>true));
+        $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+		$this->redis = $redis;
+		$this->table = $table;
+
+    }
+}
+
+?>

+ 93 - 0
app/pali_text/function.php

@@ -0,0 +1,93 @@
+<?php
+require_once "../path.php";
+require_once "../db/table.php";
+
+class PaliText extends Table
+{
+    function __construct($redis=false) {
+		parent::__construct(_FILE_DB_PALITEXT_, "pali_text", "", "",$redis);
+    }
+	
+	public function getPath($book,$para){
+		if($this->redis!==false){
+			$path = $this->redis->hGet("pali_text://path",$book."-".$para);
+			if($path!==FALSE){
+				return json_decode($path,true);
+			}
+		}
+		$path = array();
+		$parent = $para;
+		$deep = 0;
+		$sFirstParentTitle = "";
+		//循环查找父标题 得到整条路径
+		while ($parent > -1) {
+			$query = "select * from pali_text where \"book\" = ? and \"paragraph\" = ? limit 0,1";
+			$stmt = $this->dbh->prepare($query);
+			$stmt->execute(array($book, $parent));
+			$FetParent = $stmt->fetch(PDO::FETCH_ASSOC);
+
+			$toc =array("book"=>$book,"para"=>$parent,"level"=>$FetParent["level"],"title"=>$FetParent["toc"]);
+
+			$path[] = $toc;
+
+			$parent = $FetParent["parent"];
+			$deep++;
+			if ($deep > 5) {
+				break;
+			}
+		}
+		if($this->redis){
+			$this->redis->hSet("pali_text://path",$book."-".$para,json_encode($path,JSON_UNESCAPED_UNICODE));
+		}
+		return ($path);
+	}
+
+	public function getPathHtml($arrPath){
+		$path="";
+		foreach ($arrPath as $key => $value) {
+			# code...
+			$toc = "<chapter book='{$value["book"]}' para='{$value["para"]}' title='{$value["title"]}'>{$value["title"]}</chapter>";
+			if ($path == "") {
+				if ($value["level"] < 100) {
+					$path = $toc;
+				} else {
+					$path = "<para book='{$value["book"]}' para='{$value["para"]}' title='{$value["title"]}'>{$value["para"]}</para>";
+				}
+			} else {
+				$path = $toc . $path;
+			}
+		}
+		return $path;
+	}
+}
+
+class PaliBook extends Table
+{
+    function __construct($redis=false) {
+		parent::__construct(_FILE_DB_PALITEXT_, "books", "", "",$redis);
+    }
+	
+	public function getBookTitle($book,$para){
+		if($this->redis!==false){
+			$result = $this->redis->hGet("pali_text://book",$book."-".$para);
+			if($result!==FALSE){
+				return $result;
+			}
+		}
+		$query = "select title from books where \"book\" = ? and \"paragraph\" = ? limit 0,1";
+		$stmt = $this->dbh->prepare($query);
+		$stmt->execute(array($book, $para));
+		$book = $stmt->fetch(PDO::FETCH_ASSOC);
+		if($book){
+			if($this->redis){
+				$this->redis->hSet("pali_text://book",$book."-".$para,$book["title"]);
+			}			
+			return $book["title"];
+		}
+		else{
+			return false;
+		}
+	}
+}
+
+?>

+ 5 - 5
app/reader/reader.js

@@ -9,7 +9,7 @@ var _author = "";
 var _display = "para";
 var arrMyTerm = new Array();
 var _sent_data = new Array();
-var link_str="";
+var link_str = "";
 
 palicanon_load_term();
 
@@ -31,11 +31,11 @@ function reader_load() {
 			if (_sent_data.sentences.length > 0) {
 				for (const iterator of _sent_data.sentences) {
 					if (currPara != iterator.paragraph) {
-						tpl += "\n";
+						tpl += "\n\n";
 						currPara = iterator.paragraph;
 						tpl += "```para\n";
 						tpl += currPara + "\n";
-						tpl += "```\n";
+						tpl += "```\n\n";
 					}
 					tpl +=
 						"{{" +
@@ -48,7 +48,7 @@ function reader_load() {
 						iterator.end +
 						"}}\n";
 				}
-				link_str=tpl;
+				link_str = tpl;
 				$("#contents").html(note_init(tpl));
 				note_refresh_new();
 				reader_draw_para_menu();
@@ -206,7 +206,7 @@ function reader_get_path() {
 			});
 			var bookTitle = $("chapter").first().html();
 			let suttaTitle = $("chapter").last().html();
-			
+
 			$("#pali_pedia").html(bookTitle);
 			$("#article_title").html(suttaTitle);
 			$("#page_title").text(suttaTitle);

+ 169 - 81
app/term/note.js

@@ -69,13 +69,14 @@ function note_sent_edit_dlg_init() {
 }
 function note_init(input) {
 	if (input) {
-		let newString = input.replace(/\{\{/g, '<div class="note_shell"><note info="');
-		newString = newString.replace(/\}\}/g, '" ></note></div>');
-
 		let output = "<div>";
-		output += marked(newString);
+		output += marked(input);
 		output += "</div>";
-		return output;
+
+		let newString = output.replace(/\{\{/g, '<span class="note_shell"><note info="');
+		newString = newString.replace(/\}\}/g, '" ></note></span>');
+
+		return newString;
 	} else {
 		return "";
 	}
@@ -155,70 +156,11 @@ function note_refresh_new() {
 							let id = iterator.id;
 							let strHtml = "<a name='" + id + "'></a>";
 							if (_display && _display == "para") {
-								//段落模式
-								let strPalitext =
-									"<pali book='" +
-									iterator.book +
-									"' para='" +
-									iterator.para +
-									"' begin='" +
-									iterator.begin +
-									"' end='" +
-									iterator.end +
-									"' >" +
-									iterator.palitext +
-									"</pali>";
-								let divPali = $("#" + id)
-									.parent()
-									.children(".palitext");
-								if (divPali.length == 0) {
-									if (_channal != "") {
-										let arrChannal = _channal.split(",");
-										for (let index = arrChannal.length - 1; index >= 0; index--) {
-											const iChannal = arrChannal[index];
-											$("#" + id)
-												.parent()
-												.prepend("<div class='tran_div'  channal='" + iChannal + "'></div>");
-										}
-									}
-
-									$("#" + id)
-										.parent()
-										.prepend("<div class='palitext'></div>");
-								}
-								$("#" + id)
-									.parent()
-									.children(".palitext")
-									.first()
-									.append(strPalitext);
-								let htmlTran = "";
-								for (const oneTran of iterator.translation) {
-									let html =
-										"<span class='tran' lang='" +
-										oneTran.lang +
-										"' channal='" +
-										oneTran.channal +
-										"'>";
-									html += marked(
-										term_std_str_to_tran(
-											oneTran.text,
-											oneTran.channal,
-											oneTran.editor,
-											oneTran.lang
-										)
-									);
-									html += "</span>";
-									if (_channal == "") {
-										htmlTran += html;
-									} else {
-										$("#" + id)
-											.siblings(".tran_div[channal='" + oneTran.channal + "']")
-											.append(html);
-									}
-								}
-								$("#" + id).html(htmlTran);
+								//阅读模式
+								strHtml += render_read_mode_sent(iterator);
+								$("#" + id).html(strHtml);
 							} else {
-								//句子模式
+								//编辑模式
 								strHtml += note_json_html(iterator);
 								$("#" + id).html(strHtml);
 							}
@@ -240,6 +182,8 @@ function note_refresh_new() {
 						refresh_pali_script();
 						//把巴利语单词用<w>分隔用于点词查询等
 						splite_pali_word();
+						//处理编辑框消息
+						tran_sent_textarea_event_init();
 					} catch (e) {
 						console.error(e);
 					}
@@ -251,6 +195,63 @@ function note_refresh_new() {
 	}
 }
 
+//渲染阅读模式句子
+function render_read_mode_sent(iterator) {
+	let id = iterator.id;
+	let strPalitext =
+		"<pali book='" +
+		iterator.book +
+		"' para='" +
+		iterator.para +
+		"' begin='" +
+		iterator.begin +
+		"' end='" +
+		iterator.end +
+		"' >" +
+		iterator.palitext +
+		"</pali>";
+	let divPali = $("#" + id)
+		.parent()
+		.parent()
+		.children(".palitext");
+	if (divPali.length == 0) {
+		if (_channal != "") {
+			let arrChannal = _channal.split(",");
+			for (let index = arrChannal.length - 1; index >= 0; index--) {
+				const iChannal = arrChannal[index];
+				$("#" + id)
+					.parent()
+					.parent()
+					.prepend("<div class='tran_div'  channal='" + iChannal + "'></div>");
+			}
+		}
+
+		$("#" + id)
+			.parent()
+			.parent()
+			.prepend("<div class='palitext'></div>");
+	}
+	$("#" + id)
+		.parent()
+		.parent()
+		.children(".palitext")
+		.first()
+		.append(strPalitext);
+	let htmlTran = "";
+	for (const oneTran of iterator.translation) {
+		let html = "<span class='tran' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
+		html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang));
+		html += "</span>";
+		if (_channal == "") {
+			htmlTran += html;
+		} else {
+			$("#" + id)
+				.siblings(".tran_div[channal='" + oneTran.channal + "']")
+				.append(html);
+		}
+	}
+	return htmlTran;
+}
 //生成channel列表
 function note_channal_list() {
 	console.log("note_channal_list start");
@@ -461,6 +462,7 @@ function note_ref_init() {
 	});
 }
 /*
+生成编辑模式句子块
 id
 palitext
 tran
@@ -528,18 +530,19 @@ function note_json_html(in_json) {
 	output += "</div>";
 	output += " </div>";
 
+	output += "<div class='pali_div'>";
 	output += "<div class='palitext palitext_roma'>" + in_json.palitext + "</div>";
 	output += "<div class='palitext palitext1'></div>";
 	output += "<div class='palitext palitext2'></div>";
+	output += "</div>";
 
-	//output += "<div id='translation_div'>";
+	output += "<div class='translation_div'>";
 	for (const iterator of in_json.translation) {
 		output += render_one_sent_tran_a(iterator);
-		//output += render_one_sent_tran(in_json.book, in_json.para, in_json.begin, in_json.end, iterator);
 	}
 	//所选全部译文结束
-	//output += "</div>";
-	//未选择的其他译文开始
+	output += "</div>";
+	//工具栏开始
 	output += "<div class='other_tran_div' sent='";
 	output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end + "' >";
 	output += "<div class='tool_bar' sent='";
@@ -607,10 +610,16 @@ function note_json_html(in_json) {
 
 	output += "<span class='tool_right'>";
 	//出处路径开始
-	output += "<span class='ref'>" + in_json.ref;
+	output += "<span class='ref'>";
+	output += "<span class='book_name tooltip'>" + in_json.booktitle;
+	output += "<span class='tooltiptext tooltip-bottom'>";
+	output += in_json.ref;
+	output += "</span>";
 	output += "<span class='sent_no'>";
 	output += in_json.book + "-" + in_json.para + "-" + in_json.begin + "-" + in_json.end;
 	output += "<span>";
+	output += "</span>";
+
 	output += "</span>";
 	//出处路径结束
 	output += "</span>";
@@ -626,6 +635,22 @@ function note_json_html(in_json) {
 
 	return output;
 }
+
+//设置取消输入框的编辑模式
+function sent_tran_set_edit_mode(obj, isEditMode) {
+	$(".sent_tran").removeClass("edit_mode");
+	if (isEditMode) {
+		let jqObj = $(obj);
+		while (!jqObj.hasClass("sent_tran")) {
+			jqObj = jqObj.parent();
+			if (!jqObj) {
+				return;
+			}
+		}
+		jqObj.addClass("edit_mode");
+	}
+}
+
 function sent_tran_edit(obj) {
 	let jqObj = $(obj);
 	while (!jqObj.hasClass("sent_tran")) {
@@ -868,22 +893,25 @@ function render_one_sent_tran_a(iterator) {
 
 	html += '<div class="edit">';
 	html += '<div class="input">';
-	html += "<textarea dbid='" + iterator.id + "' ";
+	html += "<textarea class='tran_sent_textarea' dbid='" + iterator.id + "' ";
 	html += "sid='" + sid + "' ";
 	html += "channel='" + iterator.channal + "' ";
 	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
-		html += 'onchange="note_pr_save(this)"';
+		html += ' is_pr="true" onchange1="note_pr_save(this)"';
 	} else {
-		html += 'onchange="note_sent_save_a(this)"';
+		html += 'is_pr="false" onchange1="note_sent_save_a(this)"';
 	}
 
 	html += ">" + iterator.text + "</textarea>";
 	html += "</div>";
 	html += '<div class="edit_tool">';
 	if (parseInt(iterator.mypower) < 20) {
-		html += "<b>提交修改建议</b> ";
+		html += "提交<b>修改建议</b> ";
 	}
-	html += "点击输入框外面自动<a onclick='sent_tran_edit(this)'>" + gLocal.gui.save + "</a> 支持markdown语法";
+	html +=
+		"按Esc <a onclick='tran_sent_edit_cancel(this)'>取消</a> 按回车<a onclick='tran_sent_save(this)'>" +
+		gLocal.gui.save +
+		"</a> 按shift+回车换行 支持markdown语法";
 	html += "</div>";
 	html += "</div>";
 
@@ -940,6 +968,39 @@ function render_one_sent_tran_a(iterator) {
 	return html;
 }
 
+function tran_sent_textarea_event_init() {
+	let textarea = document.querySelectorAll(".tran_sent_textarea");
+	for (let iterator of textarea) {
+		iterator.onkeydown = function (e) {
+			let menu = document.querySelector("#menu");
+			switch (e.key) {
+				case "Enter":
+					if (menu && menu.style.display == "block") {
+						let value = textarea.value;
+						let selectionStart = textarea.selectionStart;
+						let str1 = value.slice(0, selectionStart);
+						let str2 = value.slice(selectionStart);
+						textarea.value = str1 + data[menuFocusIndex] + "]]" + str2;
+						menu.style.display = "none";
+						return false;
+					} else {
+						if (!e.shiftKey) {
+							//回车存盘
+							tran_sent_save(e.currentTarget);
+							return false;
+						}
+					}
+					break;
+				case "Escape":
+					tran_sent_edit_cancel(e.currentTarget);
+					break;
+				default:
+					break;
+			}
+		};
+	}
+}
+
 function render_one_sent_tran(book, para, begin, end, iterator) {
 	let output = "";
 	output += "<div class='tran' lang='" + iterator.lang + "' style='display:flex;'>";
@@ -1164,7 +1225,6 @@ function set_more_button_display() {
 								for (const iterator of arrSent) {
 									if (_channal.indexOf(iterator.channal) == -1) {
 										html += render_one_sent_tran_a(iterator);
-										//html += "<div>" + marked(iterator.text) + "</div>";
 									}
 								}
 								html += "</div>";
@@ -1237,7 +1297,25 @@ function note_edit_sentence(book, para, begin, end, channal) {
 
 	alert("未找到句子");
 }
-function update_note_sent_tran(obj) {}
+function tran_sent_edit_cancel(obj) {
+	sent_tran_set_edit_mode(obj, false);
+}
+function tran_sent_save(obj) {
+	let sentDiv = find_sent_tran_div(obj);
+	if (sentDiv) {
+		let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
+		let isPr = $(textarea).attr("is_pr");
+		if (isPr == "true") {
+			note_pr_save(textarea);
+		} else {
+			note_sent_save_a(textarea);
+		}
+		sent_tran_set_edit_mode(textarea, false);
+	} else {
+		console.error("sent div not found");
+	}
+}
+
 //保存pr句子 新
 function note_pr_save(obj) {
 	let id = $(obj).attr("dbid");
@@ -1298,7 +1376,7 @@ function note_sent_save_a(obj) {
 		$(sent_tran_div).find(".preview").addClass("loading");
 	}
 }
-
+function update_sent_tran(sentData) {}
 function sent_save_callback(data) {
 	let result = JSON.parse(data);
 	if (result.status > 0) {
@@ -1539,6 +1617,15 @@ function slider_show(obj) {
 }
 
 function find_sent_tran_div(obj) {
+	let jqObj = $(obj);
+	while (!jqObj.hasClass("sent_tran")) {
+		jqObj = jqObj.parent();
+		if (!jqObj) {
+			return false;
+		}
+	}
+	return jqObj;
+	/*
 	let parent = obj.parentNode;
 	while (parent.nodeType == 1) {
 		if ($(parent).hasClass("sent_tran")) {
@@ -1550,6 +1637,7 @@ function find_sent_tran_div(obj) {
 	}
 
 	return false;
+	*/
 }
 //显示或隐藏pr数据
 function note_pr_show(channel, id) {

+ 19 - 8
app/term/note.php

@@ -5,6 +5,7 @@ require_once "../public/function.php";
 require_once "../channal/function.php";
 require_once "../ucenter/function.php";
 require_once "../usent/function.php";
+require_once "../pali_text/function.php";
 require_once "../redis/function.php";
 
 $redis = redis_connect();
@@ -12,6 +13,8 @@ $redis = redis_connect();
 $_channal = new Channal();
 $_userinfo = new UserInfo();
 $_sentPr = new SentPr($redis);
+$_pali_text = new PaliText($redis);
+$_pali_book = new PaliBook($redis);
 
 $_data = array();
 if (isset($_POST["data"])) {
@@ -136,10 +139,6 @@ foreach ($_data as $key => $value) {
 				$pali_sim = $row["count"]; //explode(",",$row["sim_sents"]) ;
 			}		
     }
-
-
-    
-
     //find out translation 查询译文
 
     $tran = "";
@@ -162,7 +161,7 @@ foreach ($_data as $key => $value) {
         if (empty($_setting["channal"])) {
 			#没有指定channel
             if ($sentChannal == "") {
-				#句子信息也没指定channel
+				#句子信息也没指定channel 查找默认译文
                 $parm = array($bookId, $para, $begin, $end);
                 $parm = array_merge_recursive($parm, $channal_list);
                 $stmt->execute($parm);
@@ -262,7 +261,7 @@ foreach ($_data as $key => $value) {
     }
     foreach ($translation as $key => $value) {
         # code...
-        if ($value["channal"]) {
+        if (!empty($value["channal"])) {
             $translation[$key]["channalinfo"] = $tran_channal[$value["channal"]];
             $translation[$key]["mypower"] = $tran_channal[$value["channal"]]["mypower"];
             $translation[$key]["status"] = $tran_channal[$value["channal"]]["status"];
@@ -275,14 +274,26 @@ foreach ($_data as $key => $value) {
     }
 
     //查询路径
-    $para_path = _get_para_path($bookId, $para);
+	$arrPath = $_pali_text->getPath($bookId, $para);
+	if(count($arrPath)>0){
+		$ref = $_pali_text->getPathHtml($arrPath);
+		$pathTopLevel = $arrPath[count($arrPath)-1];
+		$bookTitle = $_pali_book->getBookTitle($pathTopLevel["book"],$pathTopLevel["para"]);
+	}
+	else{
+		$ref="";
+		$bookTitle="";
+	}
+
+    //$para_path = _get_para_path($bookId, $para);
 
     $output[] = array("id" => $id,
         "palitext" => $palitext,
         "pali_sent_id" => $pali_text_id,
         "tran" => $tran,
         "translation" => $translation,
-        "ref" => $para_path,
+        "ref" => $ref,
+		"booktitle"=>$bookTitle,
         "tran_count" => $tran_count,
         "book" => $bookId,
         "para" => $para,

+ 32 - 6
app/term/term.css

@@ -115,11 +115,26 @@
 .tran_div:last-child {
 	border-bottom: none;
 }
-
+.ref .tooltiptext {
+	background-color: seashell;
+}
+.ref .tooltip .tooltiptext {
+	right: 0;
+	box-shadow: 0 0 10px rgb(0 0 0 / 15%);
+}
+.ref .tooltip .tooltip-bottom::after {
+	left: 90%;
+	border-color: transparent transparent seashell transparent;
+}
+.ref .tooltip-bottom {
+	top: 100%;
+	left: unset;
+	margin-left: unset;
+}
 note:hover chapter {
-	display: inline;
+	/*display: inline;*/
 }
-.ref > chapter:first-child {
+.ref > .book_name > chapter:first-child {
 	display: inline;
 }
 chapter {
@@ -135,6 +150,9 @@ chapter:hover {
 	color: var(--link-color);
 	/*text-decoration: underline;*/
 }
+.tooltiptext chapter {
+	display: inline;
+}
 para {
 	background-color: var(--drop-bg-color);
 	padding: 0 4px;
@@ -142,6 +160,10 @@ para {
 	cursor: pointer;
 	color: var(--btn-border-color);
 	border-radius: 5px;
+	display: none;
+}
+.tooltiptext para {
+	display: inline;
 }
 para:hover {
 	text-decoration: underline;
@@ -297,18 +319,18 @@ note .ref {
 	overflow-x: scroll;
 	max-width: 100%;
 	white-space: nowrap;
-	position: absolute;
-	right: 1em;
+	text-align: right;
 }
 note:hover .ref {
 	/*border-top: solid 1px var(--border-line-color);*/
-	position: absolute;
+	/*
 	margin-left: -45vw;
 	width: 45vw;
 	max-width: 45vw;
 	overflow: hidden;
 	white-space: nowrap;
 	overflow-x: scroll;
+	*/
 }
 
 .progress_bar_done {
@@ -721,3 +743,7 @@ li.active {
 .disable {
 	cursor: not-allowed;
 }
+
+.pali_div {
+	padding: 0 10px 5px 10px;
+}

+ 19 - 1
app/usent/function.php

@@ -121,6 +121,12 @@ class SentPr{
 	}
 }
 
+class Sent_his
+{
+	private $dbh_his;
+	private $errorMsg="";
+}
+
 class Sent_DB
 {
     private $dbh_sent;
@@ -147,8 +153,20 @@ class Sent_DB
 		else{
 			return false;
 		}
-		
 	}
+	public function getSentDefaultByLan($book,$para,$begin,$end,$lang){
+		$query = "SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND channal = ?  ";
+		$stmt = $this->dbh_sent->prepare($query);
+		if($stmt){
+			$stmt->execute(array($book,$para,$begin,$end,$channel));
+			$fetchDest = $stmt->fetch(PDO::FETCH_ASSOC);
+			return $fetchDest;
+		}
+		else{
+			return false;
+		}
+	}
+
 	public function update($arrData){
 		/* 修改现有数据 */
 	

+ 13 - 15
app/usent/get.php

@@ -6,12 +6,16 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 require_once "../channal/function.php";
+require_once "../redis/function.php";
 require_once "../ucenter/function.php";
+require_once "../share/function.php";
+
+$redis = redis_connect();
 
 #查询有阅读权限的channel
 $channal_list = array();
 if (isset($_COOKIE["userid"])) {
-    PDO_Connect("" . _FILE_DB_CHANNAL_);
+    PDO_Connect(_FILE_DB_CHANNAL_);
     $query = "SELECT id from channal where owner = ?   limit 0,100";
     $Fetch_my = PDO_FetchAll($query, array($_COOKIE["userid"]));
     foreach ($Fetch_my as $key => $value) {
@@ -20,17 +24,11 @@ if (isset($_COOKIE["userid"])) {
     }
 
     # 找协作的
-    $Fetch_coop = array();
-    $query = "SELECT channal_id FROM cooperation WHERE  user_id = ? ";
-    $coop_channal = PDO_FetchAll($query, array($_COOKIE["userid"]));
-    if (count($coop_channal) > 0) {
-        foreach ($coop_channal as $key => $value) {
-            # code...
-            $channal_list[] = $value["channal_id"];
-        }
-    }
-    /*  创建一个填充了和params相同数量占位符的字符串 */
-
+	$coop_channal = share_res_list_get($_COOKIE["userid"],2);
+	foreach ($coop_channal as $key => $value) {
+		# code...
+		$channal_list[] = $value["res_id"];
+	}
 }
 if (count($channal_list) > 0) {
     $channel_place_holders = implode(',', array_fill(0, count($channal_list), '?'));
@@ -41,8 +39,7 @@ if (count($channal_list) > 0) {
 
 # 查询有阅读权限的channel 结束
 
-$dns = "" . _FILE_DB_SENTENCE_;
-$dbh = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
+$dbh = new PDO(_FILE_DB_SENTENCE_, "", "", array(PDO::ATTR_PERSISTENT => true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 /* 开始一个事务,关闭自动提交 */
 
@@ -67,13 +64,14 @@ if (isset($_GET["sentences"])) {
 }
 
 $Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
-$channel_info = new Channal();
+$channel_info = new Channal($redis);
 $user_info = new UserInfo();
 
 foreach ($Fetch as $key => $value) {
     # code...
     $channel = $channel_info->getChannal($value["channal"]);
     if ($channel) {
+		$Fetch[$key]["mypower"] = $channel_info->getPower($value["channal"]);
         $Fetch[$key]["c_name"] = $channel["name"];
         $Fetch[$key]["c_owner"] = $user_info->getName($channel["owner"]);
         $Fetch[$key]["channalinfo"] = $channel;

+ 1 - 1
app/usent/sent_post.php

@@ -38,7 +38,7 @@ $cooperation = 0;
 $text_lang = "en";
 $channel_status = 0;
 if (isset($_POST["channal"])) {
-    PDO_Connect("" . _FILE_DB_CHANNAL_);
+    PDO_Connect( _FILE_DB_CHANNAL_);
     $query = "SELECT owner, lang , status FROM channal WHERE id=?";
     $fetch = PDO_FetchRow($query, array($_POST["channal"]));