Przeglądaj źródła

Merge pull request #964 from visuddhinanda/laravel

:bug: 修改建议无法采纳自己的
visuddhinanda 3 lat temu
rodzic
commit
ca092cd8e7

+ 1 - 1
app/Console/Commands/UpgradePaliText.php

@@ -84,7 +84,7 @@ class UpgradePaliText extends Command
 				Log::error( "can not open csv file. filename=" . $csvFile) ;
 				continue;
 			}
-			$title_data = PaliText::select(['book','paragraph','level','parent','toc'])
+			$title_data = PaliText::select(['book','paragraph','level','parent','toc','lenght'])
 								->where('book',$from)->orderby('paragraph','asc')->get();
             {
 				$paragraph_count = count($title_data);

+ 14 - 13
app/Http/Controllers/UserDictController.php

@@ -179,25 +179,26 @@ class UserDictController extends Controller
 		return $this->ok([$count,$updateOk]);
     }
 	public function delete(Request $request){
-		Log::info("userDictController->destroy start");
+		Log::info("userDictController->delete start");
 		$arrId = json_decode($request->get("id"),true) ;
 		Log::info("id=".$request->get("id"));
 		$count = 0;
 		$updateOk = false;
 		foreach ($arrId as $key => $id) {
-			# 找到对应数据
 			$data = UserDict::where('id',$id)->first();
-			Log::info('creator_id:'.$data->creator_id);
-			$param = [
-				"id"=>$id,
-				'creator_id'=>$_COOKIE["user_id"]
-			];
-			Log::info($param);
-			$del = UserDict::where($param)->delete();
-			$count += $del;
-			$updateOk = $this->update_sys_wbw($data);
-			$this->update_redis($data);
-
+			if($data){
+				# 找到对应数据 
+				Log::info('creator_id:'.$data->creator_id);
+				$param = [
+					"id"=>$id,
+					'creator_id'=>$_COOKIE["user_id"]
+				];
+				Log::info($param);
+				$del = UserDict::where($param)->delete();
+				$count += $del;
+				$updateOk = $this->update_sys_wbw($data);
+				$this->update_redis($data);				
+			}
 		}
 		Log::info("delete:".$count);
 		return $this->ok(['deleted'=>$count]);

+ 1 - 1
public/app/api/controller/user_dicts.php

@@ -250,7 +250,7 @@ Class CtlUserDict extends Controller{
 									$one["language"]
 									);
 				}
-				$this->redis->hSet("dict://user",$word['word'],json_encode($redisWord,JSON_UNESCAPED_UNICODE));			
+				$this->redis->hSet(Redis["namespace"]."dict/user",$word['word'],json_encode($redisWord,JSON_UNESCAPED_UNICODE));			
 			}
 		}
 		#更新redis结束

+ 1 - 1
public/app/dict/dict_lookup.php

