Browse Source

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

Bhikkhu-Kosalla 5 years ago
parent
commit
a5650c7ace

+ 22 - 0
app/admin/pali_toc.sql

@@ -0,0 +1,22 @@
+--
+-- 由SQLiteStudio v3.1.1 产生的文件 周四 2月 11 17:30:07 2021
+--
+-- 文本编码:UTF-8
+--
+PRAGMA foreign_keys = off;
+BEGIN TRANSACTION;
+
+-- 表:course
+DROP TABLE IF EXISTS course;
+CREATE TABLE course (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lesson_id CHAR (36), start INTEGER, "end" INTEGER);
+
+-- 表:nissaya
+DROP TABLE IF EXISTS nissaya;
+CREATE TABLE nissaya (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), media INTEGER);
+
+-- 表:progress
+DROP TABLE IF EXISTS progress;
+CREATE TABLE progress (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), "all" REAL, public REAL);
+
+COMMIT TRANSACTION;
+PRAGMA foreign_keys = on;

+ 8 - 10
app/course/course.php

@@ -10,13 +10,17 @@ include "../pcdl/html_head.php";
     require_once("../pcdl/head_bar.php");
     ?>
 
-<link type="text/css" rel="stylesheet" href="./style.css" />
+    <link type="text/css" rel="stylesheet" href="./style.css" />
     <style>
         .disable {
             cursor: not-allowed;
             opacity: 0.5;
         }
 
+        .padding_2_1rem {
+            padding: 2rem 1rem;
+        }
+
         #main_video_win iframe {
             width: 100%;
             height: 100%;
@@ -31,19 +35,12 @@ include "../pcdl/html_head.php";
             padding: 0;
         }
 
-        #lesson_list {}
-
         #course_info_head_1 {
             display: grid;
             grid-template-columns: 200px 1fr;
             grid-gap: 20px;
         }
 
-        #course_info_head_face {
-            /*width: 200px;
-            height: 200px;*/
-        }
-
         #course_info_head_face img {
             width: 200px;
             height: 200px;
@@ -78,7 +75,7 @@ include "../pcdl/html_head.php";
         }
 
         #lesson_list_shell {
-            padding: 1rem;
+            padding: 2rem 1rem;
             background-color: #f5f5f5;
         }
 
@@ -147,6 +144,7 @@ include "../pcdl/html_head.php";
                 grid-gap: 10px;
             }
 
+            #course_info_head_face,
             #course_info_head_face img {
                 width: 100px;
                 height: 100px;
@@ -158,7 +156,7 @@ include "../pcdl/html_head.php";
 
 
     <div id='course_content'>
-        <div id='course_info_shell' style='padding:1rem;'>
+        <div id='course_info_shell' class='padding_2_1rem'>
             <div id='course_info' class="section_inner"></div>
         </div>
         <div id='lesson_list_shell'>

+ 6 - 2
app/course/index.php

@@ -8,6 +8,10 @@ include "../pcdl/html_head.php";
 	require_once("../pcdl/head_bar.php");
 	?>
 	<style>
+		.padding_LR_1rem {
+			padding: 0 1rem;
+		}
+
 		.content_block {
 			width: 230px;
 		}
@@ -250,8 +254,8 @@ include "../pcdl/html_head.php";
 					html += '<div class="title"><a href="../course/course.php?id=' + iterator.id + '">' + iterator.title + '</a></div>';
 
 					//教师名字
-					html += '<div class="author">'+gLocal.gui.speaker+':';
-					html += "<a href='../uhome/course.php?userid="+iterator.teacher+"'>"
+					html += '<div class="author">' + gLocal.gui.speaker + ':';
+					html += "<a href='../uhome/course.php?userid=" + iterator.teacher + "'>"
 					html += iterator.teacher_info.nickname;
 					html += "</a>";
 					html += '</div>';

+ 311 - 314
app/course/lesson.js

@@ -1,356 +1,353 @@
 var renderer = new marked.Renderer();
