Explorar el Código

新建文档支持channal

visuddhinanda hace 5 años
padre
commit
ba9e4d028a

+ 40 - 42
app/public/js/notify.js

@@ -1,46 +1,44 @@
+var ntf_msg_list = new Array();
+var ntf_max_msg_line = 2;
+function ntf_init(lines = 5) {
+  ntf_max_msg_line = lines;
+  var divNotify = document.createElement("div");
+  var typ = document.createAttribute("class");
 
-	var ntf_msg_list =  new Array();
-	var ntf_max_msg_line = 5;
-	function ntf_init(){
-		var divNotify=document.createElement("div");
-		var typ=document.createAttribute("class");
-		
-		typ.nodeValue="pcd_notify";
-		divNotify.attributes.setNamedItem(typ);
+  typ.nodeValue = "pcd_notify";
+  divNotify.attributes.setNamedItem(typ);
 
-		var typId=document.createAttribute("id");
-		typId.nodeValue="id_pcd_notify";
-		divNotify.attributes.setNamedItem(typId);
+  var typId = document.createAttribute("id");
+  typId.nodeValue = "id_pcd_notify";
+  divNotify.attributes.setNamedItem(typId);
 
-		var body=document.getElementsByTagName("body")[0];
-		body.appendChild(divNotify);
-		divNotify.style.display="none";
-		
-	}
+  var body = document.getElementsByTagName("body")[0];
+  body.appendChild(divNotify);
+  divNotify.style.display = "none";
+}
 
-	function ntf_show(msg,timeout=8){
-		if(ntf_msg_list.length < ntf_max_msg_line){
-			ntf_msg_list.push(msg);
-		}
-		else{
-			for(let i=1 ; i < ntf_msg_list.length; i++){
-				ntf_msg_list[i-1] = ntf_msg_list[i];
-			}
-			ntf_msg_list[ntf_msg_list.length-1] = msg;
-		}
-		let divNotify=document.getElementById("id_pcd_notify");
-		if(divNotify){
-			let strHtml = "";
-			for(const strMsg of ntf_msg_list){
-				strHtml += "<div class='ntf_msg_div'>";
-				strHtml += strMsg;
-				strHtml += "</div>";
-			}
-			divNotify.innerHTML = strHtml;
-			divNotify.style.display = "block";
-			setTimeout("ntf_hide()",timeout*1000);
-		}
-	}
-	function ntf_hide(){
-	document.getElementById('id_pcd_notify').style.display='none';
-	}
+function ntf_show(msg, timeout = 8) {
+  if (ntf_msg_list.length < ntf_max_msg_line) {
+    ntf_msg_list.push(msg);
+  } else {
+    for (let i = 1; i < ntf_msg_list.length; i++) {
+      ntf_msg_list[i - 1] = ntf_msg_list[i];
+    }
+    ntf_msg_list[ntf_msg_list.length - 1] = msg;
+  }
+  let divNotify = document.getElementById("id_pcd_notify");
+  if (divNotify) {
+    let strHtml = "";
+    for (const strMsg of ntf_msg_list) {
+      strHtml += "<div class='ntf_msg_div'>";
+      strHtml += strMsg;
+      strHtml += "</div>";
+    }
+    divNotify.innerHTML = strHtml;
+    divNotify.style.display = "block";
+    setTimeout("ntf_hide()", timeout * 1000);
+  }
+}
+function ntf_hide() {
+  document.getElementById("id_pcd_notify").style.display = "none";
+}

+ 3 - 1
app/studio/dict_find_auto.php

@@ -191,7 +191,9 @@ for($i=0;$i<$lookup_loop;$i++)
 				else{
 					$partmean = "";
 				}
-				
+				if(inLangSetting($one["lang"],$user_setting["dict.lang"])==false){
+					$partmean = "";
+				}
 				if(isset($one["part_id"])){
 					$part_id = $one["part_id"];
 				}

+ 3 - 0
app/studio/dict_find_one.php

@@ -161,6 +161,9 @@ for($i=0;$i<$lookup_loop;$i++)
 				else{
 					$partmean = "";
 				}
