소스 검색

在editor里打开一个段落

visuddhinanda 5 년 전
부모
커밋
712f091c88
6개의 변경된 파일147개의 추가작업 그리고 46개의 파일을 삭제
  1. 93 0
      app/doc/load_channal_para.php
  2. 1 1
      app/studio/js/data.js
  3. 42 16
      app/studio/js/editor.js
  4. 8 26
      app/studio/module/editor_dictionary/gui.html
  5. 2 2
      app/studio/plugin/system_layout/gui.html
  6. 1 1
      app/studio/project.php

+ 93 - 0
app/doc/load_channal_para.php

@@ -0,0 +1,93 @@
+<?php
+/*
+get xml doc from db
+*/
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+
+if(isset($_POST["book"])){
+	$book=$_POST["book"];
+}
+else{
+	echo "error: no book id";
+	exit;
+}
+
+if(isset($_POST["para"])){
+	$paralist=explode(",",$_POST["para"]);
+}
+else{
+	exit;
+}
+
+if(isset($_POST["channal"])){
+	$channal=$_POST["channal"];
+}
+else{
+	exit;
+}
+
+	echo '<?xml version="1.0" encoding="UTF-8"?>';
+	echo "<set>\n";
+	echo "    <head>\n";
+	echo "        <type>pcdsset</type>\n";
+	echo "        <mode>package</mode>\n";
+	echo "        <ver>1</ver>\n";
+	echo "        <toc></toc>\n";
+	echo "        <style></style>\n";
+	echo "        <title>{$book}-{$para}</title>\n";
+	echo "    </head>\n";
+	echo "\n<dict></dict>\n";
+	echo "<message></message>\n";
+	echo "<body>\n";
+	
+	$dh_wbw = new PDO("sqlite:"._FILE_DB_USER_WBW_, "", "",array(PDO::ATTR_PERSISTENT=>true));
+    $dh_wbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+	
+	foreach($paralist as $para){
+
+				$albumId = UUID::v4();
+				$query="SELECT * FROM wbw_block WHERE channal=? AND book = ? AND paragraph = ?  ";
+				$stmt = $dh_wbw->prepare($query);
+				$stmt->execute(array($channal,$book,$para));
+				$FetchBlock = $stmt->fetch(PDO::FETCH_ASSOC);
+				if($FetchBlock){
+					echo "\n<block>";
+					echo "<info>\n";
+					
+					echo "<type>wbw</type>";
+					echo "<book>{$book}</book>";
+					echo "<paragraph>{$para}</paragraph>";
+					echo "<level>100</level>";
+					echo "<title></title>";
+					echo "<album_id>{$block->channal}</album_id>";
+					echo "<album_guid>{$block->channal}</album_guid>";
+					echo "<author>{$FetchBlock["owner"]}</author>";
+					echo "<language>{$FetchBlock["lang"]}</language>";
+					echo "<version>1</version>";
+					echo "<edition>1</edition>";
+					echo "<id>{$FetchBlock["id"]}</id>";
+					echo "</info>\n";		
+
+					echo "<data>\n";
+					$block_id = $FetchBlock["id"];
+					$query="select * from wbw where block_id= ? ";
+					$stmt = $dh_wbw->prepare($query);
+					$stmt->execute(array($block_id));
+					$wbw_data = $stmt->fetchAll(PDO::FETCH_ASSOC);
+					foreach($wbw_data as $word){
+						echo $word["data"];	
+						echo "\r\n";	
+					}
+					echo "</data>";
+					echo "</block>\n";
+				}
+
+	}
+				
+	echo "</body>\n";
+	echo "</set>";
+
+
+?>

+ 1 - 1
app/studio/js/data.js

