Ver código fonte

Merge pull request #753 from visuddhinanda/laravel

术语修改对话框增加save as
visuddhinanda 4 anos atrás
pai
commit
604ab08ecd

+ 180 - 0
public/app/article/print.php

@@ -0,0 +1,180 @@
+<?php
+require_once __DIR__."/../config.php";
+require_once "../pcdl/html_head.php";
+?>
+<body style="margin: 0;padding: 0;" class="reader_body" >
+	<script>
+		var gCaseTable=<?php echo file_get_contents("../public/js/case.json"); ?>
+	</script>
+
+	<script  src="./article.js"></script>
+
+	<script>
+	<?php
+	$_id = "";
+	$_display = "";
+	$_channal  = "";
+	$_collect = "";
+
+	if(isset($_GET["view"])){
+		echo "_view='".$_GET["view"]."';";
+	}
+	else{
+		echo "_view='article';";
+	}
+
+	if(isset($_GET["collection"])){
+		echo "_collection_id='".$_GET["collection"]."';";
+	}
+
+	if(isset($_GET["channel"])){
+		echo "_channal='".$_GET["channel"]."';";
+	}
+
+
+	
+	if(isset($_GET["mode"]) && $_GET["mode"]=="edit" && isset($_COOKIE["userid"])){
+		#登录状态下 编辑模式
+		$_mode = "edit";
+		echo "_mode='edit';";
+		$classMode="edit_mode";
+	}
+	else{
+		$_mode = "read";
+		echo "_mode='read';";
+		$classMode="read_mode";
+	}
+	if(isset($_GET["display"])){
+		if($_mode == "edit"){
+			$_display = "sent";
+			echo "_display='sent';";	
+		}
+		else{
+			$_display = $_GET["display"];
+			echo "_display='".$_GET["display"]."';";	
+		}
+	}
+	else{
+		if($_mode=="read"){
+			$_display = "para";
+			echo "_display='para';";
+		}
+		else{
+			$_display = "sent";
+			echo "_display='sent';";			
+		}
+
+	}	
+	if(isset($_GET["direction"])){
+		$_direction = $_GET["direction"];
+		echo "_direction='".$_GET["direction"]."';";
+	}
+	else{
+		if($_mode=="read"){
+			$_direction = "row";
+			echo "_direction='row';";
+		}
+		else{
+			$_direction = "col";
+			echo "_direction='col';";
+		}
+	}
+	$contentClass= "";
+	if($_direction=="row"){
+		$contentClass .= ' horizontal ';
+	}
+	else{
+		$contentClass .= ' vertical ';
+	}
+	if($_display=="para"){
+		$contentClass .= ' para_mode ';
+	}
+	else{
+		$contentClass .= ' sent_mode ';
+	}
+	$contentClass .= " $_mode ";
+	
+	?>
+	</script>
+
+
+<link type="text/css" rel="stylesheet" href="style.css"  />
+
+<script src="../article/my_collect.js" type="text/javascript"></script>
+
+<script src="../../node_modules/mustache/mustache.js"></script>
+
+<style>
+ul.fancytree-container{
+	border:unset;
+	width: max-content;
+}
+.fancytree-container .active {
+    font-weight: 700;
+    color: var(--main-color);
+	background: linear-gradient(to right, var(--link-color), var(--nocolor));
+    border-radius: 5px;
+}
+span.fancytree-title{
+	color: var(--main-color1);
+}
+span.fancytree-node{
+	display: flex;
+}
+
+
+#content_toc>ul>li>span.fancytree-node{
+	font-size: 120%;
+    font-weight: 900;
+}
+#article_path chapter{
+	display:unset;
+}
+
+#contents ul, li {
+    margin-block-start: 0.5em;
+    margin-block-end: 0.5em;
+    margin-left: 7px;
+}
+.click_dropdown_div{
+	align-self: center;
+}
+.channel_select_button{
+	color: var(--link-color);
+	
+}
+.channel_select_button:hover{
+	text-decoration-line: underline;
+	
+}
+.sent_tran_div a{
+	white-space: normal;
+	overflow-wrap: anywhere;
+}
+.para_tran_div a{
+	white-space: normal;
+	overflow-wrap: anywhere;
+}
+
+</style>
+
+
+
+<div id="main_view" class="main_view <?php echo $classMode;?>">
+
+</div>
+
+
+
+<script>
+
+$(document).ready(function(){
+	note_create();
+	historay_init();
+    collection_load(_collection_id);
+});
+
+</script>
+
+</body>
+</html>