-renderer.code = function (code, language) {
-	if (language == "mermaid") return '<pre class="mermaid">' + code + "</pre>";
-	else return "<pre><code>" + code + "</code></pre>";
+renderer.code = function(code, language) {
+    if (language == "mermaid") return '<pre class="mermaid">' + code + "</pre>";
+    else return "<pre><code>" + code + "</code></pre>";
 };
 
 function lesson_show(id) {
-	$.get(
-		"../course/lesson_get.php",
-		{
-			id: id,
-		},
-		function (data, status) {
-			let arrLesson = JSON.parse(data);
-			let html = "";
-			for (const lesson of arrLesson) {
-				html += '<div class="card" style="display:flex;margin:1em;padding:10px;">';
+    $.get(
+        "../course/lesson_get.php", {
+            id: id,
+        },
+        function(data, status) {
+            let arrLesson = JSON.parse(data);
+            let html = "";
+            for (const lesson of arrLesson) {
+                html += '<div class="card" style="display:flex;margin:1em;padding:10px;">';
 
-				html += '<div style="flex:7;">';
-				html += '<div class="pd-10">';
-				html +=
-					'<div class="title" style="padding-bottom:5px;font-size:200%;font-weight:600;">' +
-					lesson["title"] +
-					"</div>";
-				html += '<div style="">';
-				let summary = "";
-				try {
-					summary = marked(lesson["summary"], { renderer: renderer });
-				} catch {}
-				html += '<div class="summary"  style="padding-bottom:5px;">' + summary + "</div>";
-				let live = "";
-				try {
-					live = marked(lesson["live"], { renderer: renderer });
-				} catch {}
-				html += '<div class="summary"  style="padding-bottom:5px;">' + live + "</div>";
-				let replay = "";
-				try {
-					replay = marked(lesson["replay"], { renderer: renderer });
-				} catch {}
-				html += '<div class="summary"  style="padding-bottom:5px;">' + replay + "</div>";
-				let attachment = "";
-				try {
-					attachment = marked(lesson["attachment"], { renderer: renderer });
-				} catch {}
-				html += '<div class="summary"  style="padding-bottom:5px;">' + attachment + "</div>";
-				html += "</div>";
-				html += "</div>";
-				html += "</div>";
+                html += '<div style="flex:7;">';
+                html += '<div class="pd-10">';
+                html +=
+                    '<div class="title" style="padding-bottom:5px;font-size:200%;font-weight:600;">' +
+                    lesson["title"] +
+                    "</div>";
+                html += '<div style="">';
+                let summary = "";
+                try {
+                    summary = marked(lesson["summary"], { renderer: renderer });
+                } catch {}
+                html += '<div class="summary"  style="padding-bottom:5px;">' + summary + "</div>";
+                let live = "";
+                try {
+                    live = marked(lesson["live"], { renderer: renderer });
+                } catch {}
+                html += '<div class="summary"  style="padding-bottom:5px;">' + live + "</div>";
+                let replay = "";
+                try {
+                    replay = marked(lesson["replay"], { renderer: renderer });
+                } catch {}
+                html += '<div class="summary"  style="padding-bottom:5px;">' + replay + "</div>";
+                let attachment = "";
+                try {
+                    attachment = marked(lesson["attachment"], { renderer: renderer });
+                } catch {}
+                html += '<div class="summary"  style="padding-bottom:5px;">' + attachment + "</div>";
+                html += "</div>";
+                html += "</div>";
+                html += "</div>";
 
-				html += '<div style="flex:3;max-width:15em;">';
-				let d = new Date();
-				d.setTime(lesson["date"]);
-				let strData = d.toLocaleDateString();
-				let strTime = d.toLocaleTimeString();
-				html += "<div >" + gLocal.gui.date + ":" + strData + "</div>";
-				html += "<div >" + gLocal.gui.time + ":" + strTime + "</div>";
-				let dt = lesson["duration"] / 60;
-				let sdt = "";
-				if (dt > 59) {
-					sdt += Math.floor(dt / 60) + gLocal.gui.h;
-				}
-				let m = dt % 60;
-				if (m > 0) {
-					sdt += (dt % 60) + gLocal.gui.mins;
-				}
-				html += "<div >" + gLocal.gui.duration + ":" + sdt + "</div>";
-				let now = new Date();
+                html += '<div style="flex:3;max-width:15em;">';
+                let d = new Date();
+                d.setTime(lesson["date"]);
+                let strData = d.toLocaleDateString();
+                let strTime = d.toLocaleTimeString();
+                html += "<div >" + gLocal.gui.date + ":" + strData + "</div>";
+                html += "<div >" + gLocal.gui.time + ":" + strTime + "</div>";
+                let dt = lesson["duration"] / 60;
+                let sdt = "";
+                if (dt > 59) {
+                    sdt += Math.floor(dt / 60) + gLocal.gui.h;
+                }
+                let m = dt % 60;
+                if (m > 0) {
+                    sdt += (dt % 60) + gLocal.gui.mins;
+                }
+                html += "<div >" + gLocal.gui.duration + ":" + sdt + "</div>";
+                let now = new Date();
 
-				let lesson_time = "";
-				if (now < lesson["date"]) {
-					lesson_time = gLocal.gui.not_started;
-				} else if (now > lesson["date"] && now < lesson["date"] + dt * 1000) {
-					lesson_time = gLocal.gui.in_progress;
-				} else {
-					lesson_time = gLocal.gui.already_over;
-				}
-				html += '<div ><span class="lesson_status">' + lesson_time + "</span></div>";
+                let lesson_time = "";
+                if (now < lesson["date"]) {
+                    lesson_time = gLocal.gui.not_started;
+                } else if (now > lesson["date"] && now < lesson["date"] + dt * 1000) {
+                    lesson_time = gLocal.gui.in_progress;
+                } else {
+                    lesson_time = gLocal.gui.already_over;
+                }
+                html += '<div ><span class="lesson_status">' + lesson_time + "</span></div>";
 
-				html += "</div>";
+                html += "</div>";
 
-				html += "</div>";
-			}
-			$("#lesson_list").html(html);
-			mermaid.initialize();
-		}
-	);
+                html += "</div>";
+            }
+            $("#lesson_list").html(html);
+            mermaid.initialize();
+        }
+    );
 }
 
 function lesson_load(lesson_id) {
-	$.get(
-		"../course/lesson_get.php",
-		{
-			id: lesson_id,
-		},
-		function (data, status) {
-			let html = "";
-			let lesson_info = JSON.parse(data);
-			if (lesson_info) {
-				//head
-				html += "<div id='course_info_head' class='course_info_block'>";
+    $.get(
+        "../course/lesson_get.php", {
+            id: lesson_id,
+        },
+        function(data, status) {
+            let html = "";
+            let lesson_info = JSON.parse(data);
+            if (lesson_info) {
+                //head
+                html += "<div id='course_info_head' class='course_info_block'>";
 
-				html += "<div id='course_info_head_title'>";
-				html += "<div id='course_title'>" + lesson_info.title + "</div>";
-				html += "<div id='course_subtitle'>" + lesson_info.subtitle + "</div>";
-				html += "</div>";
-				html += "</div>";
-				//end of head
+                html += "<div id='course_info_head_title'>";
+                html += "<div id='course_title'>" + lesson_info.title + "</div>";
+                html += "<div id='course_subtitle'>" + lesson_info.subtitle + "</div>";
+                html += "</div>";
+                html += "</div>";
+                //end of head
 
-				let d = new Date();
-				d.setTime(lesson_info.date);
-				let strData = d.toLocaleDateString();
-				let strTime = d.toLocaleTimeString();
-				let dt = lesson_info["duration"] / 60;
-				let strDuration = "";
-				if (dt > 59) {
-					strDuration += Math.floor(dt / 60) + "小时";
-				}
-				let m = dt % 60;
-				if (m > 0) {
-					strDuration += (dt % 60) + "分钟";
-				}
+                let d = new Date();
+                d.setTime(lesson_info.date);
+                let strData = d.toLocaleDateString();
+                let strTime = d.toLocaleTimeString();
+                let dt = lesson_info["duration"] / 60;
+                let strDuration = "";
+                if (dt > 59) {
+                    strDuration += Math.floor(dt / 60) + "小时";
+                }
+                let m = dt % 60;
+                if (m > 0) {
+                    strDuration += (dt % 60) + "分钟";
+                }
 
-				html += "<div id='course_info_head_2' class='course_info_block'>";
-				html += "<div class='info_item'>" + "<span>上课时间:<span>" + strData + " " + strTime + "</div>";
-				html +=
-					"<div class='info_item'>" + "<span>" + gLocal.gui.duration + ":<span>" + strDuration + "</div>";
-				html += "<div class='info_item'>" + "<span>" + gLocal.gui.speaker + ":<span>";
-				html +=
-					"<a href='../uhome/course.php?userid=" +
-					lesson_info.teacher +
-					"'>" +
-					lesson_info.teacher_info.nickname +
-					"</a>";
-				html += "</span>";
-				//html += "<span>地区:缅甸</span>";
-				html += "</div>";
-				html += "</div>";
-				// end of course_info_head_2
+                html += "<div id='lesson_info_head_2' class='course_info_block'>";
+                html += "<div class='info_item'>" + "<span>上课时间:<span>" + strData + " " + strTime + "</div>";
+                html +=
+                    "<div class='info_item'>" + "<span>" + gLocal.gui.duration + ":<span>" + strDuration + "</div>";
+                html += "<div class='info_item'>" + "<span>" + gLocal.gui.speaker + ":<span>";
+                html +=
+                    "<a href='../uhome/course.php?userid=" +
+                    lesson_info.teacher +
+                    "'>" +
+                    lesson_info.teacher_info.nickname +
+                    "</a>";
+                html += "</span>";
+                //html += "<span>地区:缅甸</span>";
+                html += "</div>";
+                html += "</div>";
+                // end of course_info_head_2
 
-				//live
-				if (lesson_info.live && lesson_info.live.length > 0) {
-					html += "<div id='course_info_live' class='course_info_block'>";
-					html += "<h2>" + gLocal.gui.notice_live + "</h2>";
-					try {
-						html += marked(lesson_info.live);
-					} catch (e) {
-						html += e.message;
-					}
-					html += "</div>";
-				}
-				//end of live
+                //live
+                if (lesson_info.live && lesson_info.live.length > 0) {
+                    html += "<div id='course_info_live' class='course_info_block'>";
+                    html += "<h2>" + gLocal.gui.notice_live + "</h2>";
+                    try {
+                        html += marked(lesson_info.live);
+                    } catch (e) {
+                        html += e.message;
+                    }
+                    html += "</div>";
+                }
+                //end of live
 
-				//replay
-				if (lesson_info.replay && lesson_info.replay.length > 0) {
-					html += "<div id='course_info_replay' class='course_info_block'>";
-					html += "<h2>" + gLocal.gui.record_replay + "</h2>";
-					try {
-						html += marked(lesson_info.replay);
-					} catch (e) {
-						html += e.message;
-					}
-					html += "</div>";
-				}
-				//end of replay
+                //replay
+                if (lesson_info.replay && lesson_info.replay.length > 0) {
+                    html += "<div id='course_info_replay' class='course_info_block'>";
+                    html += "<h2>" + gLocal.gui.record_replay + "</h2>";
+                    try {
+                        html += marked(lesson_info.replay);
+                    } catch (e) {
+                        html += e.message;
+                    }
+                    html += "</div>";
+                }
+                //end of replay
 
-				//attachment
-				if (lesson_info.attachment && lesson_info.attachment.length > 0) {
-					html += "<div id='course_info_attachment' class='course_info_block'>";
-					html += "<h2>" + gLocal.gui.attachment + "</h2>";
-					try {
-						html += "<div class='course_info_content'>";
-						html += note_init(lesson_info.attachment);
-						html += "</div>";
-					} catch (e) {
-						html += e.message;
-					}
-					html += "</div>";
-				}
-				//end of attachment
+                //attachment
+                if (lesson_info.attachment && lesson_info.attachment.length > 0) {
+                    html += "<div id='course_info_attachment' class='course_info_block'>";
+                    html += "<h2>" + gLocal.gui.attachment + "</h2>";
+                    try {
+                        html += "<div class='course_info_content'>";
+                        html += note_init(lesson_info.attachment);
+                        html += "</div>";
+                    } catch (e) {
+                        html += e.message;
+                    }
+                    html += "</div>";
+                }
+                //end of attachment
 
-				//content
-				if (lesson_info.content && lesson_info.content.length > 0) {
-					html += "<div id='course_info_content' class='course_info_block'>";
-					html += "<h2>" + gLocal.gui.detaile + "</h2>";
-					try {
-						html += marked(lesson_info.content);
-					} catch (e) {
-						html += e.message;
-					}
-					html += "</div>";
-				}
-				//end of attachment
-				$("#lesson_info").html(html);
-				$("#page_title").text(lesson_info.title);
-				note_refresh_new();
-				render_course_info(lesson_info.course_id);
-				render_lesson_list(lesson_info.course_id, lesson_info.id);
-			}
-		}
-	);
+                //content
+                if (lesson_info.content && lesson_info.content.length > 0) {
+                    html += "<div id='course_info_content' class='course_info_block'>";
+                    html += "<h2>" + gLocal.gui.detaile + "</h2>";
+                    try {
+                        html += marked(lesson_info.content);
+                    } catch (e) {
+                        html += e.message;
+                    }
+                    html += "</div>";
+                }
+                //end of attachment
+                $("#lesson_info").html(html);
+                $("#page_title").text(lesson_info.title);
+                note_refresh_new();
+                render_course_info(lesson_info.course_id);
+                render_lesson_list(lesson_info.course_id, lesson_info.id);
+            }
+        }
+    );
 }
+
 function render_course_info(course_id) {
-	$.get(
-		"../course/course_get.php",
-		{
-			id: course_id,
-		},
-		function (data, status) {
-			let html = "";
-			let course_info = JSON.parse(data);
-			if (course_info) {
-				let html = "";
-				html += "<div id='parent_title'>";
-				html += "<a href='../course/course.php?id=" + course_info.id + "'>";
-				html += course_info.title;
-				html += "</a>";
-				html += "</div>";
-				html += "<div id='course_button'>";
-				html += "<button>关注</button>";
-				html += "<button>报名</button>";
-				html += "</div>";
-				$("#course_info").html(html);
-			}
-		}
-	);
+    $.get(
+        "../course/course_get.php", {
+            id: course_id,
+        },
+        function(data, status) {
+            let html = "";
+            let course_info = JSON.parse(data);
+            if (course_info) {
+                let html = "";
+                html += "<div id='parent_title'>";
+                html += "<a href='../course/course.php?id=" + course_info.id + "'>";
+                html += course_info.title;
+                html += "</a>";
+                html += "</div>";
+                html += "<div id='course_button'>";
+                html += "<button>关注</button>";
+                html += "<button>报名</button>";
+                html += "</div>";
+                $("#course_info").html(html);
+            }
+        }
+    );
 }
+
 function render_lesson_list(course_id, currLesson) {
-	$.get(
-		"../course/lesson_list.php",
-		{
-			id: course_id,
-		},
-		function (data, status) {
-			let arrLesson = JSON.parse(data);
-			let html = "";
-			for (const lesson of arrLesson) {
-				let currlessonStyle = "";
-				if (lesson.id == currLesson) {
-					currlessonStyle = " curr_lesson";
-				} else {
-					currlessonStyle = " not_curr_lesson";
-				}
-				//计算课程是否已经开始
-				let now = new Date();
-				let class_lesson_time = "";
-				let dt = lesson["duration"] / 60;
-				if (now < lesson["date"]) {
-					class_lesson_time = "not_started";
-				} else if (now > lesson["date"] && now < lesson["date"] + dt * 1000) {
-					class_lesson_time = "in_progress";
-				} else {
-					class_lesson_time = "already_over";
-				}
+    $.get(
+        "../course/lesson_list.php", {
+            id: course_id,
+        },
+        function(data, status) {
+            let arrLesson = JSON.parse(data);
+            let html = "";
+            for (const lesson of arrLesson) {
+                let currlessonStyle = "";
+                if (lesson.id == currLesson) {
+                    currlessonStyle = " curr_lesson";
+                } else {
+                    currlessonStyle = " not_curr_lesson";
+                }
+                //计算课程是否已经开始
+                let now = new Date();
+                let class_lesson_time = "";
+                let dt = lesson["duration"] / 60;
+                if (now < lesson["date"]) {
+                    class_lesson_time = "not_started";
+                } else if (now > lesson["date"] && now < lesson["date"] + dt * 1000) {
+                    class_lesson_time = "in_progress";
+                } else {
+                    class_lesson_time = "already_over";
+                }
 
-				html += '<div class="lesson_card ' + currlessonStyle + '" >';
-				let d = new Date();
-				d.setTime(lesson["date"]);
-				let strData = d.toLocaleDateString();
-				let strTime = d.toLocaleTimeString();
-				html += '<div class="pd-10">';
-				html += "<div class='datatime " + class_lesson_time + "'>" + strData + " " + strTime + "</div>";
-				html +=
-					'<div class="title" ><a href="../course/lesson.php?id=' +
-					lesson["id"] +
-					'">' +
-					lesson["title"] +
-					"</a></div>";
+                html += '<div class="lesson_card ' + currlessonStyle + '" >';
+                let d = new Date();
+                d.setTime(lesson["date"]);
+                let strData = d.toLocaleDateString();
+                let strTime = d.toLocaleTimeString();
+                html += '<div class="pd-10">';
+                html += "<div class='datatime " + class_lesson_time + "'>" + strData + " " + strTime + "</div>";
+                html +=
+                    '<div class="title" ><a href="../course/lesson.php?id=' +
+                    lesson["id"] +
+                    '">' +
+                    lesson["title"] +
+                    "</a></div>";
 
-				html += "</div>";
+                html += "</div>";
 
-				html += "</div>";
-			}
-			$("#lesson_list").html(html);
-		}
-	);
+                html += "</div>";
+            }
+            $("#lesson_list").html(html);
+        }
+    );
 }
 
 function lesson_get_timeline_settime(start, div) {
-	let lessonTime;
-	if (start) {
-		lessonTime = new Date(parseInt(start));
-	} else {
-		lessonTime = new Date();
-	}
-	let month = lessonTime.getMonth() + 1;
-	month = month > 9 ? month : "0" + month;
-	let d = lessonTime.getDate();
-	d = d > 9 ? d : "0" + d;
-	let data = lessonTime.getFullYear() + "-" + month + "-" + d;
-	let strData = "<input type='date'  id='" + div + "_date' value='" + data + "'/>";
+    let lessonTime;
+    if (start) {
+        lessonTime = new Date(parseInt(start));
+    } else {
+        lessonTime = new Date();
+    }
+    let month = lessonTime.getMonth() + 1;
+    month = month > 9 ? month : "0" + month;
+    let d = lessonTime.getDate();
+    d = d > 9 ? d : "0" + d;
+    let data = lessonTime.getFullYear() + "-" + month + "-" + d;
+    let strData = "<input type='date'  id='" + div + "_date' value='" + data + "'/>";
 
-	let H = lessonTime.getHours();
-	H = H > 9 ? H : "0" + H;
-	let M = lessonTime.getMinutes();
-	M = M > 9 ? M : "0" + M;
-	let strTime = "<input type='time'  id='" + div + "_time' value='" + H + ":" + M + "'/>";
+    let H = lessonTime.getHours();
+    H = H > 9 ? H : "0" + H;
+    let M = lessonTime.getMinutes();
+    M = M > 9 ? M : "0" + M;
+    let strTime = "<input type='time'  id='" + div + "_time' value='" + H + ":" + M + "'/>";
 
-	$("#form_" + div).html(strData + strTime);
+    $("#form_" + div).html(strData + strTime);
 }
 
 function lesson_get_timeline_submit() {
-	let start_date = new Date();
-	let start_data = $("#start_date").val().split("-");
-	let start_time = $("#start_time").val().split(":");
+    let start_date = new Date();
+    let start_data = $("#start_date").val().split("-");
+    let start_time = $("#start_time").val().split(":");
 
-	start_date.setFullYear(start_data[0], parseInt(start_data[1]) - 1, start_data[2]);
-	start_date.setHours(start_time[0], start_time[1]);
+    start_date.setFullYear(start_data[0], parseInt(start_data[1]) - 1, start_data[2]);
+    start_date.setHours(start_time[0], start_time[1]);
 
-	let end_date = new Date();
-	let end_data = $("#end_date").val().split("-");
-	let end_time = $("#end_time").val().split(":");
+    let end_date = new Date();
+    let end_data = $("#end_date").val().split("-");
+    let end_time = $("#end_time").val().split(":");
 
-	end_date.setFullYear(end_data[0], parseInt(end_data[1]) - 1, end_data[2]);
-	end_date.setHours(end_time[0], end_time[1], 0, 0);
+    end_date.setFullYear(end_data[0], parseInt(end_data[1]) - 1, end_data[2]);
+    end_date.setHours(end_time[0], end_time[1], 0, 0);
 
-	location.assign("../course/lesson_get_timeline.php?start=" + start_date.getTime() + "&end=" + end_date.getTime());
+    location.assign("../course/lesson_get_timeline.php?start=" + start_date.getTime() + "&end=" + end_date.getTime());
 }
 
 function lesson_get_timeline_json(start, end) {
-	$.get(
-		"../ucenter/active_log_get.php",
-		{
-			start: start,
-			end: end,
-		},
-		function (data) {
-			$("#timeline_json").val(data);
-			let json = JSON.parse(data);
-			let html = "<table>";
-			for (const row of json) {
-				html += "<tr>";
-				let start_date = new Date(parseInt(row.time));
-				html += "<td>" + start_date.getHours() + ":" + start_date.getMinutes() + "</td>";
+    $.get(
+        "../ucenter/active_log_get.php", {
+            start: start,
+            end: end,
+        },
+        function(data) {
+            $("#timeline_json").val(data);
+            let json = JSON.parse(data);
+            let html = "<table>";
+            for (const row of json) {
+                html += "<tr>";
+                let start_date = new Date(parseInt(row.time));
+                html += "<td>" + start_date.getHours() + ":" + start_date.getMinutes() + "</td>";
 
-				html += "<td>" + gLocal.LogType[row.active] + "</td>";
-				html += "<td>";
-				switch (row.active) {
-					case "30":
-						html += "<a href='../dict/?word=" + row.content + "' target='_blank'>" + row.content + "</a>";
-						break;
-					case "11":
-						break;
-					case "20":
-						break;
-					default:
-						html += row.content;
-						break;
-				}
-				html += "</td>";
-				html += "</tr>";
-			}
-			html += "</table>";
-			$("#timeline_table").html(html);
-		}
-	);
-}
+                html += "<td>" + gLocal.LogType[row.active] + "</td>";
+                html += "<td>";
+                switch (row.active) {
+                    case "30":
+                        html += "<a href='../dict/?word=" + row.content + "' target='_blank'>" + row.content + "</a>";
+                        break;
+                    case "11":
+                        break;
+                    case "20":
+                        break;
+                    default:
+                        html += row.content;
+                        break;
+                }
+                html += "</td>";
+                html += "</tr>";
+            }
+            html += "</table>";
+            $("#timeline_table").html(html);
+        }
+    );
+}

