Bläddra i källkod

藏经阁 译文修改 提交和采纳基本完成

visuddhinanda 5 år sedan
förälder
incheckning
ac76bb63e3

+ 1 - 0
.vscode/launch.json

@@ -4,6 +4,7 @@
   // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
   "version": "0.2.0",
   "configurations": [
+  
     {
       "type": "chrome",
       "request": "launch",

+ 48 - 29
app/commit/commit.js

@@ -22,36 +22,34 @@ function commit_render_channel_select() {
 	html += "<div class='commit_win_inner' >";
 	html += commit_render_head(1);
 	html += "<div style='display:flex;'>";
-	html += "<div>译文来源:";
-	html += "<select id='src_channel' onchange='src_change(this)'>";
-	if (typeof _commit_data.src == "undefined") {
-		let lastSrc = localStorage.getItem("commit_last_src");
-		if (typeof lastSrc == "undefined") {
-			html += "<option value='' selected>请选择当前版本</option>";
-		} else {
-			_commit_data.src = lastSrc;
-		}
-	}
-	for (const iterator of _my_channal) {
-		if (iterator.status > 0) {
-			html += "<option value='" + iterator.id + "' ";
+
+	if (typeof _commit_data.src != "undefined") {
+		html += "<div>译文来源:";
+		let isFound = false;
+		for (const iterator of _my_channal) {
 			if (_commit_data.src == iterator.id) {
-				html += " selected ";
+				html += iterator.name;
+				isFound = true;
+				break;
 			}
-			html += ">" + iterator.name + "-";
-			if (iterator.power >= 30) {
-				html += gLocal.gui.your;
-			} else if (iterator.power >= 20) {
-				html += "可编辑";
-			} else {
-				html += "只读";
+		}
+		if (!isFound) {
+			for (const iterator of _channalData) {
+				if (_commit_data.src == iterator.id) {
+					html += iterator.name;
+					isFound = true;
+					break;
+				}
 			}
-			html += "</option>";
 		}
+		if (!isFound) {
+			html += "无法找到Channel";
+		}
+		html += "</div>";
+	} else {
+		html += "<div>请选择译文来源";
+		html += "</div>";
 	}
-	html += "</select>";
-
-	html += "</div>";
 	html += "<div>==></div>";
 	html += "<div>目标译文:";
 	html += "<select id='dest_channel' onchange='dest_change(this)'>";
@@ -64,7 +62,7 @@ function commit_render_channel_select() {
 		}
 	}
 	for (const iterator of _my_channal) {
-		if (iterator.status > 0) {
+		if (iterator.status > 0 && _commit_data.src != iterator.id) {
 			html += "<option value='" + iterator.id + "' ";
 			if (_commit_data.dest == iterator.id) {
 				html += " selected ";
@@ -200,24 +198,30 @@ function commit_render_comp(mode) {
 	html += "</div>";
 
 	let textCount = 0;
-	for (const iterator of sentData) {
+	let sentIndex = 0;
+	for (let iterator of sentData) {
+		iterator.checked = false;
 		if (iterator.translation[0].text != iterator.translation[1].text) {
 			textCount++;
 			if (iterator.translation[0].id != "") {
 				html += "<div class='commit_compare'>";
-				html += "<div ><input class='sent_checkbox' type='checkbox' ";
+				html += "<div >";
+				html += "<input class='sent_checkbox' index='" + sentIndex + "' type='checkbox' ";
 				switch (mode) {
 					case 0:
 						if (iterator.translation[1].id == "") {
 							html += " checked ";
+							iterator.checked = true;
 						} else {
 							if (iterator.translation[0].update_time > iterator.translation[1].update_time) {
 								html += " checked ";
+								iterator.checked = true;
 							}
 						}
 						break;
 					case 1:
 						html += " checked ";
+						iterator.checked = true;
 						break;
 					case 2:
 						break;
@@ -260,6 +264,7 @@ function commit_render_comp(mode) {
 				html += "</div>";
 			}
 		}
+		sentIndex++;
 	}
 	if (textCount == 0) {
 		html += "译文全部相同,无需推送。";
@@ -270,9 +275,10 @@ function commit_render_comp(mode) {
 
 function commit_sent_select(obj) {
 	let sent_id = $(obj).attr("sent_id");
-	for (const iterator of sentData) {
+	for (let iterator of sentData) {
 		if (iterator.pali_sent_id == sent_id) {
 			let html = "";
+			iterator.checked = obj.checked;
 			if (obj.checked) {
 				if (iterator.translation[1].id != "") {
 					html += "<del>" + iterator.translation[1].text + "</del><br>";
@@ -306,6 +312,19 @@ function commit_render_final(result) {
 }
 function commit_pull() {
 	localStorage.setItem("commit_src_" + _commit_data.src, _commit_data.dest);
+	let pullData = new Array();
+	for (const iterator of sentData) {
+		if (iterator.checked) {
+			for (const iterator of _arrData) {
+				pullData.push(iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end);
+			}
+			_commit_data.sent = pullData;
+		}
+	}
+	if (pullData.length == 0) {
+		alert("没有数据被选择");
+		return;
+	}
 	$.post(
 		"../commit/commit.php",
 		{

+ 11 - 2
app/commit/commit.php

@@ -66,7 +66,16 @@ if($stmt){
 			$fetchDest = $stmt->fetch(PDO::FETCH_ASSOC);
 			if ($fetchDest) {
 				#有目标数据,比较时间
-				if($fetchSrc["modify_time"]>$fetchDest["modify_time"]){
+				$insert=false;
+				if(isset($_data["compare"]) && $_data["compare"]=="auto"){
+					if($fetchSrc["modify_time"]>$fetchDest["modify_time"]){
+						$insert = true;
+					}					
+				}
+				else{
+					$insert = true;
+				}
+				if($insert){
 					#新数据 更新
 					if($destChannelPower>=20){
 						#有权限 直接写入
@@ -77,7 +86,7 @@ if($stmt){
 					else{
 						#pr
 						$prData[] = $newData;
-					}
+					}					
 				}
 			}
 			else{

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 0
app/public/images/svg.md


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 2 - 0
app/studio/svg/icon.svg


+ 132 - 71
app/term/note.js

@@ -655,7 +655,7 @@ function render_one_sent_tran_a(iterator) {
 	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
 		html += " pr ";
 	}
-	html += "' channel='" + iterator.channal + "' sid='" + sid + "'>";
+	html += "' dbid='" + iterator.id + "' channel='" + iterator.channal + "' sid='" + sid + "'>";
 	html += "<div class='sent_tran_inner'>";
 	html += '<div class="tool_bar">';
 	html += '	<div class="right">';
@@ -667,7 +667,7 @@ function render_one_sent_tran_a(iterator) {
 		if (typeof iterator.is_pr_editor != "undefined" && iterator.is_pr_editor == true) {
 			//提交人
 			//修改按钮
-			html += "<button class='icon_btn tooltip' onclick='sent_pr_edit(this)'>";
+			html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
 			html += '<svg class="icon" >';
 			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
 			html += "</svg>";
@@ -687,16 +687,17 @@ function render_one_sent_tran_a(iterator) {
 			html += "</button>";
 		} else {
 			//非提交人
-			//采纳按钮
-			html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
-			html += '<svg class="icon" >';
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
-			html += "</svg>";
-			html += "<span class='tooltiptext tooltip-top'>";
-			html += gLocal.gui.accept_copy;
-			html += "</span>";
-			html += "</button>";
-
+			if (parseInt(iterator.mypower) >= 20) {
+				//有权限 采纳按钮
+				html += "<button class='icon_btn tooltip' onclick=\"sent_pr_merge('" + iterator.id + "')\">";
+				html += '<svg class="icon" >';
+				html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#accept_copy"></use>';
+				html += "</svg>";
+				html += "<span class='tooltiptext tooltip-top'>";
+				html += gLocal.gui.accept_copy;
+				html += "</span>";
+				html += "</button>";
+			}
 			//点赞按钮
 			html += "<button class='icon_btn tooltip' onclick='sent_pr_like(this)'>";
 			html += '<svg class="icon" >';
@@ -712,7 +713,11 @@ function render_one_sent_tran_a(iterator) {
 		//编辑按钮
 		html += "<button class='icon_btn tooltip' onclick='sent_tran_edit(this)'>";
 		html += '<svg class="icon" >';
-		html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
+		if (parseInt(iterator.mypower) < 20) {
+			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#my_idea"></use>';
+		} else {
+			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
+		}
 		html += "</svg>";
 		html += "<span class='tooltiptext tooltip-top'>";
 		if (parseInt(iterator.mypower) < 20) {
@@ -720,22 +725,37 @@ function render_one_sent_tran_a(iterator) {
 		} else {
 			html += gLocal.gui.edit;
 		}
-
 		html += "</span>";
 		html += "</button>";
 
 		//推送按钮
-		if (parseInt(iterator.mypower) >= 20) {
-			html += "<button class='icon_btn tooltip' ";
-			html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
-			html += '<svg class="icon" >';
-			html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#ic_mode_edit"></use>';
-			html += "</svg>";
-			html += "<span class='tooltiptext tooltip-top'>";
-			html += "推送";
-			html += "</span>";
-			html += "</button>";
+		let commitIcon = "";
+		let commitTipText = "";
+		if (parseInt(iterator.mypower) >= 30 && parseInt(iterator.status) < 30) {
+			//我的私有资源 公开发布
+			commitIcon = "publish";
+			commitTipText = "公开发布";
+		} else {
+			if (parseInt(iterator.mypower) < 20) {
+				//只读资源 采纳
+				commitIcon = "accept_copy";
+				commitTipText = "采纳";
+			} else {
+				//其他资源 复制到
+				commitIcon = "copy";
+				commitTipText = "复制到";
+			}
 		}
+		html += "<button class='icon_btn tooltip' ";
+		html += " onclick=\"sent_commit('" + iterator.channal + "','" + sid + "')\">";
+		html += '<svg class="icon" >';
+		html += '<use xlink="http://www.w3.org/1999/xlink" href="../studio/svg/icon.svg#' + commitIcon + '"></use>';
+		html += "</svg>";
+		html += "<span class='tooltiptext tooltip-top'>";
+		html += commitTipText;
+		html += "</span>";
+		html += "</button>";
+		//推送按钮结束
 
 		//更多按钮
 		html += '<div class="case_dropdown">';
@@ -806,7 +826,13 @@ function render_one_sent_tran_a(iterator) {
 	html += "<textarea dbid='" + iterator.id + "' ";
 	html += "sid='" + sid + "' ";
 	html += "channel='" + iterator.channal + "' ";
-	html += 'onchange="note_sent_save_a(this)">' + iterator.text + "</textarea>";
+	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
+		html += 'onchange="note_pr_save(this)"';
+	} else {
+		html += 'onchange="note_sent_save_a(this)"';
+	}
+
+	html += ">" + iterator.text + "</textarea>";
 	html += "</div>";
 	html += '<div class="edit_tool">';
 	if (parseInt(iterator.mypower) < 20) {
@@ -1133,6 +1159,36 @@ function note_edit_sentence(book, para, begin, end, channal) {
 	alert("未找到句子");
 }
 function update_note_sent_tran(obj) {}
+//保存pr句子 新
+function note_pr_save(obj) {
+	let id = $(obj).attr("dbid");
+	let sid = $(obj).attr("sid").split("-");
+	let book = sid[0];
+	let para = sid[1];
+	let begin = sid[2];
+	let end = sid[3];
+	let channel = $(obj).attr("channel");
+	let text = $(obj).val();
+	let sent_tran_div = find_sent_tran_div(obj);
+	$.post(
+		"../usent/pr_post.php",
+		{
+			id: id,
+			book: book,
+			para: para,
+			begin: begin,
+			end: end,
+			channel: channel,
+			text: text,
+		},
+		sent_save_callback
+	);
+
+	if (sent_tran_div) {
+		$(sent_tran_div).find(".preview").addClass("loading");
+	}
+}
+
 //保存译文句子 新
 function note_sent_save_a(obj) {
 	let id = $(obj).attr("dbid");
@@ -1156,59 +1212,64 @@ function note_sent_save_a(obj) {
 			text: text,
 			lang: "zh",
 		},
-		function (data) {
-			let result = JSON.parse(data);
-			if (result.status > 0) {
-				alert("error" + result.message);
-			} else {
-				if (result.commit_type == 1 || result.commit_type == 2) {
-					ntf_show("成功修改");
-					if (sent_tran_div) {
-						let divPreview = $(sent_tran_div).find(".preview").first();
-						if (result.text == "") {
-							let channel_info = "Empty";
-							let thisChannel = find_channal(result.channal);
-							if (thisChannel) {
-								channel_info = thisChannel.name + "-" + thisChannel.nickname;
-							}
-							divPreview.html(
-								"<span style='color:var(--border-line-color);'>" + channel_info + "</span>"
-							);
-						} else {
-							divPreview.html(
-								marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
-							);
-							term_updata_translation();
-							popup_init();
-							for (const iterator of _arrData) {
-								if (
-									iterator.book == result.book &&
-									iterator.para == result.para &&
-									iterator.begin == result.begin &&
-									iterator.end == result.end
-								) {
-									for (const tran of iterator.translation) {
-										if (tran.channal == result.channal) {
-											tran.text = result.text;
-											break;
-										}
-									}
+		sent_save_callback
+	);
+
+	if (sent_tran_div) {
+		$(sent_tran_div).find(".preview").addClass("loading");
+	}
+}
+
+function sent_save_callback(data) {
+	let result = JSON.parse(data);
+	if (result.status > 0) {
+		alert("error" + result.message);
+	} else {
+		let sid = result.book + "-" + result.para + "-" + result.begin + "-" + result.end;
+
+		let sent_tran_div = $(
+			".sent_tran[dbid='" + result.id + "'][channel='" + result.channal + "'][sid='" + sid + "']"
+		);
+		if (result.commit_type == 1 || result.commit_type == 2) {
+			ntf_show("成功修改");
+			if (sent_tran_div) {
+				let divPreview = sent_tran_div.find(".preview").first();
+				if (result.text == "") {
+					let channel_info = "Empty";
+					let thisChannel = find_channal(result.channal);
+					if (thisChannel) {
+						channel_info = thisChannel.name + "-" + thisChannel.nickname;
+					}
+					divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
+				} else {
+					divPreview.html(
+						marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
+					);
+					term_updata_translation();
+					popup_init();
+					for (const iterator of _arrData) {
+						if (
+							iterator.book == result.book &&
+							iterator.para == result.para &&
+							iterator.begin == result.begin &&
+							iterator.end == result.end
+						) {
+							for (const tran of iterator.translation) {
+								if (tran.channal == result.channal) {
+									tran.text = result.text;
+									break;
 								}
 							}
 						}
-						$(sent_tran_div).find(".preview").removeClass("loading");
 					}
-				} else if (result.commit_type == 3) {
-					ntf_show("已经提交修改建议");
-				} else {
-					ntf_show("未提交");
 				}
+				sent_tran_div.find(".preview").removeClass("loading");
 			}
+		} else if (result.commit_type == 3) {
+			ntf_show("已经提交修改建议");
+		} else {
+			ntf_show("未提交");
 		}
-	);
-
-	if (sent_tran_div) {
-		$(sent_tran_div).find(".preview").addClass("loading");
 	}
 }
 

+ 5 - 0
app/term/note.php

@@ -177,6 +177,7 @@ foreach ($_data as $key => $value) {
 										   "text" => $Fetch["text"], 
 										   "lang" => $Fetch["language"], 
 										   "channal" => $Fetch["channal"], 
+										   "status" => $Fetch["status"], 
 										   "editor" => $Fetch["editor"],
 										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
 										   "update_time"=>$Fetch["modify_time"]
@@ -200,6 +201,7 @@ foreach ($_data as $key => $value) {
 										   "text" => $Fetch["text"], 
 										   "lang" => $Fetch["language"], 
 										   "channal" => $Fetch["channal"], 
+										   "status" => $Fetch["status"], 
 										   "editor" => $Fetch["editor"],
 										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
 										   "update_time"=>$Fetch["modify_time"]
@@ -223,6 +225,7 @@ foreach ($_data as $key => $value) {
 										   "text" => $Fetch["text"], 
 										   "lang" => $Fetch["language"], 
 										   "channal" => $value, 
+										   "status" => $Fetch["status"], 
 										   "editor" => $Fetch["editor"],
 										   "editor_name"=>$_userinfo->getName($Fetch["editor"]),
 										   "update_time"=>$Fetch["modify_time"]
@@ -237,6 +240,7 @@ foreach ($_data as $key => $value) {
 										   "text" => "", 
 										   "lang" => "", 
 										   "channal" => $value,
+										   "status" => 0,
 										   "editor" => false,
 										   "editor_name"=>false,
 										   "update_time"=>false
@@ -261,6 +265,7 @@ foreach ($_data as $key => $value) {
         if ($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"];
 			#查询句子pr
 			$translation[$key]["pr_new"]=$_sentPr->getNewPrNumber($value["book"],$value["para"],$value["begin"],$value["end"],$value["channal"]);
 			$translation[$key]["pr_all"]=$_sentPr->getAllPrNumber($value["book"],$value["para"],$value["begin"],$value["end"],$value["channal"]);

+ 22 - 1
app/usent/function.php

@@ -66,7 +66,7 @@ class SentPr{
 
 	public function getPrData($book,$para,$begin,$end,$channel){
 		if ($this->dbh_sent) {
-            $query = "SELECT id,book,paragraph,begin,end,text,editor,modify_time FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 limit 0,100";
+            $query = "SELECT id,book,paragraph,begin,end,channel,text,editor,modify_time FROM sent_pr WHERE book = ? and paragraph= ? and begin=? and end=? and channel=? and status=1 limit 0,100";
             $stmt = $this->dbh_sent->prepare($query);
             $stmt->execute(array($book,$para,$begin,$end,$channel));
             $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -98,6 +98,27 @@ class SentPr{
 			return false;
 		}
 	}
+
+	public function setPrData($id,$text){
+		if ($this->dbh_sent) {
+            $query = "UPDATE sent_pr set text=? ,modify_time=?  WHERE id = ? and editor= ? ";
+            $stmt = $this->dbh_sent->prepare($query);
+            $stmt->execute(array($text,mTime(),$id,$_COOKIE["userid"]));
+            
+			if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+				/*  识别错误  */
+				$error = $this->dbh_sent->errorInfo();
+				//$respond['message'] = $error[2];
+				return false;
+			} else {
+				#没错误 更新历史记录
+				return true;
+			}
+		}
+		else{
+			return false;
+		}
+	}
 }
 
 class Sent_DB

+ 4 - 1
app/usent/get_pr.php

@@ -15,7 +15,10 @@ foreach ($result as $key => $value) {
 	# code...
 	$result[$key]["editor_name"]=$user_info->getName($value["editor"]);
 	$result[$key]["update_time"]=$value["modify_time"];
-	$result[$key]["channalinfo"] = $channel_info->getChannal($value["channal"]);
+	$result[$key]["channal"]=$value["channel"];
+	$result[$key]["para"]=$value["paragraph"];
+	$result[$key]["channalinfo"] = $channel_info->getChannal($value["channel"]);
+	$result[$key]["mypower"] = $channel_info->getPower($value["channel"]);
 	if(isset($_COOKIE["userid"])){
 		if($value["editor"]==$_COOKIE["userid"]){
 			$result[$key]["is_pr_editor"] =true;

+ 30 - 0
app/usent/pr_post.php

@@ -0,0 +1,30 @@
+<?php
+
+require_once "../usent/function.php";
+require_once "../channal/function.php";
+require_once "../ucenter/function.php";
+require_once "../redis/function.php";
+
+//回传数据
+$respond = array("status" => 0, "message" => "");
+$respond['id'] = $_POST["id"];
+$respond['book'] = $_POST["book"];
+$respond['para'] = $_POST["para"];
+$respond['begin'] = $_POST["begin"];
+$respond['end'] = $_POST["end"];
+$respond['channal'] = $_POST["channel"];
+$respond['text'] = $_POST["text"];
+$respond['editor'] = $_COOKIE["userid"];
+$respond['commit_type'] = 1;
+
+$redis = redis_connect();
+
+$channel_info = new Channal();
+$user_info = new UserInfo();
+$pr = new SentPr($redis);
+$result = $pr->setPrData($_POST["id"],$_POST["text"]);
+if(!$result){
+	$respond['status']=1;
+	$respond['message']="error";
+}
+echo json_encode($respond, JSON_UNESCAPED_UNICODE);

+ 1 - 0
app/usent/sent_post.php

@@ -21,6 +21,7 @@ if (isset($_POST["landmark"])) {
 }
 //回传数据
 $respond = array("status" => 0, "message" => "");
+$respond['id'] = $_POST["id"];
 $respond['book'] = $_POST["book"];
 $respond['para'] = $_POST["para"];
 $respond['begin'] = $_POST["begin"];

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 666 - 666
dicttext/thin/ref_index.csv


Vissa filer visades inte eftersom för många filer har ändrats