瀏覽代碼

Merge branch 'master' of https://github.com/visuddhinanda/mint

Bhikkhu-Kosalla 5 年之前
父節點
當前提交
8ffa39b219

+ 4 - 1
app/article/article.js

@@ -86,7 +86,10 @@ function articel_load_collect(article_id) {
 				try {
 					let result = JSON.parse(data);
 					if (result && result.length > 0) {
-						$("#collect_title").html(result[0].title);
+						//$("#collect_title").html(result[0].title);
+						let strTitle = "<a href='../article/?collect=" + result[0].id + "'>" + result[0].title + "</a>";
+						$("#pali_pedia").html(strTitle);
+
 						let article_list = JSON.parse(result[0].article_list);
 						render_article_list(article_list);
 					}

+ 1 - 0
app/course/course.php

@@ -1,4 +1,5 @@
 <?PHP
+
 include "../pcdl/html_head.php";
 ?>
 <body>

+ 44 - 2
app/course/my_couse.js

@@ -44,8 +44,15 @@ function course_validate_form(thisform) {
 
 function course_list() {}
 
-function time_init() {
-	let lessonTime = new Date(parseInt($("#form_datetime").val()));
+function time_init(time = 0) {
+	//time=0 input time
+	//time != 0 now
+	let lessonTime;
+	if (time == 0) {
+		lessonTime = new Date(parseInt($("#form_datetime").val()));
+	} else {
+		lessonTime = new Date();
+	}
 	let month = lessonTime.getMonth() + 1;
 	month = month > 9 ? month : "0" + month;
 	let d = lessonTime.getDate();
@@ -90,3 +97,38 @@ function lesson_update() {
 		},
 	});
 }
+
+function lesson_insert() {
+	const date = new Date();
+	$("#lesson_timezone").val(date.getTimezoneOffset());
+	$.ajax({
+		type: "POST", //方法类型
+		dataType: "json", //预期服务器返回的数据类型
+		url: "../course/my_lesson_insert.php", //url
+		data: $("#lesson_new").serialize(),
+		success: function (result) {
+			console.log(result); //打印服务端返回的数据(调试用)
+			if (result.status == 0) {
+				alert(result.message);
+				window.open("../course/my_course_index.php?course=" + result.course_id);
+			} else {
+				alert(result.message);
+			}
+		},
+		error: function (data, status) {
+			alert(status + ":" + data.responseText);
+			switch (status) {
+				case "timeout":
+					break;
+				case "error":
+					break;
+				case "notmodified":
+					break;
+				case "parsererror":
+					break;
+				default:
+					break;
+			}
+		},
+	});
+}

+ 4 - 2
app/course/my_lesson_edit.php

@@ -88,8 +88,9 @@ echo '<div id="userfilelist">';
     echo '<div style="flex:8;"><textarea name="summary" style="height:6em;">'.$lesson_info["summary"].'</textarea></div>';
     echo '</div>';
 
+
     echo '<div style="display:flex;">';
-    echo '<div style="flex:2;">'.$_local->gui->introduction.'</div>';
+    echo '<div style="flex:2;">'.$_local->gui->time_arrange.'</div>';
     echo '<div style="flex:8;">';
     $strDate = date("Y-m-d",$lesson_info["date"]/1000);
     $strTime = date("H:i",$lesson_info["date"]/1000);
@@ -99,7 +100,8 @@ echo '<div id="userfilelist">';
     echo $_local->gui->date.':<div id="form_date"></div>';
     echo $_local->gui->time.':<div id="form_time"></div>';
     echo $_local->gui->duration.':<input type="time" name="duration" value="'.$strDuration.'"/>';
-    echo '</div></div>';
+    echo '</div>';
+    echo '</div>';
 
     echo '<div style="display:flex;">';
     echo '<div style="flex:2;">'.$_local->gui->notice_live.'</div>';

+ 11 - 3
app/course/my_lesson_insert.php

@@ -13,10 +13,19 @@ $query = "INSERT INTO lesson (id, course_id,  live, replay, title,  subtitle ,
 				 VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
 
 $sth = $PDO->prepare($query);
+
+/*
 $data = strtotime($_POST["lesson_date"]);
 $time = strtotime($_POST["lesson_time"]) - strtotime("today");
 $datatime = ($data+$time)*1000;
 $duration = strtotime($_POST["duration"]) - strtotime("today");
+*/
+
+$data = strtotime($_POST["lesson_date"]);
+$time = strtotime($_POST["lesson_time"]) - strtotime("today");
+$timezone = $_POST["lesson_timezone"];
+$datatime = ($data+$time+$timezone*60)*1000;
+$duration = strtotime($_POST["duration"]) - strtotime("today");
 
 $sth->execute(array(UUID::v4(), $_POST["course_id"] , $_POST["live"] , $_POST["replay"] ,$_POST["title"] , $_POST["subtitle"]  , $datatime  , $duration  , $_COOKIE["userid"] , $_POST["tag"] ,$_POST["summary"] , 1, $_POST["cover"] ,$_POST["teacher"] , $_POST["attachment"] , $_POST["lang"] , $_POST["speech_lang"] ,mTime() , mTime() ,  mTime() ));
 $respond=array("status"=>0,"message"=>"");
@@ -24,12 +33,11 @@ if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();
 	$respond['status']=1;
 	$respond['message']=$error[2];
-	echo "<div style=''>Lesson 数据添加失败:{$error[2]}</div>";
 }
 else{
 	$respond['status']=0;
 	$respond['message']="成功";
-	echo "<div style=''>Lesson 数据添加成功</div>";
+	$respond['course_id']=$_POST["course_id"];
 }
-//echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 ?>

+ 1 - 1
app/course/my_lesson_list.php

@@ -31,7 +31,7 @@ echo '</div>';
 		<span class="icon_btn_div">
 			<span class="icon_btn_tip"><?php echo $_local->gui->new_lesson;?></span>
 			<button id="file_share" type="button" class="icon_btn"  title=" ">
-			<a href="../course/my_course_index.php?course=<?php echo $course_info["id"] ?>&op=newlesson">
+			<a href="../course/my_lesson_new.php?course=<?php echo $course_info["id"] ?>&op=newlesson">
                 <svg style="" t="1601520759574" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7839" width="200" height="200">
                     <path d="M192 256h640v320H192z" p-id="7840"></path>
                     <path d="M832 192.5v447.29H192V192.5h640m0-64H192c-35.35 0-64 28.65-64 64v447.29c0 35.35 28.65 64 64 64h640c35.35 0 64-28.65 64-64V192.5c0-35.35-28.65-64-64-64z" p-id="7841">

+ 59 - 14
app/course/my_lesson_new.php

@@ -1,3 +1,33 @@
+<?php
+require_once '../studio/index_head.php';
+?>
+<body id="file_list_body" onLoad="course_list()">
+
+	<script language="javascript" src="../course/my_couse.js"></script>
+	<script language="javascript" src="../ucenter/name_selector.js"></script>
+	<script >
+	var gCurrPage="course";
+	</script>
+
+	<style>
+	#course {
+		background-color: var(--btn-border-color);
+		
+	}
+	#course:hover{
+		background-color: var(--btn-border-color);
+		color: var(--btn-color);
+		cursor:auto;
+	}
+	</style>
+
+	<?php
+	require_once '../studio/index_tool_bar.php';
+	?>
+		
+	<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">
+		<div id="course_list"  class="file_list_block">
+
 <div class="tool_bar">
 <?php
 require_once "../path.php";