@@ -46,7 +46,7 @@ function doc_commit() {
 }
 
 function createXmlDoc() {
-  var strXml = "";
+  let strXml = '<?xml version="1.0" encoding="UTF-8"?>';
   strXml += "<set>\n";
   strXml += "    <head>\n";
   strXml += "        <type>pcdsset</type>\n";

+ 42 - 16
app/studio/js/editor.js

@@ -29,6 +29,9 @@ var g_fileid = 0;
 var g_docid = "";
 
 var g_op = "";
+var g_book = "";
+var g_para = "";
+var g_channal = "";
 
 var gCurrModifyWindowParNo = -1;
 
@@ -191,9 +194,9 @@ function editor_windowsInit() {
 	var strSertch = location.search;
 	if (strSertch.length > 0) {
 		strSertch = strSertch.substr(1);
-		var sertchList = strSertch.split('&');
-		for (x in sertchList) {
-			var item = sertchList[x].split('=');
+		let sertchList = strSertch.split('&');
+		for (const param of sertchList) {
+			let item = param.split('=');
 			switch (item[0]) {
 				case "filename":
 					g_filename = item[1];
@@ -207,8 +210,16 @@ function editor_windowsInit() {
 				case "op":
 					g_op = item[1];
 					break;
-
-			}
+				case "book":
+					g_book = item[1];
+					break;
+				case "para":
+					g_para = item[1];
+					break;
+				case "channal":
+					g_channal = item[1];
+					break;
+			}			
 		}
 	}
 	checkCookie();
@@ -252,7 +263,9 @@ function editor_windowsInit() {
 				alert("no doc id");
 			}
 			break;
-
+		case "openchannal":
+				editor_openChannal(g_book,g_para,g_channal);
+			break;
 		case "import":
 			if (g_filename.length > 0) {
 				editor_importOldVer(g_filename)
@@ -3768,7 +3781,19 @@ function setHeadingInfo(id, objValue) {
 	}
 }
 
-
+function editor_openChannal(book,para,channal) {
+	$.post(
+		"../doc/load_channal_para.php",
+		{
+			book:book,
+			para:para,
+			channal:channal,
+		},
+		function(data) {
+			editor_parse_doc_xml(data);
+		}
+	);
+}
 //open project begin
 var editor_openProjectXmlHttp = null;
 function editor_openProject(strFileId, filetype) {
@@ -3800,12 +3825,7 @@ function editor_openProject(strFileId, filetype) {
 
 }
 
-function editor_open_project_serverResponse() {
-	// 4 = "loaded"
-	if (editor_openProjectXmlHttp.readyState == 4) {
-		if (editor_openProjectXmlHttp.status == 200) {// 200 = "OK"
-			var xmlText = editor_openProjectXmlHttp.responseText;
-
+function editor_parse_doc_xml(xmlText) {
 			if (window.DOMParser) {
 				parser = new DOMParser();
 				gXmlBookData = parser.parseFromString(xmlText, "text/xml");
@@ -3834,18 +3854,24 @@ function editor_open_project_serverResponse() {
 			else {
 				msg_init(1);
 			}
-
-
 			updataDocParagraphList();
 			updataToc();
 			//渲染数据块
 			blockShow(0);
 			refreshResource()
 			editro_layout_loadStyle();
+}
 
+function editor_open_project_serverResponse() {
+	// 4 = "loaded"
+	if (editor_openProjectXmlHttp.readyState == 4) {
+		if (editor_openProjectXmlHttp.status == 200) {
+			// 200 = "OK"
+			var xmlText = editor_openProjectXmlHttp.responseText;
+			editor_parse_doc_xml(xmlText);
 		}
 		else {
-			document.getElementById('sutta_text').innerHTML = "Problem retrieving data:" + editor_openProjectXmlHttp.statusText;
+			$('#sutta_text').html("Problem retrieving data:" + editor_openProjectXmlHttp.statusText);
 		}
 	}
 }

+ 8 - 26
app/studio/module/editor_dictionary/gui.html

@@ -1,8 +1,8 @@
 <div class="menu" id="menu_dict">
-	<h1><?php echo $module_gui_str['editor_dictionary']['1001']; ?></h1>
+	<h1></h1>
 	<div class="submenu">
 		<p class="submenu_title" onclick="submenu_show_detail(this)">
-			<?php echo $module_gui_str['editor_dictionary']['1002']; ?>
+			
 			<svg class="icon">
 				<use xlink:href="svg/icon.svg#ic_add"></use>
 			</svg>
@@ -10,39 +10,24 @@
 		<div class="submenu_details">
 			<div>
 				<a href="dictadmin/user/phpliteadmin.php"
-					target="user_dict_admin"><?php echo $module_gui_str['editor_dictionary']['1009']; ?></a><br>
+					target="user_dict_admin"></a><br>
 				<a href="dictadmin/system/phpliteadmin.php"
-					target="system_dict_admin"><?php echo $module_gui_str['editor_dictionary']['1010']; ?></a><br>
+					target="system_dict_admin"></a><br>
 				<a href="dictadmin/3rd/phpliteadmin.php"
-					target="3rd_dict_admin"><?php echo $module_gui_str['editor_dictionary']['1011']; ?></a><br>
+					target="3rd_dict_admin"></a><br>
 				<button type="button"
-					onclick="uploadAllWordData()"><?php echo $module_gui_str['editor_dictionary']['1012']; ?></button>
+					onclick="uploadAllWordData()"></button>
 			</div>
 		</div>
 	</div>
 
 	<div class="submenu">
 		<p class="submenu_title" onclick="submenu_show_detail(this)">
-			<?php echo $module_gui_str['editor_dictionary']['1003']; ?>
 			<svg class="icon">
 				<use xlink:href="svg/icon.svg#ic_add"></use>
 			</svg>
 		</p>
 		<div class="submenu_details">
-			<?php	
-	//获取服务器端文件列表
-	$dir="../tmp/user/$userid/my_document/";
-	$files = scandir($dir);
-	$arrlength=count($files);
-	for($x=0;$x<$arrlength;$x++) {
-		if(is_file($dir.$files[$x])){
-			$exeName=mb_substr($files[$x],-4,NULL,"UTF-8");
-			if($exeName==".pcs"){
-			echo "<a onclick=menu_file_import_wbw('".$files[$x]."')>".$files[$x].'</a><br />';
-			}
-		}
-	}
-	?>
 			<span id="id_load_dict_from_WBW_msg_inner"></span>
 		</div>
 
@@ -50,18 +35,15 @@
 
 	<div class="submenu">
 		<p class="submenu_title" onclick="submenu_show_detail(this)">
-			<?php echo $module_gui_str['editor_dictionary']['1004']; ?>
 			<svg class="icon">
 				<use xlink:href="svg/icon.svg#ic_add"></use>
 			</svg>
 		</p>
 		<div class="submenu_details">
 			<button type="button"
-				onclick="menu_file_export_ild()"><?php echo $module_gui_str['editor_dictionary']['1007']; ?></button>
+				onclick="menu_file_export_ild()">export</button>
 			<button type="button"
-				onclick="menu_file_import_ild()"><?php echo $module_gui_str['editor_dictionary']['1008']; ?></button>
-			<button type="button"
-				onclick="project_res_ild_remove()"><?php echo $module_gui_str['editor_dictionary']['1020']; ?></button>
+				onclick="menu_file_import_ild()">import</button>
 			<span id="id_ild_msg_inner"></span>
 		</div>
 

+ 2 - 2
app/studio/plugin/system_layout/gui.html

@@ -27,8 +27,8 @@
 							<li><input type="checkbox" checked id="id_layout_sandhi_word" onclick="editSandhiDisplay('word',this)" /><?php echo $module_gui_str['editor_layout']['1010']; ?></li>
 							<li><input type="checkbox" checked id="id_layout_sandhi_parent" onclick="editSandhiDisplay('parent',this)" /><?php echo $module_gui_str['editor_layout']['1011']; ?></li>
 							<li><input type="checkbox" id="id_layout_sandhi_combin" /><?php echo $module_gui_str['editor_layout']['1012']; ?></li>
-							<li><input type="checkbox" checked id="id_layout_sandhi_word" onclick="editSandhiDisplay('comp_word',this)" /><?php echo $module_gui_str['editor_layout']['1013']; ?></li>
-							<li><input type="checkbox" checked id="id_layout_sandhi_parent" onclick="editSandhiDisplay('comp_parent',this)" /><?php echo $module_gui_str['editor_layout']['1014']; ?></li>
+							<li><input type="checkbox" checked id="id_layout_sandhi_word" onclick="editSandhiDisplay('comp_word',this)" /><?php echo "sandhi_word"; ?></li>
+							<li><input type="checkbox" checked id="id_layout_sandhi_parent" onclick="editSandhiDisplay('comp_parent',this)" /><?php echo "sandhi_parent"; ?></li>
 						</ul>
 					</div>
 				</div>		

+ 1 - 1
app/studio/project.php

@@ -378,7 +378,7 @@ switch($op){
 				}
 				else{
 					echo $FetchWBW.$_local->gui->para;
-					echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}'>open</a>";
+					echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
 				}
 				echo '</div>';