@@ -341,7 +341,7 @@ function lookup_user($word){
 	$Fetch=array();
 	
 	if($redis){
-		$rediskey = Redis["prefix"]."dict/user";
+		$rediskey = Redis["namespace"]."dict/user";
 		$wordData = $redis->hGet($rediskey,$word);
 			if($wordData){
 				if(!empty($wordData)){

+ 1 - 1
public/app/dict/redis_import_user.php

@@ -2,7 +2,7 @@
 require_once __DIR__."/../config.php";
 require_once __DIR__."/../redis/function.php";
 
-$rediskey = Redis["prefix"]."dict/user";
+$rediskey = Redis["namespace"]."dict/user";
 if (PHP_SAPI == "cli") {
 	$redis = redis_connect();
 	if ($redis != false) {

+ 1 - 1
public/app/studio/dict_find_auto.php

@@ -101,7 +101,7 @@ array_push($db_file_list, array(_DIR_DICT_3RD_ . "/uhan_en.db", ""));
 
 $db_file_list[] = array("","wbwdict://new/".$_COOKIE["userid"],true);	
 $db_file_list[] = array(_FILE_DB_TERM_,"dict://term",true);	
-$db_file_list[] = array(_FILE_DB_WBW1_,Redis["prefix"]."dict/user",true);
+$db_file_list[] = array(_FILE_DB_WBW1_,Redis["namespace"]."dict/user",true);
 
 $db_file_list[] = array( _DIR_DICT_SYSTEM_ . "/sys_regular.db","dict://regular",true);
 $db_file_list[] = array( _DIR_DICT_SYSTEM_ . "/sys_irregular.db","dict://irregular",true);

+ 1 - 1
public/app/studio/dict_find_one.php

@@ -70,7 +70,7 @@ $db_file_list = array();
 //词典列表
 if ($dict_name == "") {
     $db_file_list[] = array(_FILE_DB_TERM_,"dict://term",true);	
-	$db_file_list[] = array(_FILE_DB_WBW1_,Redis["prefix"]."dict/user",true);
+	$db_file_list[] = array(_FILE_DB_WBW1_,Redis["namespace"]."dict/user",true);
 	
     $db_file_list[] = array( _DIR_DICT_SYSTEM_ . "/sys_regular.db","dict://regular",true);
     $db_file_list[] = array( _DIR_DICT_SYSTEM_ . "/sys_irregular.db","dict://irregular",true);

+ 17 - 17
public/app/studio/dict_updata_wbw.php

@@ -1,4 +1,4 @@
-<?php
+<?php
 require_once 'checklogin.inc';
 require_once "../public/_pdo.php";
 require_once "../config.php";
@@ -35,7 +35,7 @@ foreach ($word as $x => $ws) {
 				 mean = ? AND
 				 base = ? AND
 				 factors = ? AND
-				 factormean = ? AND source = '_USER_DATA_'" ;
+				 factormean = ? AND source = '_USER_WBW_'" ;
     $Fetch = PDO_FetchAll($query,array($ws->pali,$ws->type,$ws->gramma,$ws->mean,$ws->parent,$ws->factors,$ws->fm));
     $FetchNum = count($Fetch);
 
@@ -54,7 +54,7 @@ foreach ($word as $x => $ws) {
             $ws->fm,
             $ws->status,
             $ws->language,
-			'_USER_DATA_',
+			'_USER_WBW_',
             mTime());
         array_push($arrInserString, $params);
 
@@ -136,7 +136,7 @@ if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
 	if ($redis != false) {
 		foreach ($updateWord as $key => $value) {
 			# code...
-			$query = "SELECT * from "._TABLE_DICT_USER_." where word = ? ";
+			$query = "SELECT * from "._TABLE_DICT_USER_." where word = ? and source = '_USER_WBW_'";
 			$stmt = $PDO->prepare($query);
 			$stmt->execute(array($key));
 			if ($stmt) {
@@ -146,21 +146,21 @@ if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
 					# code...
 					$redisWord[] = array($one["id"],
 										$one["pali"],
-									$one["type"],
-									$one["gramma"],
-									$one["parent"],
-									$one["mean"],
-									$one["note"],
-									$one["factors"],
-									$one["factormean"],
-									$one["status"],
-									$one["confidence"],
-									$one["creator"],
-									$one["dict_name"],
-									$one["language"]
+										$one["type"],
+										$one["gramma"],
+										$one["parent"],
+										$one["mean"],
+										$one["note"],
+										$one["factors"],
+										$one["factormean"],
+										$one["status"],
+										$one["confidence"],
+										$one["creator"],
+										$one["dict_name"],
+										$one["language"]
 									);
 				}
-				$redis->hSet("dict://user",$key,json_encode($redisWord,JSON_UNESCAPED_UNICODE));
+				$redis->hSet(Redis["namespace"]."dict/user",$key,json_encode($redisWord,JSON_UNESCAPED_UNICODE));
 			}				
 		}
 	}

+ 82 - 65
public/app/term/note.js

@@ -955,6 +955,16 @@ function sent_pr_merge(id) {
 				alert("error" + result.message);
 			} else {
 				ntf_show("成功采纳");
+				result.channal = result.channel;
+				let sent_tran_div = $(
+					".sent_tran[dbid='" + result.data.id + "']"
+				);
+				if (sent_tran_div) {
+					update_sent_text(sent_tran_div,result.data);
+				}else{
+					ntf_show("找不到句子容器");
+				}
+				
 			}
 		}
 	);
@@ -1108,17 +1118,17 @@ function render_one_sent_tran_a(iterator, diff = false) {
 			html += render_icon_button("ic_delete", "note_pr_delete(this)", gLocal.gui.delete);
 		} else {
 			//非提交人
-			if (parseInt(iterator.mypower) >= 20) {
-				//有权限 采纳按钮
-				html += render_icon_button(
-					"accept_copy",
-					"sent_pr_merge('" + iterator.id + "')",
-					gLocal.gui.accept_copy
-				);
-			}
 			//点赞按钮
 			html += render_icon_button("like", "sent_pr_like(this)", gLocal.gui.like);
 		}
+		if (parseInt(iterator.mypower) >= 20) {
+			//有权限 采纳按钮
+			html += render_icon_button(
+				"accept_copy",
+				"sent_pr_merge('" + iterator.id + "')",
+				gLocal.gui.accept_copy
+			);
+		}
 	} else {
 		//非pr列表里的句子
 		//编辑按钮
@@ -2259,63 +2269,7 @@ function sent_save_callback(data) {
 		if (result.commit_type == 1 || result.commit_type == 2) {
 			ntf_show("成功修改");
 			if (sent_tran_div) {
-				let divPreview = sent_tran_div.find(".preview").first();
-                let thisChannel = find_channal(result.channal);
-				if (result.text == "") {
-                    //内容为空
-					let channel_info = "Empty";
-					if (thisChannel) {
-						channel_info = thisChannel.name + "-" + thisChannel.nickname;
-					}
-					divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
-				} else {
-					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;
-								}
-							}
-						}
-					}
-                    switch (thisChannel.type) {
-                        case 'nissaya':
-							let nissayaHtml = "";
-							nissayaHtml += "<div class='nissaya'>";
-							nissayaHtml += note_init(renderNissayaPreview(result.text), result.channal, result.editor, result.lang);
-							nissayaHtml += "</div>";
-                            divPreview.html(nissayaHtml);
-                            break;
-                        case 'commentary':
-                            divPreview.html(
-                                note_init(result.text, result.channal, result.editor, result.lang)
-                            );
-                            note_refresh_new();
-                        break;
-						case 'original':
-							switch (getCookie('language')) {
-								case 'my':
-									//缅文
-									result.text = roman_to_my(result.text);
-									break;
-							}
-                        default:
-                            divPreview.html(
-                                note_init(result.text, result.channal, result.editor, result.lang)
-                            );
-                            term_updata_translation();                        
-                            break;
-                    }
-					popup_init();
-                    //初始化气泡
-                    guide_init();
-				}
+				update_sent_text(sent_tran_div,result);
 			}
 		} else if (result.commit_type == 3) {
 			ntf_show("已经提交修改建议");
@@ -2325,6 +2279,69 @@ function sent_save_callback(data) {
 	}
 }
 
+function update_sent_text(sent_tran_div,result){
+	let divPreview = sent_tran_div.find(".preview").first();
+	let objTextarea = sent_tran_div.find(".text_input").children("textarea").first();
+	let thisChannel = find_channal(result.channal);
+	objTextarea.val(result.text);
+	if (result.text == "") {
+		//内容为空
+		let channel_info = "Empty";
+		if (thisChannel) {
+			channel_info = thisChannel.name + "-" + thisChannel.nickname;
+		}
+		divPreview.html("<span style='color:var(--border-line-color);'>" + channel_info + "</span>");
+	} else {
+		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;
+					}
+				}
+			}
+		}
+		switch (thisChannel.type) {
+			case 'nissaya':
+				let nissayaHtml = "";
+				nissayaHtml += "<div class='nissaya'>";
+				nissayaHtml += note_init(renderNissayaPreview(result.text), result.channal, result.editor, result.lang);
+				nissayaHtml += "</div>";
+				divPreview.html(nissayaHtml);
+				break;
+			case 'commentary':
+				divPreview.html(
+					note_init(result.text, result.channal, result.editor, result.lang)
+				);
+				note_refresh_new();
+			break;
+			case 'original':
+				switch (getCookie('language')) {
+					case 'my':
+						//缅文
+						result.text = roman_to_my(result.text);
+						objTextarea.val(result.text);
+						break;
+				}
+			default:
+				divPreview.html(
+					note_init(result.text, result.channal, result.editor, result.lang)
+				);
+				term_updata_translation();                        
+				break;
+		}
+		popup_init();
+		//初始化气泡
+		guide_init();
+	}
+}
+
 function pr_create_callback(data) {
 	let response;
 	if(typeof data=="string"){

+ 48 - 16
public/app/term/term.js

@@ -407,7 +407,8 @@ function term_array_updata() {
 }
 /*
 *-----------------------
-*更新术语显示
+* 更新术语显示
+* 默认模版<a href='{{ link }}'>{{meaning}}</a>({{word}},{{meaning2}})
 *-----------------------
 */
 function term_updata_translation(callback=null) {
@@ -424,9 +425,18 @@ function term_updata_translation(callback=null) {
 	}
 	$("term").each(function () {
 		let status = $(this).attr("status");
+		let orgWord = $(this).text().split('|');
+		let termText;		
+		if(status == 0){
+			if(orgWord.length>1){
+				$(this).attr("pali",orgWord[0]) ;
+				$(this).attr("show",orgWord[1]) ;
+				$(this).text(orgWord[0]);
+			}
+		}
 
-		let termText;
 		termText = $(this).attr("pali");
+
 		if(typeof termText=="undefined"){
 			termText = $(this).text();
 		}
@@ -450,6 +460,7 @@ function term_updata_translation(callback=null) {
 					$(this).attr("lang")
 				); //我的术语字典
 				if (myterm) {
+					//查字典成功
 					$(this).attr("status", "1");
 					$(this).attr("type", "0");
 					$(this).attr("guid", myterm.guid);
@@ -458,12 +469,14 @@ function term_updata_translation(callback=null) {
 					$(this).attr("mean2", myterm.other_meaning);
 					$(this).attr("replace", myterm.meaning);
 				} else {
+					//没查到
 					$(this).attr("status", "2");
 					$(this).attr("pali", termText);
 				}
 			}
 			let guid = $(this).attr("guid");
 			let pali = $(this).attr("pali");
+			let meaningShow = $(this).attr("show");
 			let mean = $(this).attr("mean");
 			let mean2 = $(this).attr("mean2");
 			let renderTo = $(this).attr("pos");
@@ -471,11 +484,20 @@ function term_updata_translation(callback=null) {
 			let lang = $(this).attr("lang");
 			let noteText = "";
 
+			let realMeaning = '';
+			if(typeof meaningShow !== "undefined"){
+				//指定显示意思优先
+				realMeaning = meaningShow;
+			}else{
+				realMeaning = mean;
+			}
+
 			if (termCounter[guid]) {
-				termCounter[guid] = 2;
+				termCounter[guid]++;
 			} else {
 				termCounter[guid] = 1;
 			}
+			console.log("termCounter",termCounter[guid]);
 			myterm = term_lookup_my(pali, $(this).attr("channal"), $(this).attr("editor"), $(this).attr("lang")); //我的术语字典
 			let linkclass = "";
 			if (myterm) {
@@ -501,7 +523,7 @@ function term_updata_translation(callback=null) {
 						}
 					}
 				}
-
+				console.log("term temlate",noteText);
 				noteText = noteText.replace(
 					"[",
 					"<span class='" +
@@ -519,7 +541,7 @@ function term_updata_translation(callback=null) {
 						"','"+channel+"','"+lang+"')\">"
 				);
 				noteText = noteText.replace("]", "</span>");
-				noteText = noteText.replace("%mean%", "<span class='term_mean'>" + mean + "</span>");
+				noteText = noteText.replace("%mean%", "<span class='term_mean'>" + realMeaning + "</span>");
 				noteText = noteText.replace("%pali%", "<span class='term_pali'>" + pali + "</span>");
 				if (mean2 != "") {
 					noteText = noteText.replace("%mean2%", ", <span class='term_mean2'>" + mean2 + "</span>");
@@ -527,18 +549,22 @@ function term_updata_translation(callback=null) {
 					noteText = noteText.replace("%mean2%", "");
 				}
 				noteText = noteText.replace("%note%", "<span class='term_note'>" + "" + "</span>");
-				if (myterm) {
-					if (myterm.meaning != mean) {
-						noteText = noteText.replace(
-							"%mymean%",
-							"<span class='term_mean_my'>" + myterm.meaning + "</span>"
-						);
+				
+				{
+					if (myterm) {
+						//匹配术语成功
+						if (myterm.meaning != mean) {
+							realMeaning = "<span class='term_mean_my'>" + myterm.meaning + "</span>";
+						} else {
+							realMeaning = '';
+						}
 					} else {
-						noteText = noteText.replace("%mymean%", "");
-					}
-				} else {
-					noteText = noteText.replace("%mymean%", "");
+						realMeaning = '';
+						
+					}					
 				}
+				noteText = noteText.replace("%mymean%", realMeaning);
+
 			} else {
 				noteText =
 					"<span class='" +
@@ -689,7 +715,12 @@ function term_get_dict(callback=null) {
 	let termwordlist = new Array();
 	$("term").each(function () {
 		if ($(this).attr("status") == 0) {
-			$(this).attr("pali", $(this).text());
+			let word = $(this).text().split('|');
+			$(this).attr("pali", word[0]);
+			if(word.length>1){
+				$(this).attr("show", word[1]);
+				$(this).text(word[0]);
+			}
 		}
 		let termword = new Object();
 		termword.pali = $(this).attr("pali");
@@ -703,6 +734,7 @@ function term_get_dict(callback=null) {
 	if (_display == "sent") {
 		readonly = false;
 	}
+	console.log('term list',termwordlist);
 	$.post(
 		"../term/term_get.php",
 		{

+ 1 - 0
public/app/usent/sent_pr_merge.php

@@ -42,6 +42,7 @@ if($prData){
 		}
 		if($db_sent->update($updateDate)){
 			$respond['update'] = count($updateDate);
+			$respond['data'] = $newData;
 		}
 		else{
 			$respond['message'] = $db_sent->getError();