@@ -24,7 +54,7 @@ echo '</div>';
 
 ?>
 
-<form action="../course/my_course_index.php" method="POST">
+<form  id="lesson_new" action="##" method="POST">
 <input type="hidden" name="course" value="<?php echo $_GET["course"];?>" />
 <input type="hidden" name="op" value="insert" />
 <input type="hidden" name="course_id" value="<?php echo $_GET["course"];?>" />
@@ -65,14 +95,22 @@ echo '</div>';
         <div style="flex:2;"><?php echo $_local->gui->notice_live ?></div>
         <div style="flex:8;"><textarea  name="live"  style="height:6em;"></textarea></div>
     </div>
-    <div style="display:flex;">
-        <div style="flex:2;"><?php echo $_local->gui->time_arrange ?></div>
-        <div style="flex:8;">
-        <?php echo $_local->gui->date ?>:<input type="date" name="lesson_date" value=""/>
-        <?php echo $_local->gui->time ?>:<input type="time" name="lesson_time" value="08:00"/>
-        <?php echo $_local->gui->duration ?>: <input type="time" name="duration" value="01:00"/>
-        </div>
-    </div>
+
+    <?php
+    echo '<div style="display:flex;">';
+    echo '<div style="flex:2;">'.$_local->gui->time_arrange.'</div>';
+    echo '<div style="flex:8;">';
+    echo "<div style='display:flex;'>";
+    echo '<input type="hidden" id="form_datetime" name="form_time" value="'.time().'"/>';
+    echo '<input type="hidden" id="lesson_timezone" name="lesson_timezone" value=""/>';
+    echo '<div><div>'.$_local->gui->date.'</div><div id="form_date"></div></div>';
+    echo '<div><div>'.$_local->gui->time.'</div><div id="form_time"></div></div>';
+    echo  '<div><div>'.$_local->gui->duration.'</div><input type="time" name="duration" value="01:00"/></div>';
+    echo '</div>';
+    echo '</div>';
+    echo '</div>';
+    ?>
+
     <div style="display:flex;">
     <div style="flex:2;"><?php echo $_local->gui->record_replay ?></div>
     <div style="flex:8;"><textarea name="replay" style="height:6em;"></textarea></div>