+				if(inLangSetting($one["lang"],$user_setting["dict.lang"])==false){
+					$partmean = "";
+				}
 				$status = $one["status"];
 				if(isset($one["confidence"])){
 					$confidence = $one["confidence"];

+ 106 - 18
app/studio/project.php

@@ -18,6 +18,9 @@ require_once "../public/function.php";
 require_once "../public/load_lang.php";
 require_once "./book_list_en.inc";
 require_once "../ucenter/function.php";
+require_once "../ucenter/setting_function.php";
+
+$user_setting = get_setting();
 
 $sLang["1"]="pali";
 $sLang["2"]="en";
@@ -157,9 +160,22 @@ switch($op){
 								$title="";
 							}
 							$block_id=UUID::v4();
-							$block_data[] = array($block_id,"",$USER_ID,$book,$iPar,"_none_","zh-cn",1);
-							$block_list[] = array("type"=>6,"block_id"=>$block_id);
-
+							$trans_block_id = UUID::v4();
+							$block_data[] = array($block_id,"",$_POST["channal"],$USER_ID,$book,$iPar,"_none_",$_POST["lang"],1);
+							$block_list[] = array("channal"=>$_POST["channal"],
+															"type"=>6,//word by word
+															"book"=>$res_book,
+															"paragraph"=>$iPar,
+															"block_id"=>$block_id,
+															"readonly"=>false
+														);
+														/*
+							$block_list[] = array("channal"=>$_POST["channal"],
+														"type"=>2,//translation
+														"book"=>$res_book,
+														"paragraph"=>$iPar,
+														"readonly"=>false
+													);*/
 						while($result = $sth->fetch(PDO::FETCH_ASSOC))
 						{
 							if($result["gramma"]=="?"){
@@ -185,9 +201,7 @@ switch($op){
 							$strXml.="</word>";
 							$wbw_data[] = array(UUID::v4(),$block_id,$book,$iPar,$result["wid"],$result["real"],$strXml,mTime(),mTime(),1,$USER_NAME);
 						}
-							
 						}
-							
 					}
 					
 					//写入数据库
@@ -195,7 +209,7 @@ switch($op){
 
 					PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
 					$PDO->beginTransaction();
-					$query="INSERT INTO wbw_block ('id','parent_id','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?)";
+					$query="INSERT INTO wbw_block ('id','parent_id','channal','owner','book','paragraph','style','lang','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?)";
 					$stmt = $PDO->prepare($query);
 					foreach($block_data as $oneParam){
 						$stmt->execute($oneParam);
@@ -235,6 +249,7 @@ switch($op){
 					PDO_Connect("sqlite:$db_file");
 					$query="INSERT INTO fileindex ('id',
 												'parent_id',
+												'channal',
 												'user_id',
 												'book',
 												'paragraph',
@@ -251,13 +266,14 @@ switch($op){
 												'doc_block',
 												'receive_time'
 												) 
-									VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+									VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
 					$stmt = $PDO->prepare($query);
 					$doc_id=UUID::v4();
 					$file_name = $book . '_' . $create_para . '_' . time();
 					$newData=array(
 								   $doc_id,
 								   "",
+								   $_POST["channal"],
 								   $uid,
 								   $book,
 								   $create_para,
@@ -311,24 +327,99 @@ switch($op){
 		$strQueryParaList=str_replace(",","','",$paraList);
 		$strQueryParaList="('".$strQueryParaList."')";
 		$aParaList=str_getcsv($paraList);
+		echo "<div style='display:none;'>";
 		echo $strQueryParaList;
 		echo "<textarea>";
 		print_r($res);
 		echo "</textarea>";
+		echo "</div>";
 		if(!isset($_POST["title"])){
 			$thisFileName=basename(__FILE__);
 			echo "<div class='fun_block'>";
-			echo "<h2>新建工程</h2>";
+			echo "<h2>New Document 新建文档</h2>";
 			echo "<form action=\"{$thisFileName}\" method=\"post\">";
 			echo "<input type='hidden' name='op' value='{$op}'/>";
 			echo "<input type='hidden' name='data' value='{$data}'/>";
-			echo "Project Title:<input type='input' name='title' value='{$title}'/><br>";
-			echo "<input type=\"checkbox\" name='new_tran' />自动新建译文<br>";
-			echo "<input type=\"submit\" value='Load'>";
-			echo "<select name='format'>";
-			echo "<option value='db'>".$_local->gui->database."</option>";
-			echo "<option value='file'>file</option>";
+			
+			echo "<fieldset>";
+			echo "<legend>Title 文档标题(必填)</legend>";
+			echo "<div>";
+			echo "<input type='input' name='title' value='{$title}'/>";
+			echo "</div>";
+			echo "</fieldset>";
+			echo "<fieldset>";
+			echo "<legend>Channal 频道(必填)</legend>";
+			echo "<div>";
+			PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
+			$query = "select * from channal where owner = '{$_COOKIE["userid"]}'   limit 0,100";
+			$Fetch = PDO_FetchAll($query);
+			$i=0;
+			foreach($Fetch as $row){
+				echo '<div class="file_list_row" style="padding:5px;">';
+			
+				echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+				echo '<input name="channal" value="'.$row["id"].'" ';
+				if($i==0){
+					echo "checked";
+				}
+				echo ' type="radio" />';
+				echo '</div>';
+				echo '<div class="title" style="flex:3;padding-bottom:5px;">'.$row["name"].'</div>';
+				echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+				PDO_Connect("sqlite:"._FILE_DB_USER_WBW_);
+				$query = "select count(*) from wbw_block where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
+				$FetchWBW = PDO_FetchOne($query);
+				echo '</div>';
+				echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+				if($FetchWBW==0){
+					echo "空白";
+				}
+				else{
+					echo $FetchWBW."个段落";
+				}
+				echo '</div>';
+
+				echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+				PDO_Connect("sqlite:"._FILE_DB_SENTENCE_);
+				$query = "select count(*) from sentence where channal = '{$row["id"]}' and book='{$book}' and paragraph in {$strQueryParaList}  limit 0,100";
+				$FetchWBW = PDO_FetchOne($query);
+				echo '</div>';
+				echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+				if($FetchWBW==0){
+					echo "空白";
+				}
+				else{
+					echo $FetchWBW."个段落";
+				}
+				echo '</div>';
+
+				echo '<div class="summary"  style="flex:1;padding-bottom:5px;">'.$row["status"].'</div>';
+				echo '<div class="author"  style="flex:1;padding-bottom:5px;">'.$row["create_time"].'</div>';
+				
+				echo '</div>';
+				$i++;
+			}
+			echo '<div class="file_list_row" style="padding:5px;">';
+			
+			echo '<div class="pd-10"  style="max-width:2em;flex:1;">New Channal 新建频道</div>';
+			echo '<div class="title" style="flex:3;padding-bottom:5px;">';
+			echo '<input type="input" placeholder="Channal Title"></div>';
+			echo '<div class="author"  style="flex:1;padding-bottom:5px;"><button>New 新建</button></div>';
+			
+			echo '</div>';
+			echo "</div>";
+			echo "</fieldset>";
+			echo "<fieldset>";
+			echo "<legend>Language 语言</legend>";
+			echo "<select name='lang'>";
+			foreach ($user_setting['studio.translation.lang'] as $key => $value) {
+				echo "<option value='{$value}'>".$value."</option>";
+			}
+			
 			echo "</select>";
+			echo "</fieldset>";
+			echo "<input type=\"submit\" value='Create 建立'>";
+			echo "<input type='hidden' name='format' value='db'>";
 			echo "</form>";
 			echo "</div>";
 			echo "</body>";
@@ -513,7 +604,6 @@ switch($op){
 					}
 					break;
 				}
-			
 				case "3"://translate
 				{
 					//打开翻译数据文件
@@ -567,9 +657,7 @@ switch($op){
 					//输出数据内容					
 					$par_text="";
 					foreach($aParaText as $sent){
-						$par_text .= "<sen><begin>{$sent["begin"]}</begin>
-									<end>{$sent["end"]}</end>
-									<text>{$sent["text"]}</text></sen>";
+									$par_text .= "<sen><begin>{$sent["begin"]}</begin><end>{$sent["end"]}</end><text>{$sent["text"]}</text></sen>";
 					}
 					fwrite($myfile, $par_text);
 					//段落块结束

+ 4 - 4
app/studio/project_load_db.php

@@ -42,8 +42,8 @@ if(count($Fetch)>0){
 				echo "<paragraph>{$FetchBlock[0]["paragraph"]}</paragraph>";
 				echo "<level>100</level>";
 				echo "<title>title</title>";
-				echo "<album_id>1</album_id>";
-				echo "<album_guid>{$albumId}</album_guid>";
+				echo "<album_id>{$block->channal}</album_id>";
+				echo "<album_guid>{$block->channal}</album_guid>";
 				echo "<author>{$FetchBlock[0]["owner"]}</author>";
 				echo "<language>{$FetchBlock[0]["lang"]}</language>";
 				echo "<version>1</version>";
@@ -77,8 +77,8 @@ if(count($Fetch)>0){
 					echo "<paragraph>{$FetchBlock[0]["paragraph"]}</paragraph>";
 					echo "<level>100</level>";
 					echo "<title>title</title>";
-					echo "<album_id>1</album_id>";
-					echo "<album_guid>{$albumId}</album_guid>";
+					echo "<album_id>{$block->channal}</album_id>";
+					echo "<album_guid>{$block->channal}</album_guid>";
 					echo "<author>{$FetchBlock[0]["author"]}</author>";
 					echo "<editor>{$FetchBlock[0]["editor"]}</editor>";
 					echo "<language>{$FetchBlock[0]["lang"]}</language>";

+ 1 - 1
app/ucenter/setting.js

@@ -112,7 +112,7 @@ function setting_save() {
       data: JSON.stringify(setting),
     },
     function (data, status) {
-      alert(data);
+      ntf_show(data);
     }
   );
 }

+ 9 - 1
app/ucenter/setting.php

@@ -12,13 +12,15 @@ require_once '../public/function.php';
 	<link type="text/css" rel="stylesheet" href="../studio/css/font.css"/>
 	<link type="text/css" rel="stylesheet" href="../pcdl/css/reader.css"/>
 	<link type="text/css" rel="stylesheet" href="../pcdl/css/reader_mob.css" media="screen and (max-width:767px)">
-	<title id="page_title">PCD Reader</title>
+	<link type="text/css" rel="stylesheet" href="../public/css/notify.css"/>
+	<title id="page_title">Setting</title>
 
 	<script src="../public/js/jquery-3.5.1.js"></script>
 	<script src="../public/js/fixedsticky.js"></script>
 	<script src="./setting.js"></script>
 	<script src="../lang/lang.js"></script>
 	<script src="../public/js/comm.js"></script>
+	<script src="../public/js/notify.js"></script>
 	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
 
 </head>
@@ -33,6 +35,10 @@ if(!isset($_COOKIE["userid"])){
 
 
 <style>
+.pcd_notify{
+	margin-left: 20em;
+	background-color: rgb(201 137 15 / 64%);
+}
 		#para_nav {
 			display: flex;
 			justify-content: space-between;
@@ -266,6 +272,8 @@ para:hover{
 <script>
 $(document).ready(setting_onload);
 
+ntf_init(1);
+
 function setNaviVisibility(strObjId = "") {
     var objNave = document.getElementById("leftmenuinner");
     var objblack = document.getElementById("BV");

+ 1 - 1
app/ucenter/user.php

@@ -71,7 +71,7 @@
 				<div id="user_info_name"><?php echo $_COOKIE["nickname"];?></div>
 				<div id="user_info_welcome2"><?php echo $_local->gui->to_the_dhamma;?></div>
 				</div>
-				<a href="../studio/setting.php" target="_blank">
+				<a href="../ucenter/setting.php" target="_blank">
 					<span>
 					<svg class="icon">
 						<use xlink:href="../studio/svg/icon.svg#ic_settings"></use>