Kaynağa Gözat

Merge pull request #87 from visuddhinanda/master

简介支持markdown
visuddhinanda 5 yıl önce
ebeveyn
işleme
6b53ce59d3
3 değiştirilmiş dosya ile 52 ekleme ve 9 silme
  1. 30 7
      app/course/course.php
  2. 13 0
      app/course/course_get.php
  3. 9 2
      app/course/index.php

+ 30 - 7
app/course/course.php

@@ -48,18 +48,16 @@ echo '</div>';
 
 
 echo "<div  class='index_inner'>";
 echo "<div  class='index_inner'>";
 
 
-echo '<div class="card" style="margin:1em;">';
+echo '<div class="card" style="margin:1em;padding:10px;">';
     echo '<div class="title">';
     echo '<div class="title">';
     echo '简介';
     echo '简介';
     echo '</div>';
     echo '</div>';
-    echo '<div class="detail">';
-    echo $course_info["summary"];
+    echo '<div id="course_summary" class="detail">';
     echo '</div>';
     echo '</div>';
     echo '<div class="title">';
     echo '<div class="title">';
     echo '参考资料';
     echo '参考资料';
     echo '</div>';    
     echo '</div>';    
-    echo '<div class="detail">';
-    echo $course_info["attachment"];
+    echo '<div id="course_attachment"  class="detail">';
     echo '</div>';   
     echo '</div>';   
 echo '</div>';
 echo '</div>';
 
 
@@ -70,11 +68,36 @@ echo "</div>";
 
 
 ?>
 ?>
 </div>
 </div>
-<script src="../public/js/marked.js"></script>
 <script>
 <script>
     $("#main_video_win").height($("#main_video_win").width()*9/16);
     $("#main_video_win").height($("#main_video_win").width()*9/16);
+    $.get("../course/course_get.php",
+  {
+    id:"<?php echo $_GET["id"]; ?>"
+  },
+  function(data,status){
+      let arrLesson = JSON.parse(data);
+      if(arrLesson && arrLesson.length>0){
+        let summary = "";
+        try{
+            summary = marked(arrLesson[0]["summary"]);
+        }
+        catch(e){
+
+        }          
+        $("#course_summary").html(summary);
+
+        let attachment = "";
+        try{
+            attachment = marked(arrLesson[0]["attachment"]);
+        }
+        catch(e){
+
+        }          
+        $("#course_attachment").html(attachment);
+      }
+    });
 
 
-    $.get("../course/lesson_list.php",
+$.get("../course/lesson_list.php",
   {
   {
     id:"<?php echo $_GET["id"]; ?>"
     id:"<?php echo $_GET["id"]; ?>"
   },
   },

+ 13 - 0
app/course/course_get.php

@@ -0,0 +1,13 @@
+<?php
+//
+
+require_once "../path.php";
+require_once "../public/_pdo.php";
+
+global $PDO;
+PDO_Connect("sqlite:"._FILE_DB_COURSE_);
+$query = "select * from course where id = '{$_GET["id"]}'   limit 0,1";
+$fAllLesson = PDO_FetchAll($query);
+echo json_encode($fAllLesson, JSON_UNESCAPED_UNICODE);
+
+?>

+ 9 - 2
app/course/index.php

@@ -85,8 +85,15 @@ include "../pcdl/html_head.php";
 
 
             html += '<div style="flex:7;">';
             html += '<div style="flex:7;">';
             html +=  '<div class="title" style="padding-bottom:5px;font-size:110%;font-weight:600;"><a href="../course/course.php?id='+iterator.id+'">'+iterator.title+'</a></div>';
             html +=  '<div class="title" style="padding-bottom:5px;font-size:110%;font-weight:600;"><a href="../course/course.php?id='+iterator.id+'">'+iterator.title+'</a></div>';
-            html += '<div class="summary"  style="padding-bottom:5px;">'+iterator.subtitle+'</div>';
-            html += '<div class="summary"  style="padding-bottom:5px;">'+iterator.summary+'</div>';
+			html += '<div class="summary"  style="padding-bottom:5px;">'+iterator.subtitle+'</div>';
+			let summary = "";
+        try{
+            summary = marked(iterator.summary);
+        }
+        catch(e){
+
+        }      
+            html += '<div class="summary"  style="padding-bottom:5px;">'+summary+'</div>';
 
 
             html += '</div>';
             html += '</div>';