@@ -102,11 +140,18 @@ echo '</div>';
     </div>
     </div> 
 </div>
-
-
-<input type="submit" value="<?php echo $_local->gui->submit ?>">
 </form>
-
+<button onclick="lesson_insert()"><?php echo $_local->gui->submit ?></button>
 <script>
     name_selector_init("teacher_id",{input_id:"form_teacher"});
-</script>
+    time_init(1);
+</script>
+
+
+</div>
+		
+        </div>
+        
+    <?php
+    require_once '../studio/index_foot.php';
+    ?>

+ 2 - 1
app/course/my_lesson_update.php

@@ -13,12 +13,13 @@ PDO_Execute($query,array(mTime(),mTime(),$course_id));
 
 $query="UPDATE lesson SET title = ? , subtitle = ? , date = ? , duration = ? , live = ? , replay = ? , summary = ? , teacher = ?  , receive_time= ?  , modify_time= ?   where  id = ?  ";
 $sth = $PDO->prepare($query);
+
 $data = strtotime($_POST["lesson_date"]);
 $time = strtotime($_POST["lesson_time"]) - strtotime("today");
 $timezone = $_POST["lesson_timezone"];
 $datatime = ($data+$time+$timezone*60)*1000;
-
 $duration = strtotime($_POST["duration"]) - strtotime("today");