+ 55 - 38
app/course/lesson.php

@@ -1,44 +1,61 @@
 <?PHP
-    include "../pcdl/html_head.php";
+include "../pcdl/html_head.php";
 ?>
+
 <body>
-<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
-<script src="https://cdn.jsdelivr.net/npm/mermaid@8.6.0/dist/mermaid.min.js"></script>
+    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
+    <script src="https://cdn.jsdelivr.net/npm/mermaid@8.6.0/dist/mermaid.min.js"></script>
 
-<script src="../course/lesson.js"></script>
-<?php
+    <script src="../course/lesson.js"></script>
+    <?php
     require_once("../pcdl/head_bar.php");
-?>
+    ?>
+
+    <link type="text/css" rel="stylesheet" href="./style.css" />
+
+    <style>
+        .padding_LR_1rem {
+            padding: 0 1rem;
+        }
+
+        #lesson_info_shell {
+            padding: 2rem 1rem;
+        }
+
+        #course_info_shell {
+            background-color: var(--box-bg-color1);
+        }
+
+        #course_info {
+            display: flex;
+            justify-content: space-between;
+            padding: 6px;
+        }
+
+        #parent_title,
+        #parent_title a {
+            font-size: 13px;
+            line-height: 2.4em;
+            font-weight: 500;
+            color: var(--tool-color);
+        }
+    </style>
+
+    <div id='course_content'>
+        <div id='course_info_shell' class='padding_LR_1rem'>
+            <div id='course_info' class="section_inner"></div>
+        </div>
+        <div id='lesson_info_shell'>
+            <div id='lesson_info' class="section_inner"></div>
+        </div>
+        <div id='lesson_list_shell'>
+            <div id='lesson_list' class="section_inner lesson"></div>
+        </div>
+    </div>
 
-<link type="text/css" rel="stylesheet" href="./style.css" />
-
-<style>
-#course_info_shell{
-    background-color: var(--box-bg-color1);
-}
-#course_info{
-    display:flex;
-    justify-content: space-between;
-    padding: 6px;
-}
-
-#parent_title,#parent_title a {
-    font-size: 13px;
-    line-height: 2.4em;
-    font-weight: 500;
-    color: var(--tool-color);
-}
-</style>
-
-<div id='course_content' >
-    <div id='course_info_shell'><div id='course_info' class="section_inner"></div></div>
-    <div id='lesson_info_shell'><div id='lesson_info' class="section_inner"></div></div>
-    <div id='lesson_list_shell'><div id='lesson_list' class="section_inner lesson"></div></div>
-</div>
-
-<script>
-lesson_load("<?php echo $_GET["id"]; ?>");
-</script>
-<?php
-include "../pcdl/html_foot.php";
-?>
+    <script>
+        lesson_load("<?php echo $_GET["id"]; ?>");
+    </script>
+    <?php
+    include "../pcdl/html_foot.php";
+    ?>

+ 48 - 51
app/course/style.css

@@ -1,93 +1,90 @@
 #course_frame {
-	display: flex;
+    display: flex;
 }
+
 #course_content {
-	margin: 0;
-	padding: 0;
-}
-#lesson_list {
+    margin: 0;
+    padding: 0;
 }
+
 #course_info_head_1 {