+ 0 - 0
public/app/article/templiates/footnote.tpl


+ 15 - 18
public/app/article/templiates/main.tpl

@@ -1,22 +1,19 @@
-<div>
-{{title}}
-</div>
-<div>
-{{subtitle}}
-</div>
-<div>
-{{editor.name}} at {{updated_at}}
-</div>
-<div class="content">
-{{content}}
+<div class="article">
+    {{#article}}
+        <div class="title heading{{article.level}}">{{article.title}}</div>
+        <div class="subtitle">{{article.subtitle}}</div>
+        <div class="editor">
+        {{article.editor.name}} at {{article.updated_at}}
+        </div>
+        <content>{{article.content}}</content>
+    {{/article}}
 </div>
 
 <h2>Glossary</h2>
-{{#glossary}}
-<b>{{pali}}</b>:{{meaning}}
-{{/glossary}}
+<glossary></glossary>
+
+<h2>reference</h2>
+<reference></reference>
 
-<h2>ref</h2>
-{{#ref}}
-{{path}}
-{{/ref}}
+<h2>footnote</h2>
+<footnote></footnote>

+ 0 - 0
public/app/article/templiates/reference.tpl


+ 0 - 0
public/app/article/templiates/term.tpl


+ 1 - 1
public/app/share/share.js

@@ -174,7 +174,7 @@ function username_search(keyword, type) {
 					for (const iterator of result) {
 						html +=
 							"<li onclick=\"user_selected('" +
-							iterator.uid +
+							iterator.id +
 							"','" +
 							iterator.username +
 							"',0)\">" +

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

@@ -232,7 +232,7 @@ switch ($op) {
 											$strXml, 
 											mTime(), 
 											mTime(), 
-											$channelInfo["status"], 
+											0, 
 											$_COOKIE['userid'],
 											$_COOKIE['uid']
 										);

+ 20 - 18
public/app/term/channal_list.php

@@ -166,24 +166,26 @@ foreach ($channal as $key => $value) {
         $arr_sent_final[] = $sent_final;
     }
     $channalInfo = $_channal->getChannal($key);
-	
-    $name = $_userinfo->getName($channalInfo["owner_uid"]);
-    $channalInfo["username"] = $name["username"];
-    $channalInfo["nickname"] = $name["nickname"];
-    $channalInfo["count"] = $value;
-    $channalInfo["all"] = count($_data);
-    $channalInfo["final"] = $arr_sent_final;
-	$channalInfo["article_len"] = $article_len;
-	$channalInfo["id"] = $key;
-	$channalInfo["owner"] = $channalInfo["owner_uid"];
-
-	if(isset($channel_power[$key])){
-		$channalInfo["power"] =$channel_power[$key];
-	}
-	else{
-		$channalInfo["power"] =10;
-	}
-    $output[] = $channalInfo;
+	if($channalInfo){
+        $name = $_userinfo->getName($channalInfo["owner_uid"]);
+        $channalInfo["username"] = $name["username"];
+        $channalInfo["nickname"] = $name["nickname"];
+        $channalInfo["count"] = $value;
+        $channalInfo["all"] = count($_data);
+        $channalInfo["final"] = $arr_sent_final;
+        $channalInfo["article_len"] = $article_len;
+        $channalInfo["id"] = $key;
+        $channalInfo["owner"] = $channalInfo["owner_uid"];
+
+        if(isset($channel_power[$key])){
+            $channalInfo["power"] =$channel_power[$key];
+        }
+        else{
+            $channalInfo["power"] =10;
+        }
+        $output[] = $channalInfo;        
+    }
+
 }
 
 $time = microtime(true);

+ 141 - 35
public/app/term/term_edit_dlg.js

@@ -7,7 +7,8 @@ function term_edit_dlg_init(title = gLocal.gui.dict_terms) {
 		outerHeight: "80vh",
 		buttons: [
 			{
-				text: gLocal.gui.save,
+                id:"term_edit_dlg_save",
+				text: gLocal.gui.submit,
 				click: function () {
 					term_edit_dlg_save();
 					$(this).dialog("close");
@@ -22,7 +23,10 @@ function term_edit_dlg_init(title = gLocal.gui.dict_terms) {
 		],
 	});
 }
-function term_edit_dlg_open(id = "", word = "",channel="",lang="") {
+/*
+obj:调用此函数的按钮的handle
+*/
+function term_edit_dlg_open(id = "", word = "",channel="",lang="",obj=null) {
 	if (id == "") {
 		let newWord = new Object();
 		newWord.guid = "";
@@ -33,7 +37,7 @@ function term_edit_dlg_open(id = "", word = "",channel="",lang="") {
 		newWord.note = "";
 		newWord.language = lang;
 		newWord.channel = channel;
-		let html = term_edit_dlg_render(newWord);
+		let html = term_edit_dlg_render(newWord,obj);
 		$("#term_edit_dlg_content").html(html);
 		$("#term_edit_dlg").dialog("open");
 	} else {
@@ -44,7 +48,7 @@ function term_edit_dlg_open(id = "", word = "",channel="",lang="") {
 			},
 			function (data) {
 				let word = JSON.parse(data);
-				let html = term_edit_dlg_render(word);
+				let html = term_edit_dlg_render(word,obj);
 				$("#term_edit_dlg_content").html(html);
 				$("#term_edit_dlg").dialog("open");
 			}
@@ -52,11 +56,11 @@ function term_edit_dlg_open(id = "", word = "",channel="",lang="") {
 	}
 }
 
-function term_edit_dlg_render(word = "") {
-	if (word == "") {
+function term_edit_dlg_render(word = null,obj=null) {
+	if (word == null) {
 		word = new Object();
 		word.guid = "";
-		word.word = pali;
+		word.word = "";
 		word.meaning = "";
 		word.other_meaning = "";
 		word.tag = "";
@@ -67,12 +71,21 @@ function term_edit_dlg_render(word = "") {
 	output += "<input type='hidden' id='term_edit_form_id' name='id' value='" + word.guid + "'>";
 	output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.spell + "</legend>";
-	output +=
-		"<input type='input' id='term_edit_form_word' name='word' value='" +
-		word.word +
-		"'placeholder=" +
-		gLocal.gui.required +
-		">";
+    if(word.guid === "" && word.word === ""){
+        //新建术语 而且词头为空 允许修改word 拼写
+            "<input type='input' id='term_edit_form_word' name='word' value='" +
+            word.word +
+            ">";  
+    }else{
+        output += "<div style='font-size:200%;font-weight:700;'>"+word.word+"</div>";
+        output +=
+            "<input type='hidden' id='term_edit_form_word' name='word' value='" +
+            word.word +
+            "'placeholder=" +
+            gLocal.gui.required +
+            ">";        
+    }
+
 	output += "</fieldset>";
 
 	output += "<fieldset>";
@@ -115,50 +128,135 @@ function term_edit_dlg_render(word = "") {
 		" >";
 	output += "</fieldset>";
 
+
+
 	output += "<fieldset>";
+	output += "<legend>" + gLocal.gui.encyclopedia + "</legend>";
+	output += "<textarea id='term_edit_form_note' name='note' placeholder=" + gLocal.gui.optional +	" style='height:5em;'>";
+	output += word.note ;
+	output += "</textarea>";
+	output += "</fieldset>";
+
+
+
+    output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.channel + "</legend>";
 
-	let currChannel=null;
+	let currChannel=null;//当前单词的channel
 	if(typeof word.channel == "undefined" && typeof word.channal != "undefined"){
 		word.channel = word.channal;
 	}
 	for (const iterator of _my_channal) {
-		if(iterator.id==word.channel){
+		if(iterator.uid==word.channel){
 			currChannel = iterator;
 		}
 	}
+    //查询术语所在句子的channel
+    let sentChannel=null;
+    let sentChannelId=null;
+    if(obj){
+        let sentObj = find_sent_tran_div(obj);
+        if(sentObj){
+            sentChannelId = sentObj.attr('channel');
+            for (const iterator of _my_channal) {
+                if(iterator.uid==sentChannelId){
+                    sentChannel = iterator;
+                }
+	        }
+        }
+    }
+    let style='display:none;';
+    if(word.guid === ''){
+        //新建术语 可以修改channel
+        style = 'display:block;';
+    }else{
+        //修改术语 不能修改channel
+        output +="<div>当前:" ;
+        if(word.channel === ''){
+            output += "通用于<b>所有版本</b>";
+            //判断是否只读
+            if(sentChannel.power !== 30){
+                output += "(只读)";
+            }
+        }else{
+            output += "仅使用于版本<b>";
+            if(currChannel !== null){
+                //我有写权限
+                output += currChannel.name;
+            }else{
+                //我没有写权限 设置按钮为disable
+                output += word.channel;
+                output += "(只读)";
+            }
+            output += "</b>";
+        }
 
+        output += "</div>";
+        output +="<div><input type='checkbox' name='save_as' onchange='term_save_as(this)' />另存为</div>";
+    }
+
+    output += "<div id='term_save_as_channel' style='"+style+"' >";
 	output += "<select id='term_edit_form_channal' name='channal'>";
-	if(currChannel !== null){
-		if(currChannel.owner == getCookie("user_uid")){
-			//是自己的
-			output += "<option value=''>通用于所有版本</option>";
-			
-		}
-		output += "<option value='"+currChannel.id+"'>仅用于"+currChannel.name+"</option>";
-	}else{
-		output += "<option value=''>通用于所有版本</option>";
-	}
-	/*
+    //TODO 句子channel 是我自己的才显示通用于所有版本
+    if(sentChannelId){
+        if(sentChannel && sentChannel.power==30){
+            output += "<option value=''>通用于我的所有版本</option>";
+        }
+    }else{
+        //术语不在句子里,也显示
+        output += "<option value=''>通用于我的所有版本</option>";
+    }
+    
+    
+    /*
+    按照当前的默认匹配逻辑,先匹配句子所在channel 里面的术语,没有才匹配通用的
+    所以如果此术语匹配到了channel 说明这个channel一定是这个句子的channel 
+    在这种情况下,如果没有在我的有写权限的channel列表中找到,这个句子channel一定是我没有写权限的。
+    */
+
+    //句子channel 我有写权限才显示仅用于此channel
+    let ignoreChannelId=null;
+    if(word.channel === ''){
+        if(sentChannel !== null){
+            output += "<option value='"+sentChannel.uid+"'>[本句版本]"+sentChannel.name+"</option>";
+            ignoreChannelId = sentChannel.uid;
+        }
+    }
+    if(word.guid==''){
+        //新建术语
+        for (const iterator of _my_channal) {
+            if(iterator.uid==word.channel){
+                //这句我有写权限
+                output += "<option value='"+word.channel+"'>[本句版本]"+iterator.name+"</option>";
+                ignoreChannelId = word.channel;
+            }
+        }
+    }
+
 	for (const iterator of _my_channal) {
-		if(word.channel=="" || (word.channel!="" && iterator.id==word.channel)){
-			output += "<option value='"+iterator.id+"'>仅用于"+iterator.name+"</option>";
+        if(currChannel && currChannel.uid==iterator.uid){
+            continue;
+        }
+        if(ignoreChannelId === iterator.uid){
+            continue;
+        }
+		if(word.channel=="" || (word.channel!="" && iterator.uid !== word.channel)){
+			output += "<option value='"+iterator.uid+"' onclick=\"set_term_dlg_channel_msg('此术语将仅仅用于这个版本')\">仅用于"+iterator.name+"</option>";
 		}
 	}
-	*/
+	
 	output += "</select>";
+    output += "<div class='msg' id='term_dlg_channel_msg'>只有选择<b>通用版本</b>或者<b>本句版本</b>才会应用到这个句子</div>";
+    output += "</div>";
 	output += "</fieldset>";
 
-	output += "<fieldset>";
-	output += "<legend>" + gLocal.gui.encyclopedia + "</legend>";
-	output += "<textarea id='term_edit_form_note' name='note' placeholder=" + gLocal.gui.optional +	">";
-	output += word.note ;
-	output += "</textarea>";
-	output += "</fieldset>";
 	output += "</form>";
 
 	return output;
 }
+function set_term_dlg_channel_msg(msg){
+    $("#term_dlg_channel_msg").text(msg);
+}
 function term_edit_dlg_save() {
 	$.ajax({
 		type: "POST", //方法类型
@@ -202,3 +300,11 @@ function term_edit_dlg_save() {
 		},
 	});
 }
+
+function term_save_as(obj){
+    if(obj.checked){
+        $("#term_save_as_channel").show();
+    }else{
+        $("#term_save_as_channel").hide();
+    }
+}

+ 1 - 1
public/app/term/term_popup.js

@@ -65,7 +65,7 @@ function note_lookup_guid_json(guid) {
           html +=
             "<button onclick=\"term_edit_dlg_open('" +
             result.guid +
-            "')\">修改</button>";
+            "','','','',this)\">修改</button>";
           html += "</div>";
           html += "</div>";
           $("[term-popup='" + guid + "']").html(html);

+ 18 - 9
public/app/term/term_post.php

@@ -24,9 +24,9 @@ if (isset($_COOKIE["userid"]) == false) {
 $respond = array("status" => 0, "message" => "");
 PDO_Connect( _FILE_DB_TERM_);
 
+$channelInfo = new Channal($redis);
 
-
-if ($_POST["id"] != "") {
+if ($_POST["id"] != "" && !isset($_POST['save_as'])) {
 	#更新
 	#先查询是否有权限
 	#是否这个术语的作者
@@ -38,7 +38,7 @@ if ($_POST["id"] != "") {
 		if($Fetch){
 			if($Fetch['owner']!=$_COOKIE["userid"]){
 				#不是这个术语的作者,查是否是channel的有编辑权限者	
-				$channelInfo = new Channal($redis);
+				
 				$channelPower = $channelInfo->getPower($Fetch['channal']);
 				if($channelPower<20){
 					$respond['status'] = 1;
@@ -56,12 +56,11 @@ if ($_POST["id"] != "") {
 			exit;				
 		}
 	}
-    $query = "UPDATE "._TABLE_TERM_." SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? ,  modify_time= ? , updated_at = now()  where guid= ? ";
+    $query = "UPDATE "._TABLE_TERM_." SET meaning= ? ,other_meaning = ? , tag= ? ,  language = ? , note = ? ,  modify_time= ? , updated_at = now()  where guid= ? ";
 	$stmt = @PDO_Execute($query, 
 						array($_POST["mean"],
         					  $_POST["mean2"],
         					  $_POST["tag"],
-        					  $_POST["channal"],
         					  $_POST["language"],
         					  $_POST["note"],
         					  mTime(),
@@ -112,11 +111,21 @@ if ($_POST["id"] != "") {
 		$stmt = $PDO->prepare($query);
 		$stmt->execute(array($_POST["word"],$_POST["language"],$_POST["tag"],$_COOKIE["userid"]));
 	}else{
+        #TODO 
 		$query = "SELECT id from "._TABLE_TERM_." where word= ? and channal=?  and tag=? and owner = ? ";
 		$stmt = $PDO->prepare($query);
 		$stmt->execute(array($_POST["word"],$_POST["channal"],$_POST["tag"],$_COOKIE["userid"]));
 	}
-	
+	if($_POST["channal"]==""){
+        $owner_uid = $_COOKIE["user_uid"];
+    }else{
+        $channel = $channelInfo->getChannal($_POST["channal"]);
+        if($channelInfo){
+            $owner_uid = $channel["owner_uid"];
+        }else{
+            $owner_uid = $_COOKIE["user_uid"];
+        }
+    }
 	if ($stmt) {
 		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
 		if($Fetch){
@@ -137,7 +146,7 @@ if ($_POST["id"] != "") {
         $_POST["channal"],
         $_POST["language"],
         $_POST["note"],
-        $_COOKIE["user_uid"],
+        $owner_uid,
         $_COOKIE["user_id"],
         mTime(),
         mTime()
@@ -170,8 +179,8 @@ if ($_POST["id"] != "") {
         $respond['message'] = $_POST["word"];
         $respond['data'] = [
             "id"=>$parm[0],
-            "guid"=>$parm[2],
-			"word"=>$parm[3],
+            "guid"=>$parm[1],
+			"word"=>$parm[2],
 			"word_en"=>$parm[3],
 			"meaning"=>$parm[4],
 			"other_meaning"=>$parm[5],

+ 1 - 1
public/app/uwbw/create_wbw.php

@@ -201,7 +201,7 @@ foreach ($_para as $key => $para) {
 				$strXml,
 				mTime(),
 				mTime(),
-				$channelInfo["status"],
+				0,
 				$_COOKIE["userid"],
 				$_COOKIE["uid"]
 			);

+ 4 - 3
public/app/uwbw/update.js

@@ -7,7 +7,7 @@ function user_wbw_push_word_element(xWord) {
 	let wId = wordid.split("-")[2];
 	let mWord = doc_word("#" + wordid);
 	let blockid = mWord.block.info("id");
-	user_wbw_push(blockid, wId, com_xmlToString(xWord));
+	user_wbw_push(blockid, wId, com_xmlToString(xWord),getNodeText(xWord,'status'));
 }
 
 function user_wbw_push_word(wordid) {
@@ -34,11 +34,11 @@ function user_wbw_push_word(wordid) {
 			}
 			wordData += com_xmlToString(xAllWord[i]);
 		}
-		user_wbw_push(blockid, wId, wordData);
+		user_wbw_push(blockid, wId, wordData,getNodeText(xAllWord[i],'status'));
 	}
 }
 
-function user_wbw_push(block_id, wid, data) {
+function user_wbw_push(block_id, wid, data,status=7) {
 	let d = new Date();
 	let objData = new Object();
 	objData.block_id = block_id;
@@ -47,6 +47,7 @@ function user_wbw_push(block_id, wid, data) {
 	objData.time = d.getTime();
 	objData.book = doc_block("#" + block_id).info("book");
 	objData.para = doc_block("#" + block_id).info("paragraph");
+	objData.status = status;
 	user_wbw_data_buffer.push(objData);
 }
 var commitTimes = 0;

+ 7 - 2
public/app/uwbw/update.php

@@ -48,12 +48,17 @@ if (count($aData) > 0) {
 
     /* 开始一个事务,关闭自动提交 */
     $PDO->beginTransaction();
-    $query = "UPDATE "._TABLE_USER_WBW_." SET data= ?  , editor_id = ? , modify_time= ? , updated_at = now()  where block_uid= ?  and wid= ?  ";
+    $query = "UPDATE "._TABLE_USER_WBW_." SET data= ?  , editor_id = ? , status = ?, modify_time= ? , updated_at = now()  where block_uid= ?  and wid= ?  ";
     $sth = $PDO->prepare($query);
 
     foreach ($aData as $data) {
 		if($listBlockId[$data->block_id]>=20){
-			$sth->execute(array($data->data, $_COOKIE['uid'], mTime(), $data->block_id, $data->word_id));
+            if(!isset($data->status) || empty($data->status)){
+                $status = 7;
+            }else{
+                $status = (int)$data->status;
+            }
+			$sth->execute(array($data->data, $_COOKIE['uid'], $status , mTime(), $data->block_id, $data->word_id));
 		}
     }
     $PDO->commit();

+ 1 - 1
v1/scripts/install4.sh

@@ -3,7 +3,7 @@
 date
 
 php ./migrations/20220205084100_group_info_copy.php
-php ./migrations/20220205092400_group_member.php
+php ./migrations/20220205092400_group_member_copy.php
 
 php ./migrations/20220206143600_fileindex_copy.php
 date