+
 $sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$datatime, $duration , $_POST["live"] , $_POST["replay"] , $_POST["summary"] ,  $_POST["teacher"] ,  mTime() , mTime() , $_POST["lesson"]));
 $respond=array("status"=>0,"message"=>"");
 if (!$sth || ($sth && $sth->errorCode() != 0)) {

+ 27 - 37
app/fullcalendar/examples/php/get-date.php

@@ -1,49 +1,39 @@
 <?php
 //
 
-require_once "../../../../path.php";
-require_once "../../../../public/_pdo.php";
+require_once "../../../path.php";
+require_once "../../../public/_pdo.php";
 
-if(isset($_GET["teacher"])){
-    $teacher = " teacher = ? ";
-}
-else{
-    $teacher = " 1= 1";
-}
+function get_teacher_course($teacher_id){
 
-global $PDO;
-PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+		$teacher = "  ";
 
-$query = "select * from course where $teacher  order by create_time DESC limit 0,100";
-if(isset($_GET["teacher"])){
-	$Fetch = PDO_FetchAll($query,array($_GET["teacher"]));
-}
-else{
-	$Fetch = PDO_FetchAll($query);
-}
+	global $PDO;
+	PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+	
+	$query = "select * from course where teacher = ?  order by create_time DESC limit 0,100";
 
-$output = array();
-foreach ($Fetch as $key => $couse) {
-	# code...
-	$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
-	$fAllLesson = PDO_FetchAll($query);
-	foreach ($fAllLesson as  $lesson) {
+	$Fetch = PDO_FetchAll($query,array($teacher_id));
+	
+	$output = array();
+	foreach ($Fetch as $key => $couse) {
 		# code...
-		#		"id": "999",
-		#"title": "Dhammacakkha",
-		#"url": "https://www.wikipali.org/app/course/lesson.php?id=6a42e993-8f7e-414a-a291-a4094764f992",
-		#"start": "2020-12-11T08:00:00+06:30",
-		#"end": "2020-12-11T09:30:00+06:30"
-		$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
-		$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
-		$output[]=array("id"=>$lesson["id"],
-									"title"=>$couse["title"],
-									"url"=>"../../../course/lesson.php?id=".$lesson["id"],
-									"start"=> $start,
-									"end"=>$end
-								);
+		$query = "select * from lesson where course_id = '{$couse["id"]}'   limit 0,300";
+		$fAllLesson = PDO_FetchAll($query);
+		foreach ($fAllLesson as  $lesson) {
+			$start = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000);
+			$end = date("Y-m-d\TH:i:s+00:00",$lesson["date"]/1000+$lesson["duration"]);
+			$output[]=array("id"=>$lesson["id"],
+										"title"=>$couse["title"],
+										"url"=>"../../course/lesson.php?id=".$lesson["id"],
+										"start"=> $start,
+										"end"=>$end
+									);
+		}
 	}
+	return($output);
+	
 }
-echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
 
 ?>

+ 5 - 2
app/fullcalendar/examples/php/get-events.php

@@ -11,6 +11,7 @@
 
 // Require our Event class and datetime utilities
 require dirname(__FILE__) . '/utils.php';
+require_once "./get-date.php";
 
 // Short-circuit if the client did not give us a date range.
 if (!isset($_GET['start']) || !isset($_GET['end'])) {
@@ -30,8 +31,10 @@ if (isset($_GET['timeZone'])) {
 }
 
 // Read and parse our events JSON file into an array of event data arrays.
-$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
-$input_arrays = json_decode($json, true);
+//$json = file_get_contents(dirname(__FILE__) . '/../json/events.json');
+//$input_arrays = json_decode($json, true);
+//使用cookie传递老师id
+$input_arrays = get_teacher_course($_COOKIE["teacher_id"]);
 
 // Accumulate an output array of event data arrays.
 $output_arrays = array();

+ 33 - 0
app/pali_sent/get_sim.php

@@ -0,0 +1,33 @@
+<?php
+/*
+get user sentence from db
+*/
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+
+$sim = $_POST["sim"];
+
+$simList = json_decode($sim);
+$output = array();
+
+$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
+$dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+$query="SELECT * FROM pali_sent WHERE  id = ?   ";
+$stmt = $dbh->prepare($query);
+foreach ($simList as  $value) {
+    # code...
+    $stmt->execute(array($value));
+	$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
+	if($Fetch){
+		$sent = $Fetch;
+		$sent["path"]=_get_para_path($Fetch["book"],$Fetch["paragraph"]);
+		$output[] = $sent;  
+	}
+}
+
+echo json_encode($output, JSON_UNESCAPED_UNICODE);
+
+?>

+ 1 - 1
app/path.php

@@ -13,7 +13,7 @@ define("_FILE_DB_RESRES_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/res.db3");
 define("_FILE_DB_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text.db3");
 define("_FILE_DB_STATISTICS_" , __DIR__."/../tmp/appdata/palicanon/word_statistics.db3");
 define("_FILE_DB_PALI_SENTENCE_" , __DIR__."/../tmp/appdata/palicanon/pali_sent.db3");
-define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sent._simdb3");
+define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sent_sim.db3");
 define("_FILE_DB_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/index.db3");
 define("_FILE_DB_WORD_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/wordindex.db3");
 define("_FILE_DB_PALI_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/paliindex.db3");

+ 4 - 1
app/pcdl/html_head.php

@@ -61,9 +61,12 @@ else{
 	<link type="text/css" rel="stylesheet" href="../term/popup_note.css"/>
 
 	<script src="../term/term_edit_dlg.js"></script>
-	<link type="text/css" rel="stylesheet" href="../term/term_edit_dlg.css"/>	
+	<link type="text/css" rel="stylesheet" href="../term/term_edit_dlg.css"/>
 	<script src="../uwbw/wbw_channal_list.js"></script>
 	<script src="../usent/historay.js"></script>
+	<script src="../term/pali_sim_sent.js"></script>
+	<link type="text/css" rel="stylesheet" href="../term/pali_sim_dlg.css"/>
+
 
 	<script src="../widget/click_dropdown.js"></script>
 	<link type="text/css" rel="stylesheet" href="../widget/click_dropdown.css"/>

+ 9 - 15
app/public/book_tag/tag_list.json

@@ -6,18 +6,9 @@
 	"aṭṭhakathā": { "level": 0 },
 	"ṭīkā": { "level": 0 },
 	"añña": { "level": 0 },
-	"dīgha": { "level": 1 },
-	"majjhima": { "level": 1 },
-	"saṃyutta": { "level": 1 },
-	"aṅguttara": { "level": 1 },
-	"khuddaka": { "level": 1 },
-	"pārājikapāḷi": { "level": 1 },
-	"pācittiyapāḷi": { "level": 1 },
-	"mahāvagga": { "level": 1 },
-	"cūḷavagga": { "level": 1 },
+	"suttavibhaṅga": { "level": 1 },
+	"khandhaka": { "level": 1 },
 	"parivāra": { "level": 1 },
-	"mahāvibhaṅga": { "level": 2 },
-	"bhikkhunīvibhaṅga": { "level": 2 },
 	"vibhaṅga": { "level": 1 },
 	"dhammasaṅgaṇī": { "level": 1 },
 	"dhātukathā": { "level": 1 },
@@ -25,6 +16,8 @@
 	"kathāvatthu": { "level": 1 },
 	"yamaka": { "level": 1 },
 	"paṭṭhāna": { "level": 1 },
+	"mahāvibhaṅga": { "level": 2 },
+	"bhikkhunīvibhaṅga": { "level": 2 },
 	"yamaka": { "level": 2 },
 	"vinayavinicchaya": { "level": 2 },
 	"vinayasaṅgaha": { "level": 2 },
@@ -43,7 +36,7 @@
 	"sāratthappakāsinī": { "level": 3 },
 	"sāratthamañjūsā": { "level": 3 },
 	"sāratthadīpanī": { "level": 3 },
-	"saṃyuttanikāya": { "level": 2 },
+	"saṃyuttanikāya": { "level": 1 },
 	"sammohavinodanī": { "level": 3 },
 	"samantapāsādikā": { "level": 3 },
 	"sādhuvilāsinī": { "level": 3 },
@@ -60,7 +53,7 @@
 	"mūlasikkhā": { "level": 2 },
 	"milindapañha": { "level": 3 },
 	"manorathapūraṇī": { "level": 3 },
-	"majjhimanikāya": { "level": 2 },
+	"majjhimanikāya": { "level": 1 },
 	"mahāvibhaṅga": { "level": 2 },
 	"mahāniddesa": { "level": 3 },
 	"līnatthappakāsanā": { "level": 3 },
@@ -70,7 +63,8 @@
 	"kaṅkhāvitaraṇī": { "level": 2 },
 	"jātaka": { "level": 3 },
 	"itivuttaka": { "level": 3 },
-	"dīghanikāya": { "level": 2 },
+	"dīghanikāya": { "level": 1 },
+	"khuddaka": { "level": 1 },
 	"dhātukathā": { "level": 2 },
 	"dhammasaṅgaṇī": { "level": 2 },
 	"dhammapada": { "level": 3 },
@@ -80,7 +74,7 @@
 	"bhikkhunīvibhaṅga": { "level": 2 },
 	"aṭṭhasālinī": { "level": 3 },
 	"apadāna": { "level": 3 },
-	"aṅguttaranikāya": { "level": 2 },
+	"aṅguttaranikāya": { "level": 1 },
 	"abhidhammamātikā": { "level": 2 },
 	"abhidhammāvatāra": { "level": 2 },
 	"abhidhammatthasaṅgaha": { "level": 2 }

+ 3 - 3
app/reader/index.php

@@ -249,9 +249,9 @@ require_once "../pcdl/html_head.php";
 		<span>
 		<input type="checkbox" onchange="setVisibility('palitext',this)" checked>Pali Text Visible
 		<?php
-		echo "<button class='icon_btn'  title='{$_local->gui->add}{$_local->gui->subfield}'>";
-		echo "<a href='../article/frame.php?id=".$_GET["id"];
-		echo "'>{$_local->gui->add}{$_local->gui->subfield}</a></button>";
+		//echo "<button class='icon_btn'  title='{$_local->gui->add}{$_local->gui->subfield}'>";
+		//echo "<a href='../article/frame.php?id=".$_GET["id"];
+		//echo "'>{$_local->gui->add}{$_local->gui->subfield}</a></button>";
 		
 		if(isset($_GET["display"]) && $_GET["display"]=="para"){
 			echo "<button class='icon_btn active' title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";

+ 18 - 2
app/term/note.js

@@ -36,6 +36,7 @@ function note_create() {
 	wbw_channal_list_init();
 	note_sent_edit_dlg_init();
 	term_edit_dlg_init();
+	pali_sim_dlg_init();
 }
 function note_sent_edit_dlg_init() {
 	$("body").append(
@@ -483,8 +484,13 @@ function note_json_html(in_json) {
 	output += "<span class='separate_line'></span>";
 	//相似句工具条
 	output += "<span class='other_bar' >";
-	output += "<span class='similar_sent_span' >" + gLocal.gui.similar_sentences + "</span>";
-	output += "<span class='similar_sent_num'></span>";
+	output +=
+		"<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
+		in_json.id +
+		"')\">" +
+		gLocal.gui.similar_sentences +
+		"</span>";
+	output += "<span class='similar_sent_num'>" + in_json.sim.length + "</span>";
 	output += "</span>";
 	output += "</div>";
 	output += "<div class='other_tran'>";
@@ -659,6 +665,8 @@ function new_sentence(book, para, begin, end, channel) {
 	}
 	note_edit_sentence(book, para, begin, end, channel);
 }
+
+//显示更多译文按钮动作
 function set_more_button_display() {
 	$(".other_tran_div").each(function () {
 		const sentid = $(this).attr("sent").split("-");
@@ -913,3 +921,11 @@ function setVisibility(key, value) {
 			break;
 	}
 }
+
+function note_show_pali_sim(SentId) {
+	for (const iterator of _arrData) {
+		if (iterator.id == SentId) {
+			pali_sim_dlg_open(SentId, iterator.sim);
+		}
+	}
+}

+ 26 - 5
app/term/note.php

@@ -40,6 +40,10 @@ $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);  
 
+$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_SIM_;
+$db_pali_sent_sim = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$db_pali_sent_sim->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
 $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);  
@@ -70,15 +74,28 @@ foreach ($_data as $key => $value) {
 		$end=0;
 	}
 
-	$query="SELECT html FROM 'pali_sent' WHERE book = ? AND paragraph = ? AND begin = ? AND end = ? ";
+	$query="SELECT id,html FROM 'pali_sent' WHERE book = ? AND paragraph = ? AND begin = ? AND end = ? ";
 	$sth = $db_pali_sent->prepare($query);
 	$sth->execute(array($bookId,$para,$begin,$end));
-	$row = $sth->fetch(PDO::FETCH_NUM);
+	$row = $sth->fetch(PDO::FETCH_ASSOC);
 	if ($row) {
-		$palitext= $row[0];
+		$palitext= $row['html'];
+		$pali_text_id = $row['id'];
 	} else {
 		$palitext="";
+		$pali_text_id = 0;
+	}
+	$query="SELECT sim_sents FROM 'pali_sent_sim' WHERE id = ?  ";
+	$sth = $db_pali_sent_sim->prepare($query);
+	$sth->execute(array($pali_text_id));
+	$row = $sth->fetch(PDO::FETCH_ASSOC);
+	if($row){
+		$pali_sim= explode(",",$row["sim_sents"]) ;
+	}
+	else{
+		$pali_sim=array();
 	}
+		//查询相似句
 
 	//find out translation 查询译文
 	$tran="";
@@ -154,9 +171,12 @@ foreach ($_data as $key => $value) {
 		$translation[$key]["channalinfo"]=$tran_channal[$value["channal"]];
 	}
 
-	
+	//查询路径
 	$para_path=_get_para_path($bookId,$para);
 
+
+
+
 	$output[]=array("id"=>$id,
 							   "palitext"=>$palitext,
 							   "tran"=>$tran,
@@ -166,7 +186,8 @@ foreach ($_data as $key => $value) {
 							   "book"=>$bookId,
 							   "para"=>$para,
 							   "begin"=>$begin,
-							   "end"=>$end
+							   "end"=>$end,
+							   "sim"=>$pali_sim
 							);
 
 }

+ 7 - 0
app/term/pali_sim_dlg.css

@@ -0,0 +1,7 @@
+.pali_sent_div {
+	padding: 3px;
+	margin-bottom: 5px;
+}
+.pali_sent_div > .path {
+	font-size: 75%;
+}

+ 45 - 0
app/term/pali_sim_sent.js

@@ -0,0 +1,45 @@
+function pali_sim_dlg_init(title = "Sim") {
+	$("body").append('<div id="pali_sim_dlg" title="' + title + '"><div id="pali_sim_dlg_content"></div></div>');
+
+	$("#pali_sim_dlg").dialog({
+		autoOpen: false,
+		width: 550,
+		buttons: [
+			{
+				text: "Close",
+				click: function () {
+					$(this).dialog("close");
+				},
+			},
+		],
+	});
+}
+function pali_sim_dlg_open(id, sim_id) {
+	{
+		$.post(
+			"../pali_sent/get_sim.php",
+			{
+				id: id,
+				sim: JSON.stringify(sim_id),
+			},
+			function (data) {
+				let sents = JSON.parse(data);
+				let html = pali_sim_dlg_render(sents);
+				$("#pali_sim_dlg_content").html(html);
+				$("#pali_sim_dlg").dialog("open");
+			}
+		);
+	}
+}
+
+function pali_sim_dlg_render(sent_list) {
+	let output = "";
+	for (const iterator of sent_list) {
+		output += "<div class='pali_sent_div'>";
+		output += "<div class='pali_sent'>" + iterator.text + "</div>";
+		output += "<div class='path'>" + iterator.path + "</div>";
+		output += "</div>";
+	}
+
+	return output;
+}

+ 4 - 0
app/uhome/course.php

@@ -1,4 +1,8 @@
 <?PHP
+if(isset($_GET["userid"])){
+    setcookie("teacher_id", $_GET["userid"], time()+60*60,"/");
+}
+
 include "../pcdl/html_head.php";
 ?>
 <body>