Sfoglia il codice sorgente

书的目录带有channel时显示channel的章节标题和完成度

visuddhinanda 3 anni fa
parent
commit
fe8cd164a5
2 ha cambiato i file con 30 aggiunte e 2 eliminazioni
  1. 3 1
      public/app/article/article.js
  2. 27 1
      public/app/reader/get_para1.php

+ 3 - 1
public/app/article/article.js

@@ -393,8 +393,10 @@ function palicanon_load() {
 				start: _start,
 				end: _end,
 			}
-            if(_channal !==""){
+            if(_channal !== ""){
+				param.channel = _channal;
                 for (const iterator of _channal.split(",")) {
+					//增加点击次数
                     OneHitChapter(_book,_par,iterator);
                 }
             }

+ 27 - 1
public/app/reader/get_para1.php

@@ -30,6 +30,10 @@ if (isset($_GET["begin"])) {
 if (isset($_GET["end"])) {
     $_end = $_GET["end"];
 }
+if (isset($_GET["channel"])) {
+    $_channel = $_GET["channel"];
+}
+
 $_view = $_GET["view"];
 
 $output["toc"] = array();
@@ -44,6 +48,10 @@ $output["owner"]="";
 $output["username"]=array("username"=>"","nickname"=>"");
 $output["status"]="";
 
+$dns = _FILE_DB_PALI_TOC_;
+$dbh_toc = new PDO($dns, _DB_USERNAME_, _DB_PASSWORD_, array(PDO::ATTR_PERSISTENT => true));
+$dbh_toc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
 if ($_view == "sent") {
     $output["content"] = "{{". $_book . "-" . $_para . "-". $_start . "-" . $_end . "}}";
     echo json_encode($output, JSON_UNESCAPED_UNICODE);
@@ -119,6 +127,9 @@ if ($FetchParInfo) {
     /*
     目录
     */
+	if(isset($_channel)){
+		$firstChannel = explode(',',$_channel)[0];
+	}
     $sTocOutput = "\n\n";
 	if(count($toc)>1){
 		$currLevel = $toc[0]["level"];
@@ -149,7 +160,22 @@ if ($FetchParInfo) {
 				# code...
 				$space .= "  ";
 			}
-			$sTocOutput .= $space . "- [{$sToc}](../article/index.php?view=chapter&book={$_book}&par={$value["paragraph"]})\n";
+			//目录进度
+			if(isset($firstChannel)){
+				$query = "SELECT title , progress FROM "._TABLE_PROGRESS_CHAPTER_."  WHERE book= ? AND para= ?  AND channel_id=?";
+				$sth_title = $dbh_toc->prepare($query);
+				$sth_title->execute(array($_book, $value["paragraph"], $firstChannel));
+				$trans_title = $sth_title->fetch(PDO::FETCH_ASSOC);
+				if ($trans_title) {
+					if(!empty($trans_title['title'])){
+						$sToc = $trans_title['title'];
+					}
+					$progress = "<".sprintf('%d',$trans_title['progress']*100)."%";
+				}else{
+					$progress = "";
+				}
+			}
+			$sTocOutput .= $space . "- [{$sToc}](../article/index.php?view=chapter&book={$_book}&par={$value["paragraph"]}){$progress}\n";
 		}		
 	}
 $sTocOutput .= "\n\n";