Browse Source

百科显示channal

visuddhinanda 5 years ago
parent
commit
6b89c9f451
7 changed files with 209 additions and 9 deletions
  1. 1 0
      app/pcdl/reader.php
  2. 74 0
      app/term/channal_list.php
  3. 73 0
      app/term/note.js
  4. 22 2
      app/term/note.php
  5. 2 1
      app/term/term.js
  6. 5 0
      app/wiki/wiki.js
  7. 32 6
      app/wiki/wiki.php

+ 1 - 0
app/pcdl/reader.php

@@ -1080,6 +1080,7 @@ function render_sent($sent_data,$sn,$display_mode,$sent_count,$class=""){
 			else{
 				$user=null;
 			}
+			
 			echo "<div class='list_with_head'>";
 
 			echo "<div class='head'>";

+ 74 - 0
app/term/channal_list.php

@@ -0,0 +1,74 @@
+<?php
+require_once "../public/function.php";
+require_once "../path.php";
+require_once '../channal/function.php';
+require_once '../ucenter/function.php';
+
+
+
+$_data = array();
+$output = array();
+if(isset($_POST["data"])){
+	$_data = json_decode($_POST["data"],true);
+}
+else{
+    echo json_encode($output, JSON_UNESCAPED_UNICODE);
+    exit;
+}
+
+$_userinfo = new UserInfo();
+$_channal = new Channal();
+
+$dns = "sqlite:"._FILE_DB_SENTENCE_;
+$db_trans_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$db_trans_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+
+$channal = array();
+
+foreach ($_data as $key => $value) {
+	# code...
+	$id = $value["id"];
+	$arrInfo = str_getcsv($value["data"],"@");
+	$arrSent = str_getcsv($arrInfo[0],"-");
+	$bookId=$arrSent[0];
+	$para=$arrSent[1];
+	$begin=$arrSent[2];
+	$end=$arrSent[3];
+
+	//find out translation
+	$tran="";
+	try{
+		$query="SELECT channal FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  group by channal  limit 0 ,20 ";
+		$stmt = $db_trans_sent->prepare($query);
+		$stmt->execute(array($bookId,$para,$begin,$end));
+		$Fetch = $stmt->fetchAll(PDO::FETCH_ASSOC);
+		foreach ($Fetch as $key => $value) {
+            # code...
+            if(!empty($value["channal"])){
+                $channal[$value["channal"]] = 1;
+            }
+            
+        }
+	}
+	catch (Exception $e) {
+		$tran = $e->getMessage();
+		//echo 'Caught exception: ',  $e->getMessage(), "\n";
+	}
+	
+
+
+}
+
+foreach ($channal as $key => $value) {
+    # code...
+    $channalInfo = $_channal->getChannal($key);
+    $name = $_userinfo->getName($channalInfo["owner"]);
+    $channalInfo["username"] = $name["username"];
+    $channalInfo["nickname"] = $name["nickname"];
+    $output[]= $channalInfo;
+}
+
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 73 - 0
app/term/note.js

@@ -66,9 +66,13 @@ function note_refresh_new() {
       }
     }
     {
+      let setting = new Object();
+      setting.lang = "";
+      setting.channal = _channal;
       $.post(
         "../term/note.php",
         {
+          setting: JSON.stringify(setting),
           data: JSON.stringify(arrSentInfo),
         },
         function (data, status) {
@@ -82,6 +86,7 @@ function note_refresh_new() {
               }
               note_ref_init();
               term_get_dict();
+              note_channal_list();
             } catch (e) {
               console.error(e);
             }
@@ -91,6 +96,74 @@ function note_refresh_new() {
     }
   }
 }