-	display: flex;
-}
-#course_info_head_face {
-	width: 200px;
-	height: 200px;
-	padding: 12px;
+    display: flex;
 }
+
 #course_info_head_face img {
-	width: 100%;
-	border-radius: 12px;
+    width: 100%;
+    border-radius: 12px;
 }
+
 .section_inner {
-	max-width: 960px;
-	margin: 0 auto;
+    max-width: 960px;
+    margin: 0 auto;
 }
+
 #course_info_head_title {
-	padding: 12px 0;
+    padding: 12px 0;
 }
+
 #course_title {
-	font-size: 22px;
-	font-weight: 700;
+    font-size: 22px;
+    font-weight: 700;
 }
 
 #course_subtitle {
-	font-size: 13px;
-	font-weight: 600;
-	padding: 10px 0;
+    font-size: 13px;
+    font-weight: 600;
+    padding: 10px 0;
 }
+
 #lesson_list_shell {
-	background-color: var(--drop-bg-color);
+    padding: 2rem 1rem;
+    background-color: #f5f5f5;
 }
-.course_info_block {
-	border-top: 1px solid var(--box-bg-color2);
-	padding: 10px 5px;
+
+
 }
-.course_info_block:first-child {
-	border-top: none;
+.course_info_block {
+    padding: 1rem 0;
 }
 .course_info_block h2 {
-	font-size: 16px;
-}
-#lesson_list {
-	display: flex;
-	flex-wrap: wrap;
+    font-size: 16px;
 }
 #lesson_list .lesson_card {
-	width: 50%;
-	padding: 15px;
+    width: 50%;
+    padding: 15px;
 }
 .datatime {
-	display: inline;
-
-	padding: 1px 4px;
+    display: inline;
+    padding: 1px 4px;
 }
 .not_started {
-	background-color: orangered;
-	color: var(--bg-color);
+    background-color: orangered;
+    color: var(--bg-color);
 }
 .in_progress,
 .already_over {
-	color: var(--btn-hover-bg-color);
+    color: var(--btn-hover-bg-color);
 }
 .lesson_card .title {
-	padding: 5px;
-	font-size: 17px;
-	font-weight: 600;
+    padding: 5px;
+    font-size: 17px;
+    font-weight: 600;
 }
 .curr_lesson {
-	border-left: 2px solid var(--tool-bt-bg-color1);
+    border-left: 2px solid var(--tool-bt-bg-color1);
 }
 .curr_lesson a {
-	color: var(--main-color);
+    color: var(--main-color);
 }
 .not_curr_lesson {
-	border-left: 2px solid var(--border-line-color);
-	color: gray;
+    border-left: 2px solid var(--border-line-color);
+    color: gray;
 }
 .not_curr_lesson a {
-	color: gray;
-}
-#course_info_head_2 {
-	padding: 10px 0;
+    color: gray;
 }
+#lesson_info_head_2 {
+    padding: 1rem 0;
+    border-top: 1px solid var(--border-line-color);
+    border-bottom: 1px solid var(--border-line-color);
+}

+ 168 - 72
app/doc/fork.php

@@ -1,12 +1,19 @@
 <?php
-/*
+/*拷贝其他人的文件
 *
 *
 */
-
+require_once '../studio/index_head.php';
+?>
+<body id="file_list_body" >
+<?php
     require_once "../public/_pdo.php";
     require_once "../public/function.php";