+
+function note_channal_list() {
+  let objNotes = document.querySelectorAll("note");
+  let arrSentInfo = new Array();
+  for (const iterator of objNotes) {
+    {
+      let info = iterator.getAttributeNode("info").value;
+      if (info && info != "") {
+        arrSentInfo.push({ id: "", data: info });
+      }
+    }
+    {
+      $.post(
+        "../term/channal_list.php",
+        {
+          setting: "",
+          data: JSON.stringify(arrSentInfo),
+        },
+        function (data, status) {
+          if (status == "success") {
+            try {
+              let arrData = JSON.parse(data);
+              let strHtml = "";
+              for (const iterator of arrData) {
+                strHtml = render_channal_list(iterator);
+              }
+              $("#channal_list").html(strHtml);
+            } catch (e) {
+              console.error(e);
+            }
+          }
+        }
+      );
+    }
+  }
+}
+
+function render_channal_list(channalinfo) {
+  let output = "";
+  output += "<div class='list_with_head'>";
+
+  output += "<div class='head'>";
+  output += "<span class='head_img'>";
+  output += channalinfo.nickname.slice(0, 2);
+  output += "</span>";
+  output += "</div>";
+
+  output += "<div>";
+
+  output += "<div>";
+  output += "<a href='../wiki/wiki.php?word=" + _word;
+  output += "&channal=" + channalinfo.id + "' >";
+
+  output += channalinfo["nickname"];
+  output += "/" + channalinfo["name"];
+
+  output += "</a>";
+  output += "</div>";
+
+  output += "<div>";
+  output += "@" + channalinfo["username"];
+  output += "</div>";
+
+  output += "</div>";
+  output += "</div>";
+  return output;
+}
+
 function note_ref_init() {
   $("chapter").click(function () {
     let bookid = $(this).attr("book");

+ 22 - 2
app/term/note.php

@@ -24,6 +24,15 @@ else{
 	}
 	$_data[] = array("id"=>$id,"data"=>$info);
 }
+
+if(isset($_POST["setting"])){
+	$_setting = json_decode($_POST["setting"],true);
+}
+else{
+	$_setting["lang"] = "";
+	$_setting["channal"] = "";
+}
+
 $dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
 $db_pali_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 $db_pali_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
@@ -57,9 +66,20 @@ foreach ($_data as $key => $value) {
 	//find out translation
 	$tran="";
 	try{
-		$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0 order by modify_time DESC limit 0 ,1 ";
+		if(!empty($_setting["channal"])){
+			$queryChannal = " AND channal = ? ";
+		}
+		else{
+			$queryChannal ="";
+		}
+		$query="SELECT * FROM sentence WHERE book= ? AND paragraph= ? AND begin= ? AND end= ?  AND strlen >0  $queryChannal order by modify_time DESC limit 0 ,1 ";
 		$stmt = $db_trans_sent->prepare($query);
-		$stmt->execute(array($bookId,$para,$begin,$end));
+		if(empty($_setting["channal"])){
+			$stmt->execute(array($bookId,$para,$begin,$end));
+		}
+		else{
+			$stmt->execute(array($bookId,$para,$begin,$end,$_setting["channal"]));
+		}
 		$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
 		if($Fetch){
 			$tran = $Fetch["text"];

+ 2 - 1
app/term/term.js

@@ -264,7 +264,8 @@ function term_get_word_to_div(strWord, div, callback) {
 
           html += '<div class="fun_frame">';
           html += '<div class="title">Translation</div>';
-          html += '<div class="content" style="max-height:10em;">';
+          html +=
+            '<div id="channal_list"  class="content" style="max-height:10em;">';
           html += '<div><a href="">All</a></div>';
           html += "</div>";
           html += "</div>";

+ 5 - 0
app/wiki/wiki.js

@@ -14,6 +14,11 @@ function wiki_load(word){
   });
 }
 */
+
+var _word = "";
+var _channal = "";
+var _lang = "";
+var _author = "";
 function wiki_index_init() {}
 
 function wiki_load_id(guid) {

+ 32 - 6
app/wiki/wiki.php

@@ -1,5 +1,5 @@
 <?php
-require_once "../public/_pdo.php";
+require_once "../public/load_lang.php";
 require_once "../path.php";
 
 if(isset($_GET["id"])){
@@ -30,6 +30,22 @@ echo "wiki_load_word('{$_get_word}')";
 	<script src="../term/term.js"></script>
 	<script src="../term/note.js"></script>
 	<script src="wiki.js"></script>
+	<script>
+	<?php
+	if(isset($_GET["word"])){
+		echo "_word='".$_GET["word"]."';";
+	}
+	if(isset($_GET["channal"])){
+		echo "_channal='".$_GET["channal"]."';";
+	}
+	if(isset($_GET["lang"])){
+		echo "_lang='".$_GET["lang"]."';";
+	}
+	if(isset($_GET["author"])){
+		echo "_author='".$_GET["author"]."';";
+	}
+	?>
+	</script>
 	<style>
 	.term_link,.term_link_new{
 		color: blue;
@@ -113,11 +129,19 @@ echo "wiki_load_word('{$_get_word}')";
 		padding-left: 1em;
 	}
 	note>.palitext{
-    font-family: Noto serif;
-    line-height: 1.5em;
-	color: #9f3a01;
-    font-weight: 500;
-}
+		font-family: Noto serif;
+		line-height: 1.5em;
+		color: #9f3a01;
+		font-weight: 500;
+	}
+	note>.palitext>note{
+		display:inline;
+		color:blue;
+		background-color: unset;
+		padding: unset;
+		margin-bottom: unset;
+		border-radius: unset;
+	}
 	.term_block_bar {
 		display: flex;
 		justify-content: space-between;
@@ -195,6 +219,8 @@ echo "wiki_load_word('{$_get_word}')";
 
 	</style>
 <script>
+
+
 term_word_link_fun("wiki_goto_word");
 </script>
 <style>