-    require_once "../path.php";
+	require_once "../path.php";
+
+	require_once '../studio/index_tool_bar.php';
+
+	echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
 
     if($_COOKIE["uid"]){
         $uid=$_COOKIE["uid"];
@@ -15,13 +22,91 @@
         echo "尚未登录";
         echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
         exit;
-    }
-    PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-    if(isset($_GET["doc_id"])){
-        $doc_id=$_GET["doc_id"];
-        $query = "select * from fileindex where id='{$doc_id}' ";
-        $Fetch = PDO_FetchAll($query);
-        $iFetch=count($Fetch);
+	}
+	if(isset($_GET["doc_id"])==false){
+		echo "没有 文档编号";
+		exit;
+	}
+	PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+	$doc_id=$_GET["doc_id"];
+	$query = "select * from fileindex where id= ? ";
+	$Fetch = PDO_FetchAll($query,array($doc_id));
+	$iFetch=count($Fetch);
+	if($iFetch>0){
+		//文档信息
+		$mbook=$Fetch[0]["book"];
+		$paragraph=$Fetch[0]["paragraph"];
+	}
+
+	if(isset($_GET["channel"])==false){
+		echo '<div class="file_list_block">';
+		echo "<h2>选择一个空白的版风存储新的文档</h2>";
+		echo "<form action='fork.php' method='get'>";
+		echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+		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;display:flex;">';
+		
+			echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+			echo '<input name="channel" 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:3;padding-bottom:5px;">'.$row["lang"].'</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='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+			$FetchWBW = PDO_FetchOne($query);
+			echo '</div>';
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			if($FetchWBW==0){
+				echo $_local->gui->blank;
+			}
+			else{
+				echo $FetchWBW.$_local->gui->para;
+				echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+			}
+			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='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+			$FetchWBW = PDO_FetchOne($query);
+			echo '</div>';
+			echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+			if($FetchWBW==0){
+				echo $_local->gui->blank;
+			}
+			else{
+				echo $FetchWBW.$_local->gui->para;
+			}
+			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 "<input type='submit' />";
+		echo "</form>";
+		echo "</div>";
+		exit;
+	}
+    
+	//if(isset($_GET["doc_id"]))
+	{
+		PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+		$doc_id=$_GET["doc_id"];
+		$query = "select * from fileindex where id= ? ";
+		$Fetch = PDO_FetchAll($query,array($doc_id));
+		$iFetch=count($Fetch);
         if($iFetch>0){
             //文档信息
             $orgFileInfo = $Fetch[0];
@@ -97,23 +182,25 @@
                                     $stmt = $dbhSent->prepare($query);
                                     $stmt->execute(array($blockid));
                                     $fBlock = $stmt->fetchAll(PDO::FETCH_ASSOC);
-                                    $newBlockId = UUID::V4();
-                                    $newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
+									$newBlockId = UUID::V4();
+									//不复刻译文
+                                    //$newDocBlockList[]=array('type' => 2,'block_id' => $newBlockId);
                                     $arrSentBlockTransform[$fBlock[0]["id"]] = $newBlockId;
                                     if(count($fBlock)>0){
-                                        array_push( $arrSentNewBlock,array($newBlockId,
-                                                                        $fBlock[0]["id"],
-                                                                        $fBlock[0]["book"],
-                                                                        $fBlock[0]["paragraph"],
-                                                                        $_COOKIE["userid"],
-                                                                        $fBlock[0]["lang"],
-                                                                        $fBlock[0]["author"],
-                                                                        $fBlock[0]["editor"],
-                                                                        $fBlock[0]["tag"],
-                                                                        $fBlock[0]["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrSentNewBlock,
+													array($newBlockId,
+                                                          $fBlock[0]["id"],
+                                                          $fBlock[0]["book"],
+                                                          $fBlock[0]["paragraph"],
+                                                          $_COOKIE["userid"],
+                                                          $fBlock[0]["lang"],
+                                                          $fBlock[0]["author"],
+                                                          $fBlock[0]["editor"],
+                                                          $fBlock[0]["tag"],
+                                                          $fBlock[0]["status"],
+                                                          mTime(),
+                                                          mTime()
+                                                        ));
                                     }
 
                                     $query = "select * from sentence where block_id= ? ";
@@ -121,22 +208,24 @@
                                     $stmtSent->execute(array($fBlock[0]["id"]));
                                     $fBlockData = $stmtSent->fetchAll(PDO::FETCH_ASSOC);
                                     foreach($fBlockData as $value){
-                                        array_push( $arrSentNewBlockData,array(UUID::V4(),
-                                                                        $arrSentBlockTransform[$value["block_id"]],
-                                                                        $value["book"],
-                                                                        $value["paragraph"],
-                                                                        $value["begin"],
-                                                                        $value["end"],
-                                                                        $value["tag"],
-                                                                        $value["author"],
-                                                                        $_COOKIE["userid"],
-                                                                        $value["text"],
-                                                                        $value["language"],
-                                                                        $value["ver"],
-                                                                        $value["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrSentNewBlockData,
+													array(UUID::V4(),
+														$arrSentBlockTransform[$value["block_id"]],
+														$value["book"],
+														$value["paragraph"],
+														$value["begin"],
+														$value["end"],
+														$value["channal"],
+														$value["tag"],
+														$value["author"],
+														$_COOKIE["userid"],
+														$value["text"],
+														$value["language"],
+														$value["ver"],
+														$value["status"],
+														mTime(),
+														mTime()
+													));
 
                                     }
                                     
@@ -147,7 +236,8 @@
                                 break;
                                 case 5:
                                 break;
-                                case 6:
+								case 6: 
+									#逐词解析
                                     $blockid = $blocks[$i]->block_id;
                                     $query = "select * from wbw_block where id= ? ";
                                     $stmt = $dbhWBW->prepare($query);
@@ -157,17 +247,19 @@
                                     $newDocBlockList[]=array('type' => 6,'block_id' => $newBlockId);
                                     $arrBlockTransform[$fBlock[0]["id"]] = $newBlockId;
                                     if(count($fBlock)>0){
-                                        array_push( $arrNewBlock,array($newBlockId,
-                                                                        $fBlock[0]["id"],
-                                                                        $_COOKIE["userid"],
-                                                                        $fBlock[0]["book"],
-                                                                        $fBlock[0]["paragraph"],
-                                                                        $fBlock[0]["style"],
-                                                                        $fBlock[0]["lang"],
-                                                                        $fBlock[0]["status"],
-                                                                        mTime(),
-                                                                        mTime()
-                                                                    ));
+										array_push( $arrNewBlock,
+													array($newBlockId,
+														$fBlock[0]["id"],
+														$_GET["channel"],
+														$_COOKIE["userid"],
+														$fBlock[0]["book"],
+														$fBlock[0]["paragraph"],
+														$fBlock[0]["style"],
+														$fBlock[0]["lang"],
+														$fBlock[0]["status"],
+														mTime(),
+														mTime()
+													));
                                     }
 
                                     $query = "select * from wbw where block_id= ? ";
@@ -175,18 +267,19 @@
                                     $stmtWBW->execute(array($fBlock[0]["id"]));
                                     $fBlockData = $stmtWBW->fetchAll(PDO::FETCH_ASSOC);
                                     foreach($fBlockData as $value){
-                                        array_push( $arrNewBlockData,array(UUID::V4(),
-                                                                        $arrBlockTransform[$value["block_id"]],
-                                                                        $value["book"],
-                                                                        $value["paragraph"],
-                                                                        $value["wid"],
-                                                                        $value["word"],
-                                                                        $value["data"],
-                                                                        mTime(),
-                                                                        mTime(),
-                                                                        $value["status"],
-                                                                        $_COOKIE["userid"]
-                                                                    ));
+										array_push( $arrNewBlockData,
+													array(UUID::V4(),
+														$arrBlockTransform[$value["block_id"]],
+														$value["book"],
+														$value["paragraph"],
+														$value["wid"],
+														$value["word"],
+														$value["data"],
+														mTime(),
+														mTime(),
+														$value["status"],
+														$_COOKIE["userid"]
+													));
 
                                     }
                                 break;
@@ -200,10 +293,9 @@
                         
                         if(count($arrNewBlock)>0){
                             $dbhWBW->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 (?,?,?,?,?,?,?,?,?,?,?)";
                             $stmtNewBlock = $dbhWBW->prepare($query);
                             foreach($arrNewBlock as $oneParam){
-                                //print_r($oneParam);
                                 $stmtNewBlock->execute($oneParam);
                             }
                             // 提交更改 
@@ -239,10 +331,11 @@
                                 echo "new wbw $count recorders.";
                             }   
                         }
-                        
+						
+						//不复刻译文
                         
                         //译文 block数据块
-                        
+                        /*
                         if(count($arrSentNewBlock)>0){
                             $dbhSent->beginTransaction();
                             $query="INSERT INTO sent_block ('id','parent_id','book','paragraph','owner','lang','author','editor','tag','status','modify_time','receive_time') VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
@@ -267,7 +360,7 @@
                         if(count($arrSentNewBlockData)>0){
                             // 开始一个事务,逐词解析数据 关闭自动提交
                             $dbhSent->beginTransaction();
-                            $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
+                            $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','channal','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
                             $stmtSentData = $dbhSent->prepare($query);
                             foreach($arrSentNewBlockData as $oneParam){
                                 $stmtSentData->execute($oneParam);
@@ -284,7 +377,7 @@
                                 echo "new translation $count recorders.";
                             }   
                         }
-                        
+                        */
 
                         //插入记录到文件索引
                         $filesize=0;
@@ -360,5 +453,8 @@
         }
     }
 
+	echo "</div>";
+?>
 
-?>
+</body>
+</html>

+ 192 - 69
app/doc/pcs2db.php

@@ -7,27 +7,125 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-echo "<h2>转换pcs 到数据库格式</h2>";
-$dir = _DIR_USER_BASE_.'/'.$_COOKIE["userid"]._DIR_MYDOCUMENT_;
+require_once '../studio/index_head.php';
+echo '<body id="file_list_body" >';
+echo '<div class="index_inner" style="    margin-left: 18em;margin-top: 5em;">';
+
+echo "<h2>转换PCS 到数据库格式</h2>";
+
+if($_COOKIE["uid"]){
+	$uid=$_COOKIE["uid"];
+}
+else{
+	echo "尚未登录";
+	echo "<h3><a href='../ucenter/index.php?op=login'>登录</a>后才可以打开文档 </h3>";
+	exit;
+}
+if(isset($_GET["doc_id"])==false){
+	echo "没有 文档编号";
+	exit;
+}
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
-$query = "select file_name, doc_info, modify_time from fileindex where id='".$_GET["doc_id"]."' ";
-$Fetch = PDO_FetchAll($query);
+$doc_id=$_GET["doc_id"];
+$query = "SELECT * from fileindex where id= ? ";
+$Fetch = PDO_FetchAll($query,array($doc_id));
+$iFetch=count($Fetch);
+if($iFetch>0){
+	//文档信息
+	$mbook=$Fetch[0]["book"];
+	$paragraph=$Fetch[0]["paragraph"];
+}
+
+if(isset($_GET["channel"])==false){
+	echo '<div class="file_list_block">';
+	echo "<h2>选择一个空白的版风存储新的文档</h2>";
+	echo "<form action='pcs2db.php' method='get'>";
+	echo "<input type='hidden' name='doc_id' value='{$_GET["doc_id"]}' />";
+	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;display:flex;">';
+	
+		echo '<div class="pd-10"  style="max-width:2em;flex:1;">';
+		echo '<input name="channel" 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:3;padding-bottom:5px;">'.$row["lang"].'</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='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+		$FetchWBW = PDO_FetchOne($query);
+		echo '</div>';
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		if($FetchWBW==0){
+			echo $_local->gui->blank;
+		}
+		else{
+			echo $FetchWBW.$_local->gui->para;
+			echo "<a href='../studio/editor.php?op=openchannal&book=$book&para={$paraList}&channal={$row["id"]}'>open</a>";
+		}
+		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='{$mbook}' and paragraph in ({$paragraph})  limit 0,100";
+		$FetchWBW = PDO_FetchOne($query);
+		echo '</div>';
+		echo '<div class="title" style="flex:2;padding-bottom:5px;">';
+		if($FetchWBW==0){
+			echo $_local->gui->blank;
+		}
+		else{
+			echo $FetchWBW.$_local->gui->para;
+		}
+		echo '</div>';
 
-if(count($Fetch)>0){
-    $file_modify_time = $Fetch[0]["modify_time"];
-    if(empty($Fetch[0]["doc_info"])){
-        $file = $dir.'/'.$Fetch[0]["file_name"];    
+		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 "<input type='submit' />";
+	echo "</form>";
+	echo "</div>";
+	exit;
+}
+
+$dir = _DIR_USER_DOC_.'/'.$_COOKIE["userid"]._DIR_MYDOCUMENT_;
+PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
+$query = "SELECT file_name, doc_info, modify_time from fileindex where id=? ";
+$Fetch = PDO_FetchRow($query,array($_GET["doc_id"]));
+
+if($Fetch===false){
+	echo "文件不存在";
+    exit;    
+}
+else{
+    $file_modify_time = $Fetch["modify_time"];
+    if(empty($Fetch["doc_info"])){
+        $file = $dir.'/'.$Fetch["file_name"];    
     }
     else{
-        echo "已经是数据库格式了。无需转换";
+		echo "已经是数据库格式了。无需转换";
+		exit;
     }
 }
-else{
-    echo "文件不存在";
-    exit;    
+if(!file_exists($file)){
+	echo "文件不存在";
+	exit;
 }
-
 $xml = simplexml_load_file($file);
+if($xml==false){
+	echo "载入pcs文件错误";
+	exit;
+}
 $xml_head = $xml->xpath('//head')[0];
 $strHead = "<head>";
 $strHead .= "<type>{$xml_head->type}</type>";
@@ -77,7 +175,6 @@ $dataBlock = $xml->xpath('//block');
                 echo "translate:".$block->info->book."<br>";
             break;
         }
-    
     }
 
     foreach($dataBlock as $block) {
@@ -86,8 +183,9 @@ $dataBlock = $xml->xpath('//block');
             break;
             case "translate":
                 //译文
-                $blockid = sprintf("%s",$block->info->id);
-                $newDocBlockList[]=array('type' => 2,'block_id' => $blockid);
+				$blockid = UUID::V4();
+				//译文不加入块列表 因为译文用channel解决 不需要渲染译文块
+                //$newDocBlockList[]=array('type' => 2,'block_id' => $blockid);
                 $arrSentBlockTransform["{$blockid}"] = $blockid;
                 //if(count($fBlock)>0)
                 {
@@ -118,46 +216,52 @@ $dataBlock = $xml->xpath('//block');
                     else{
                         $sent_end="";
                     }
-                    if(isset($sen->text)){
+                    if(isset($sen->text) && strlen(trim($sen->text))>0){
                         $paraText=$sen->text;
                         if( $block->info->level>0 &&  $block->info->level<8){
                             $toc.=$sen->text;
-                        }
+						}
+						array_push( $arrSentNewBlockData,
+									array(UUID::V4(),
+										$blockid,
+										$block->info->book,
+										$block->info->paragraph,
+										$sent_begin,
+										$sent_end,
+										"",
+										$block->info->author,
+										$_COOKIE["userid"],
+										$paraText,
+										mb_strlen($paraText,"UTF-8"),
+										$block->info->language,
+										"1",
+										"7",
+										$file_modify_time,
+										mTime(),
+										mTime(),
+										$_GET["channel"]
+									));						
                     }
-                    array_push( $arrSentNewBlockData,array(UUID::V4(),
-                                    $blockid,
-                                    $block->info->book,
-                                    $block->info->paragraph,
-                                    $sent_begin,
-                                    $sent_end,
-                                    "",
-                                    $block->info->author,
-                                    $_COOKIE["userid"],
-                                    $paraText,
-                                    $block->info->language,
-                                    "1",
-                                    "7",
-                                    $file_modify_time,
-                                    mTime()
-                                ));
                 }
             break;
             case "wbw":
-                $blockid = sprintf("%s",$block->info->id);
+                $blockid = UUID::V4();
                 $newDocBlockList[]=array('type' => 6,'block_id' => $blockid);
                 $arrBlockTransform["{$blockid}"] = $blockid;
                 {
-                    array_push( $arrNewBlock,array($blockid,
-                                                    "",
-                                                    $_COOKIE["userid"],
-                                                    $block->info->book,
-                                                    $block->info->paragraph,
-                                                    "",
-                                                    $block->info->language,
-                                                    "",
-                                                    $file_modify_time,
-                                                    mTime()
-                                                ));
+					array_push( $arrNewBlock,
+								array($blockid,
+								"",
+								$_GET["channel"],
+								$_COOKIE["userid"],
+								$block->info->book,
+								$block->info->paragraph,
+								"",
+								$block->info->language,
+								"",
+								$file_modify_time,
+								mTime()
+							));
                 }
 
                 $currWordId = "";
@@ -194,13 +298,13 @@ $dataBlock = $xml->xpath('//block');
                     $sWordData .= "<pali>{$word->pali}</pali>";
                     $sWordData .= "<real>{$word->real}</real>";
                     $sWordData .= "<id>{$word->id}</id>";
-                    $sWordData .= "<type status=\"0\">{$word->type}</type>";
-                    $sWordData .= "<gramma status=\"0\">{$word->gramma}</gramma>";
-                    $sWordData .= "<mean status=\"0\">{$word->mean}</mean>";
-                    $sWordData .= "<org status=\"0\">{$word->org}</org>";
-                    $sWordData .= "<om status=\"0\">{$word->om}</om>";
-                    $sWordData .= "<case status=\"0\">{$word->case}</case>";
-                    $sWordData .= "<note status=\"0\">{$word->note}</note>";
+                    $sWordData .= "<type status='0'>{$word->type}</type>";
+                    $sWordData .= "<gramma status='0'>{$word->gramma}</gramma>";
+                    $sWordData .= "<mean status='0'>{$word->mean}</mean>";
+                    $sWordData .= "<org status='0'>{$word->org}</org>";
+                    $sWordData .= "<om status='0'>{$word->om}</om>";
+                    $sWordData .= "<case status='0'>{$word->case}</case>";
+                    $sWordData .= "<note status='0'>{$word->note}</note>";
                     $sWordData .= "<style>{$word->style}</style>";
                     $sWordData .= "<status>{$word->status}</status>";
                     $sWordData .= "<parent>{$word->parent}</parent>";
@@ -221,18 +325,19 @@ $dataBlock = $xml->xpath('//block');
 
                      $iWordCount++;
                 }
-                array_push( $arrNewBlockData,array(UUID::V4(),
-                $blockid,
-                $block->info->book,
-                $block->info->paragraph,
-                $word_id,
-                $word->real,
-                $sWordData,
-                $file_modify_time,
-                mTime(),
-                $word->status,
-                $_COOKIE["userid"]
-            ));
+				array_push( $arrNewBlockData,
+							array(UUID::V4(),
+							$blockid,
+							$block->info->book,
+							$block->info->paragraph,
+							$word_id,
+							$word->real,
+							$sWordData,
+							$file_modify_time,
+							mTime(),
+							$word->status,
+							$_COOKIE["userid"]
+            			));
             break;
             case 2:
 
@@ -241,12 +346,26 @@ $dataBlock = $xml->xpath('//block');
 
     }
     
-    //逐词解析block数据块
+    //逐词解析block数据块结束
 
 
+	#插入逐词解析块数据
     if(count($arrNewBlock)>0){
         $dbhWBW->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 (?,?,?,?,?,?,?,?,?,?,?)";
         $stmtNewBlock = $dbhWBW->prepare($query);
         foreach($arrNewBlock as $oneParam){
             $stmtNewBlock->execute($oneParam);
@@ -312,7 +431,7 @@ $dataBlock = $xml->xpath('//block');
     if(count($arrSentNewBlockData)>0){
         // 开始一个事务,逐词解析数据 关闭自动提交
         $dbhSent->beginTransaction();
-        $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','language','ver','status','modify_time','receive_time') VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?)";
+        $query="INSERT INTO sentence ('id','block_id','book','paragraph','begin','end','tag','author','editor','text','strlen','language','ver','status','modify_time','receive_time','create_time','channal') VALUES (? , ? , ? , ? , ? ,?, ? , ? , ? , ? , ? , ? , ? , ? , ?, ? , ? ,?)";
         $stmtSentData = $dbhSent->prepare($query);
         foreach($arrSentNewBlockData as $oneParam){
             $stmtSentData->execute($oneParam);
@@ -374,4 +493,8 @@ $dataBlock = $xml->xpath('//block');
     }          
                 
 }
-?>
+?>
+
+</div>
+</body>
+</html>

+ 1 - 0
app/install/step1.php

@@ -28,6 +28,7 @@ $dir[]=_DIR_DICT_SYSTEM_;
 $dir[]=_DIR_DICT_3RD_;
 
 $dir[]=_DIR_USER_BASE_;
+$dir[]=_DIR_USER_DOC_;
 $dir[]=_DIR_PALI_CSV_;
 $dir[]=_DIR_TEMP_;
 $dir[]=_DIR_LOG_;

+ 54 - 0
app/palicanon/get_chapter_children.php

@@ -0,0 +1,54 @@
+<?php
+require_once '../path.php';
+
+$dns = "sqlite:"._FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+$dns = "sqlite:"._FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+if(isset($_GET["book"])){
+	$book = $_GET["book"];
+}
+if(isset($_GET["para"])){
+	$para = $_GET["para"];
+}
+
+$query = "SELECT chapter_len FROM pali_text WHERE book = ? and paragraph = ?";
+$stmt = $dbh_pali_text->prepare($query);
+$stmt->execute(array($book,$para));
+$paraInfo = $stmt->fetch(PDO::FETCH_ASSOC);
+if($paraInfo){
+	$query = "SELECT level FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level<8 order by level ASC limit 0,1";
+	$stmt = $dbh_pali_text->prepare($query);
+	$stmt->execute(array($book,$para+1,$para+$paraInfo["chapter_len"]));
+	$paraMax = $stmt->fetch(PDO::FETCH_ASSOC);
+	if($paraMax){
+		$query = "SELECT book, paragraph, level , toc as title FROM pali_text WHERE book = ? and (paragraph between ? and ?) and level = ?  limit 0,1000";
+		$stmt = $dbh_pali_text->prepare($query);
+		$stmt->execute(array($book,$para,$para+$paraInfo["chapter_len"],$paraMax["level"]));
+		$paraList = $stmt->fetchAll(PDO::FETCH_ASSOC);	
+		foreach ($paraList as $key => $value) {
+			# 查进度
+			$query = "SELECT lang, all_trans from progress_chapter where book=? and para=?";
+			$stmt = $dbh_toc->prepare($query);
+			$sth_toc = $dbh_toc->prepare($query);
+			$sth_toc->execute(array($book,$para));
+			$paraProgress = $sth_toc->fetchAll(PDO::FETCH_ASSOC);
+			$paraList[$key]["progress"]=$paraProgress;
+		}
+		echo json_encode($paraList, JSON_UNESCAPED_UNICODE);
+	}
+	else{
+		echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+	}
+	
+}
+else{
+	echo json_encode(array(), JSON_UNESCAPED_UNICODE);
+}
+
+
+?>

+ 43 - 3
app/palicanon/index.php

@@ -1,5 +1,5 @@
 <?PHP
-include "../pcdl/html_head.php";
+require_once "../pcdl/html_head.php";
 ?>
 
 <body>
@@ -96,7 +96,7 @@ include "../pcdl/html_head.php";
 
         .sutta_row div {
             padding: 10px;
-            display: flex;
+            /*display: flex;*/
             justify-items: center;
         }
 
@@ -104,6 +104,34 @@ include "../pcdl/html_head.php";
             background-color: var(--drop-bg-color);
         }
 
+		.c_level_1 {
+			padding-top: 15px;
+			padding-bottom: 15px;
+			background-color: var(--main-color1);
+		}
+		.c_level_1 .chapter_title{
+			font-size:120%;
+			font-weight:700;
+		}
+		#book_list{
+			display: flex;
+			flex-wrap: wrap;
+		}
+		.chapter_list{
+			display:none;
+		}
+		.chapter_book{
+			display:block;
+		}
+		.chapter_progress{
+			display:block;
+		}
+		.parent_chapter{
+			width:350px;
+		}
+		.parent_chapter .chapter_book,.parent_chapter .chapter_progress{
+			display:none;
+		}
         @media screen and (max-width:800px) {
             .sutta_row {
                 grid-template-columns: 100px 1fr 1fr;
@@ -150,8 +178,20 @@ include "../pcdl/html_head.php";
     echo "</div>";
     echo '</div>';
     ?>
-    <div id="book_list" class='index_inner' style='display: flex;flex-wrap: wrap;'>
+	<div class='index_inner'>
+	<div id="chapter_shell" style="display:flex;" >
 
+    <div id="book_list" class="chapter_list" list="1" >
+    </div>
+
+    <div id="chapter_list_1" class="chapter_list"  >
+    </div>
+    <div id="chapter_list_2" class="chapter_list" >
+    </div>
+    <div id="chapter_list_3" class="chapter_list" >
+    </div>
+
+    </div>
     </div>
 
     <script>

+ 41 - 4
app/palicanon/palicanon.js

@@ -90,19 +90,21 @@ function tag_changed() {
 					}
 				}
 
+				let level_class = "c_level_" + iterator[0].level;
 				//html += "<div style='width:100%;'>";
-				html += "<div class='sutta_row' >";
+				html += "<div class='sutta_row  " + level_class + "' >";
 				html += "<div class='sutta_box'>" + tag0 + "</div>";
+
 				html +=
-					"<div class='sutta_box'><a href='../reader/?view=chapter&book=" +
+					"<div class='chapter_title'><a href='../reader/?view=chapter&book=" +
 					iterator[0].book +
 					"&para=" +
 					iterator[0].para +
 					"' target = '_blank'>" +
 					iterator[0].title +
 					"</a></div>";
-				html += "<div class='sutta_box'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
-				html += "<div class='sutta_tag'>tag=" + iterator[0].tag + "</div>";
+				html += "<div class='chapter_book'>book:" + iterator[0].book + " para:" + iterator[0].para + "</div>";
+				html += "<div class='chapter_progress'>tag=" + iterator[0].tag + "</div>";
 				html += "</div>";
 				//html += "</div>";
 			}
@@ -120,6 +122,41 @@ function tag_changed() {
 		}
 	);
 }
+
+function palicanon_load_chapter(book, para) {
+	$.get(
+		"get_chapter_children.php",
+		{
+			book: book,
+			para: para,
+		},
+		function (data, status) {
+			let arrChapterList = JSON.parse(data);
+			let html = "";
+			for (const iterator of arrChapterList) {
+				html += palicanon_render_chapter_row(iterator);
+			}
+			$("#chapter_list_1").html(html);
+			$("#chapter_list_1").show();
+			$("#book_list").addClass("parent_chapter");
+		}
+	);
+}
+function palicanon_render_chapter_row(chapter) {
+	let html = "";
+	html += "<div class='sutta_row' >";
+	html += "<div class='chapter_title'><a>" + chapter.title + "</a></div>";
+	html += "<div class='chapter_book'>book:" + chapter.book + " para:" + chapter.para + "</div>";
+	html += "<div class='chapter_progress'>";
+	if (chapter.progress) {
+		for (const iterator of chapter.progress) {
+			html += "<div>" + iterator.lang + "-" + iterator.all_trans + "</div>";
+		}
+	}
+	html += "</div>";
+	html += "</div>";
+	return html;
+}
 function tag_get_local_word(word) {
 	let termKey = term_lookup_my(word, "", getCookie("userid"), getCookie("language"));
 	if (termKey) {

+ 2 - 1
app/path.php

@@ -21,7 +21,7 @@ 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_sim.db3");
-//define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sent_sim.db3");
+define("_FILE_DB_PALI_TOC_" , __DIR__."/../tmp/appdata/palicanon/pali_toc.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");
@@ -63,6 +63,7 @@ define("_DIR_BOOK_INDEX_" , __DIR__."/../app/public/book_index");
 
 /*user data*/
 define("_DIR_USER_BASE_" , __DIR__."/../tmp/user");
+define("_DIR_USER_DOC_" , __DIR__."/../tmp/user_doc");
 define("_DIR_USER_IMG_" , __DIR__."/../tmp/user/media/3");
 define("_DIR_USER_IMG_LINK_" , "../../tmp/user/media/3");
 define("_DIR_MYDOCUMENT_" , "/my_document");

+ 1 - 1
app/studio/dom_http.php

@@ -24,7 +24,7 @@ PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 $query="select file_name from fileindex where user_id='{$_COOKIE["uid"]}' AND  id='{$fileid}'";
 $Fetch = PDO_FetchOne($query);
 $purefilename=$Fetch;
-$FileName =_DIR_USER_BASE_."/".$_COOKIE["userid"]._DIR_MYDOCUMENT_."/".$Fetch;
+$FileName =_DIR_USER_DOC_."/".$_COOKIE["userid"]._DIR_MYDOCUMENT_."/".$Fetch;
 
 
 if($_COOKIE["uid"]){

+ 1 - 1
app/studio/editor.php

@@ -112,7 +112,7 @@ else{$currDevice="computer";}
 		
 		var g_device="computer";
 		var strSertch = location.search;
-		var gConfigDirMydocument="<?php echo _DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_; ?>/";
+		var gConfigDirMydocument="<?php echo _DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_; ?>/";
 		
 		if(strSertch.length>0){
 			strSertch = strSertch.substr(1);

+ 1 - 1
app/studio/file_index_refresh.php

@@ -3,7 +3,7 @@ include "../path.php";
 include "./_pdo.php";
 
 //获取服务器端文件列表
-$dir= _DIR_USER_BASE_.'/'.$_COOKIE["userid"].'/'._DIR_MYDOCUMENT_."/";
+$dir= _DIR_USER_DOC_.'/'.$_COOKIE["userid"].'/'._DIR_MYDOCUMENT_."/";
 
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 

+ 4 - 4
app/studio/project.php

@@ -408,7 +408,7 @@ switch($op){
 			
 			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 '在studio中新建版本风格</div>';
 			echo '<div class="author"  style="flex:1;padding-bottom:5px;"><button>New 新建</button></div>';
 			
 			echo '</div>';
@@ -435,7 +435,7 @@ switch($op){
 		$create_para=$paragraph;
 		
 		$FileName = $book."_".$paragraph."_".time().".pcs";
-		$sFullFileName=_DIR_USER_BASE_."/".$USER_ID._DIR_MYDOCUMENT_."/".$FileName;
+		$sFullFileName=_DIR_USER_DOC_."/".$USER_ID._DIR_MYDOCUMENT_."/".$FileName;
 		echo "filename:".$sFullFileName;
 		$myfile = fopen($sFullFileName, "w") or die("Unable to open file!");
 		
@@ -961,8 +961,8 @@ switch($op){
 							$query = "select userid from user where id='$owner'";
 							$FetchUid = PDO_FetchOne($query);
 							if($FetchUid){
-								$source=_DIR_USER_BASE_."/".$FetchUid._DIR_MYDOCUMENT_."/".$filename;
-								$dest=_DIR_USER_BASE_."/".$_COOKIE["userid"] ._DIR_MYDOCUMENT_."/".$filename;
+								$source=_DIR_USER_DOC_."/".$FetchUid._DIR_MYDOCUMENT_."/".$filename;
+								$dest=_DIR_USER_DOC_."/".$_COOKIE["userid"] ._DIR_MYDOCUMENT_."/".$filename;
 							}
 							echo "<div>源文件{$source}</div>";
 							echo "<div>目标文件{$dest}</div>";

+ 1 - 1
app/studio/project_load.php

@@ -7,7 +7,7 @@ require_once "../public/_pdo.php";
 PDO_Connect("sqlite:"._FILE_DB_FILEINDEX_);
 $query="select file_name from fileindex where user_id='{$_COOKIE["uid"]}' AND  id='{$_GET["id"]}'";
 $Fetch = PDO_FetchOne($query);
-$FileName =_DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_."/".$Fetch;
+$FileName =_DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_."/".$Fetch;
 if(file_exists($FileName)){
     echo file_get_contents($FileName);
 }

+ 15 - 11
app/term/term.js

@@ -670,17 +670,21 @@ function term_updata_translation() {
 
 function term_show_win(guid, keyWord = "") {
 	if (guid == "") {
-		$(term_body).html(
-			"“" +
-				keyWord +
-				"”" +
-				gLocal.gui.no_created +
-				"<br /><button onclick=\"term_add_new('" +
-				keyWord +
-				"')\">" +
-				gLocal.gui.create_now +
-				"</button>"
-		);
+		if (typeof term_body == "undefined") {
+			term_edit_dlg_open("", keyWord);
+		} else {
+			$(term_body).html(
+				"“" +
+					keyWord +
+					"”" +
+					gLocal.gui.no_created +
+					"<br /><button onclick=\"term_add_new('" +
+					keyWord +
+					"')\">" +
+					gLocal.gui.create_now +
+					"</button>"
+			);
+		}
 	} else {
 		let currWord = term_lookup_my_id(guid);
 		if (currWord) {

+ 19 - 3
app/term/term_edit_dlg.js

@@ -21,8 +21,19 @@ function term_edit_dlg_init(title = gLocal.gui.dict_terms) {
 		],
 	});
 }
-function term_edit_dlg_open(id = "") {
+function term_edit_dlg_open(id = "", word = "") {
 	if (id == "") {
+		let newWord = new Object();
+		newWord.guid = "";
+		newWord.word = word;
+		newWord.meaning = "";
+		newWord.other_meaning = "";
+		newWord.tag = "";
+		newWord.note = "";
+		newWord.language = "zh";
+		newWord.channal = "";
+		let html = term_edit_dlg_render(newWord);
+		$("#term_edit_dlg_content").html(html);
 		$("#term_edit_dlg").dialog("open");
 	} else {
 		$.post(
@@ -43,7 +54,12 @@ function term_edit_dlg_open(id = "") {
 function term_edit_dlg_render(word = "") {
 	if (word == "") {
 		word = new Object();
-		word.pali = "";
+		word.guid = "";
+		word.word = pali;
+		word.meaning = "";
+		word.other_meaning = "";
+		word.tag = "";
+		word.note = "";
 	}
 	let output = "";
 	output += "<form action='##' id='form_term'>";
@@ -71,7 +87,7 @@ function term_edit_dlg_render(word = "") {
 	output += "<fieldset>";
 	output += "<legend>" + gLocal.gui.other_meaning + "</legend>";
 	output +=
-		"<input type='input' id='term_edit_form_othermeaning name='mean2' value='" +
+		"<input type='input' id='term_edit_form_othermeaning' name='mean2' value='" +
 		word.other_meaning +
 		"' placeholder=" +
 		gLocal.gui.optional +

+ 51 - 12
app/term/term_post.php

@@ -1,23 +1,36 @@
 <?php
+/*
+修改术语
+*/
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once '../public/function.php';
 
+#未登录不能修改
+if(isset($_COOKIE["userid"])==false){
+	$respond['status']=1;
+	$respond['message']="not yet log in";
+	echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+	exit;
+}
+
 $respond=array("status"=>0,"message"=>"");
 PDO_Connect("sqlite:"._FILE_DB_TERM_);
 
 if($_POST["id"]!=""){
-    $query="UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? ";
+	#更新
+    $query="UPDATE term SET meaning= ? ,other_meaning = ? , tag= ? ,channal = ? ,  language = ? , note = ? , receive_time= ?, modify_time= ?   where guid= ? and owner = ? ";
     $stmt = @PDO_Execute($query,array($_POST["mean"],
-                                        $_POST["mean2"],
-                                        $_POST["tag"],
-                                        $_POST["channal"],
-                                        $_POST["language"],
-                                        $_POST["note"],
-                                        mTime(),
-                                        mTime(),
-                                        $_POST["id"]
-                                                            ));
+                                      $_POST["mean2"],
+                                      $_POST["tag"],
+                                      $_POST["channal"],
+                                      $_POST["language"],
+                                      $_POST["note"],
+                                      mTime(),
+                                      mTime(),
+									  $_POST["id"],
+									  $_COOKIE["userid"]
+                                      ));
     if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
         $error = PDO_ErrorInfo();
         $respond['status']=1;
@@ -26,10 +39,36 @@ if($_POST["id"]!=""){
     else{
         $respond['status']=0;
         $respond['message']=$_POST["word"];
-    }		
+    }
 }
 else{
-
+	#新建
+	$parm[]=UUID::v4();
+	$parm[]=$_POST["word"];
+	$parm[]=pali2english($_POST["word"]);
+	$parm[]=$_POST["mean"];
+	$parm[]=$_POST["mean2"];
+	$parm[]=$_POST["tag"];
+	$parm[]=$_POST["channal"];
+	$parm[]=$_POST["language"];
+	$parm[]=$_POST["note"];
+	$parm[]=$_COOKIE["userid"];
+	$parm[]=0;
+	$parm[]=mTime();
+	$parm[]=mTime();
+	$parm[]=mTime();
+	$query="INSERT INTO term (id, guid, word, word_en, meaning, other_meaning, tag, channal, language,note,owner,hit,create_time,modify_time,receive_time ) 
+	VALUES (NULL, ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) "; 
+	$stmt = @PDO_Execute($query,$parm);
+    if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+        $error = PDO_ErrorInfo();
+        $respond['status']=1;
+        $respond['message']=$error[2].$query;
+    }
+    else{
+        $respond['status']=0;
+        $respond['message']=$_POST["word"];
+    }
 }
     
 

+ 2 - 2
app/ucenter/index.php

@@ -82,7 +82,7 @@ require_once "../public/function.php";
 				}
 				else{
 					//created user recorder 
-					$newUserPath=_DIR_USER_BASE_.'/'.$new_userid;
+					$newUserPath=_DIR_USER_DOC_.'/'.$new_userid;
 					$userDirMyDocument=$newUserPath._DIR_MYDOCUMENT_;
 					if(!file_exists($newUserPath)){
 						if(mkdir($newUserPath)){
@@ -132,7 +132,7 @@ require_once "../public/function.php";
 					if(isset($_COOKIE["url"])){
 						setcookie("pwd_set", "on", time()+60,"/");
 					}
-					$newUserPath=_DIR_USER_BASE_.'/'.$userid.'/';
+					$newUserPath=_DIR_USER_DOC_.'/'.$userid.'/';
 					if(!file_exists($newUserPath)){
 						echo "error:cannot find user dir:$newUserPath<br/>";
 					}

+ 1 - 1
app/ucenter/setting.php

@@ -24,7 +24,7 @@ require_once '../public/function.php';
 		
 		var g_device="computer";
 		var strSertch = location.search;
-		var gConfigDirMydocument="<?php echo _DIR_USER_BASE_."/".$userid._DIR_MYDOCUMENT_; ?>/";
+		var gConfigDirMydocument="<?php echo _DIR_USER_DOC_."/".$userid._DIR_MYDOCUMENT_; ?>/";
 		
 		if(strSertch.length>0){
 			strSertch = strSertch.substr(1);

+ 22 - 0
app/upgrade/pali_toc.sql

@@ -0,0 +1,22 @@
+--
+-- 由SQLiteStudio v3.1.1 产生的文件 周五 2月 12 16:26:34 2021
+--
+-- 文本编码:UTF-8
+--
+PRAGMA foreign_keys = off;
+BEGIN TRANSACTION;
+
+-- 表:course
+CREATE TABLE course (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lesson_id CHAR (36), start INTEGER, "end" INTEGER);
+
+-- 表:nissaya
+CREATE TABLE nissaya (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), media INTEGER);
+
+-- 表:progress
+CREATE TABLE progress (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), all_strlen INTEGER, public_strlen INTEGER);
+
+-- 表:progress_chapter
+CREATE TABLE progress_chapter (id INTEGER PRIMARY KEY AUTOINCREMENT, book INTEGER, para INTEGER, lang CHAR (8), all_trans REAL, public REAL);
+
+COMMIT TRANSACTION;
+PRAGMA foreign_keys = on;

+ 148 - 0
app/upgrade/upgrade_pali_toc.php

@@ -0,0 +1,148 @@
+<?php
+#升级段落完成度数据库
+require_once '../path.php';
+
+
+$dns = "sqlite:"._FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+
+$dns = "sqlite:"._FILE_DB_SENTENCE_;
+$dbh_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+
+$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
+$dbh_pali_sent = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_pali_sent->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+
+$dns = "sqlite:"._FILE_DB_PALITEXT_;
+$dbh_pali_text = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+$dbh_pali_text->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
+$valid_book = array();
+
+#第一步 查询有多少书有译文
+$query = "SELECT book from sentence where strlen>0 and begin<>''  and language<>'' and book <1000  group by book";
+$stmt = $dbh_sent->prepare($query);
+$stmt->execute();
+$valid_book = $stmt->fetchAll(PDO::FETCH_ASSOC);
+echo "book:".count($valid_book)."<br>\n";
+
+#第一步 查询语言
+$query = "SELECT language from sentence where strlen>0 and begin<>''  and language<>'' and book <1000   group by language";
+$stmt = $dbh_sent->prepare($query);
+$stmt->execute();
+$result_lang = $stmt->fetchAll(PDO::FETCH_ASSOC);
+echo "lang:".count($result_lang)."<br>\n";
+
+$query = "DELETE FROM progress WHERE 1";
+$sth_toc = $dbh_toc->prepare($query);
+$sth_toc->execute();
+$query = "DELETE FROM progress_chapter WHERE 1";
+$sth_toc = $dbh_toc->prepare($query);
+$sth_toc->execute();
+
+/* 开始一个事务,关闭自动提交 */
+$dbh_toc->beginTransaction();
+$query = "INSERT INTO progress (book, para , lang , all_strlen , public_strlen) VALUES (?, ?, ? , ? ,? )";
+$sth_toc = $dbh_toc->prepare($query);
+foreach ($result_lang as $lang) {
+	# 第二步 生成para progress 1,2,15,zh-tw
+	
+	#查询该语言有多少段
+	$query = "select book,paragraph from sentence where strlen>0 and language= ? and book<1000 group by book,paragraph";
+	$stmt = $dbh_sent->prepare($query);
+	$stmt->execute(array($lang["language"]));
+	$result_para = $stmt->fetchAll(PDO::FETCH_ASSOC);
+	foreach ($result_para as $para) {
+		
+		# 查询每个段落的等效巴利语字符数
+		$query = "select begin from sentence where strlen>0 and language= ? and book = ? and paragraph = ? and begin<>'' group by begin,end";
+		$stmt = $dbh_sent->prepare($query);
+		$stmt->execute(array($lang["language"],$para["book"],$para["paragraph"]));
+		$result_sent = $stmt->fetchAll(PDO::FETCH_ASSOC);
+		if(count($result_sent)>0){
+			echo "book:{$para["book"]} para: {$para["paragraph"]}\n";
+			#查询这些句子的总共等效巴利语字符数
+			$place_holders = implode(',', array_fill(0, count($result_sent), '?'));
+			$query = "select sum(length) as strlen from pali_sent where book = ? and paragraph = ? and begin in ($place_holders)";
+			$sth = $dbh_pali_sent->prepare($query);
+			$param = array();
+			$param[] = $para["book"];
+			$param[] = $para["paragraph"];
+			foreach ($result_sent as $sent) {
+				# code...
+				$param[] = (int)$sent["begin"];
+			}
+			$sth->execute($param);
+			$result_strlen = $sth->fetch(PDO::FETCH_ASSOC);
+			if($result_strlen){
+				$para_strlen = $result_strlen["strlen"];
+			}
+			else{
+				$para_strlen = 0;
+			}
+			$sth_toc->execute(array($para["book"],$para["paragraph"],$lang["language"],$para_strlen,0));
+		}
+	}
+}
+$dbh_toc->commit();
+if (!$sth_toc || ($sth_toc && $sth_toc->errorCode() != 0)) {
+	/*  识别错误且回滚更改  */
+	$sth_toc->rollBack();
+	$error = $dbh_toc->errorInfo();
+	echo "error:".$error[2]."\n";
+}
+
+#第三步生成 段落完成度库
+/* 开始一个事务,关闭自动提交 */
+$dbh_toc->beginTransaction();
+$query = "INSERT INTO progress_chapter (book, para , lang , all_trans,public) VALUES (?, ?, ? , ? ,? )";
+$sth_toc = $dbh_toc->prepare($query);
+
+foreach ($valid_book as $key => $book) {
+	echo "doing chapter in book ".$book["book"] ."\n";
+	# code...
+	$query = "SELECT paragraph , chapter_len from pali_text where level < 8 and book = ?";
+	$stmt = $dbh_pali_text->prepare($query);
+	$stmt->execute(array($book["book"]));
+	$result_chapter = $stmt->fetchAll(PDO::FETCH_ASSOC);
+	foreach ($result_chapter as $key => $chapter) {
+		# 查询巴利字符数
+		$query = "SELECT sum(strlen) as pali_strlen from pali_sent_index where book = ? and para between ? and ? ";
+		$stmt = $dbh_pali_sent->prepare($query);
+		$stmt->execute(array($book["book"],$chapter["paragraph"],$chapter["paragraph"]+$chapter["chapter_len"]));
+		$result_chapter_strlen = $stmt->fetch(PDO::FETCH_ASSOC);
+		if($result_chapter_strlen){
+			$pali_strlen = (int)$result_chapter_strlen["pali_strlen"];
+			# 译文等效字符数
+			foreach ($result_lang as $lang) {
+				$query = "SELECT sum(all_strlen) as all_strlen from progress where book = ? and (para between ? and ? )and lang = ?";
+				$stmt = $dbh_toc->prepare($query);
+				$stmt->execute(array($book["book"],$chapter["paragraph"],$chapter["paragraph"]+$chapter["chapter_len"],$lang["language"]));
+				$result_chapter_trans_strlen = $stmt->fetch(PDO::FETCH_ASSOC);
+				if($result_chapter_trans_strlen){
+					$tran_strlen = (int)$result_chapter_trans_strlen["all_strlen"];
+					if($tran_strlen>0){
+						$progress = $tran_strlen/$pali_strlen;
+						$sth_toc->execute(array($book["book"],$chapter["paragraph"],$lang["language"],$progress,0));
+						//echo "{$book["book"]},{$chapter["paragraph"]},{$lang["language"]},{$progress}\n";
+					}
+
+				}
+				#插入段落数据
+			}			
+		}
+	}
+}
+$dbh_toc->commit();
+if (!$sth_toc || ($sth_toc && $sth_toc->errorCode() != 0)) {
+	/*  识别错误且回滚更改  */
+	$sth_toc->rollBack();
+	$error = $dbh_toc->errorInfo();
+	echo "error:".$error[2]."\n";
+}
+
+?>

File diff suppressed because it is too large
+ 7 - 7
pali_title/98_title.csv


Some files were not shown because too many files changed in this diff