course.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?PHP
  2. include "../pcdl/html_head.php";
  3. ?>
  4. <body>
  5. <?php
  6. require_once("../pcdl/head_bar.php");
  7. ?>
  8. <style>
  9. #main_video_win iframe{
  10. width:100%;
  11. height:100%;
  12. }
  13. #course_frame{
  14. display:flex;
  15. }
  16. #course_content{
  17. flex:5;
  18. margin:1em;
  19. padding:10px;
  20. }
  21. #lesson_list{
  22. flex:5;
  23. height: calc(100%-100px);
  24. overflow-y: scroll;
  25. }
  26. </style>
  27. <?php
  28. //
  29. require_once "../path.php";
  30. require_once "../public/_pdo.php";
  31. require_once '../ucenter/function.php';
  32. require_once '../public/function.php';
  33. global $PDO;
  34. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  35. $query = "select * from course where id = '{$_GET["id"]}' limit 0,1";
  36. $Fetch = PDO_FetchAll($query);
  37. if(count($Fetch)==0)
  38. {
  39. echo "无法找到此课程。可能该课程已经被拥有者删除。";
  40. exit;
  41. }
  42. $course_info = $Fetch[0];
  43. ?>
  44. <div id='course_head_bar' style='background-color:var(--tool-bg-color1);padding:1em 10px 10px 10px;'>
  45. <div class='index_inner '>
  46. <div style='font-size:140%'>
  47. <?php
  48. echo "<a href='../uhome/course.php?userid={$course_info["teacher"]}'>";
  49. echo ucenter_getA($course_info["teacher"]);
  50. echo "</a>";
  51. echo " > ";
  52. echo $course_info["title"];
  53. echo "</div>";
  54. echo '<div class="summary" style="padding-bottom:5px;">'.$course_info["subtitle"].'</div>';
  55. echo '<div class="summary" style="">';
  56. echo '<button>'.$_local->gui->watch.'</button>';
  57. echo '<button>'.$_local->gui->sign_up.'</button>';
  58. echo '<button>'.$_local->gui->share.'</button></div>';
  59. echo "</div>";
  60. echo '</div>';
  61. echo "<div id='course_frame' class='index_inner'>";
  62. echo '<div id="course_content" style="">';
  63. echo '<div class="title">';
  64. echo $_local->gui->introduction;
  65. echo '</div>';
  66. echo '<div id="course_summary" class="detail">';
  67. echo '</div>';
  68. echo '<div class="title">';
  69. echo $_local->gui->attachment;
  70. echo '</div>';
  71. echo '<div id="course_attachment" class="detail">';
  72. echo '</div>';
  73. echo '</div>';
  74. ?>
  75. <div id='lesson_list'>
  76. </div>
  77. </div>
  78. <script>
  79. $("#main_video_win").height($("#main_video_win").width()*9/16);
  80. $.get("../course/course_get.php",
  81. {
  82. id:"<?php echo $_GET["id"]; ?>"
  83. },
  84. function(data,status){
  85. let arrLesson = JSON.parse(data);
  86. if(arrLesson && arrLesson.length>0){
  87. let summary = "";
  88. try{
  89. summary = marked(arrLesson[0]["summary"]);
  90. }
  91. catch(e){
  92. }
  93. $("#course_summary").html(summary);
  94. let attachment = "";
  95. try{
  96. attachment = marked(arrLesson[0]["attachment"]);
  97. }
  98. catch(e){
  99. }
  100. $("#course_attachment").html(attachment);
  101. }
  102. });
  103. $.get("../course/lesson_list.php",
  104. {
  105. id:"<?php echo $_GET["id"]; ?>"
  106. },
  107. function(data,status){
  108. let arrLesson = JSON.parse(data);
  109. let html="";
  110. for(const lesson of arrLesson){
  111. html+= '<div class="card" style="display:flex;margin:1em;padding:10px;">';
  112. html+= '<div style="flex:7;">';
  113. html+= '<div class="pd-10">';
  114. html+= '<div class="title" style="padding-bottom:5px;font-size:200%;font-weight:600;"><a href="../course/lesson.php?id='+lesson["id"]+'" style="color:var(--main-color);">'+lesson["title"]+'</a></div>';
  115. html += '<div style="overflow-y: scroll;max-height: 20em;">';
  116. let summary = "";
  117. try{
  118. summary = marked(lesson["summary"]);
  119. }
  120. catch{
  121. }
  122. html+= '<div class="summary" style="padding-bottom:5px;">'+summary+'</div>';
  123. let live = "";
  124. try{
  125. //live = marked(lesson["live"]);
  126. }
  127. catch{
  128. }
  129. html+= '<div class="summary" style="padding-bottom:5px;">'+live+'</div>';
  130. let replay = "";
  131. try{
  132. //replay = marked(lesson["replay"]);
  133. }
  134. catch{
  135. }
  136. html+= '<div class="summary" style="padding-bottom:5px;">'+replay+'</div>';
  137. let attachment = "";
  138. try{
  139. attachment = marked(lesson["attachment"]);
  140. }
  141. catch{
  142. }
  143. html+= '<div class="summary" style="padding-bottom:5px;">'+attachment+'</div>';
  144. html+= '</div>';
  145. html+= '</div>';
  146. html+= '</div>';
  147. html+= '<div style="flex:3;max-width:15em;">';
  148. let d = new Date();
  149. d.setTime(lesson["date"]);
  150. let strData = d.toLocaleDateString();
  151. let strTime = d.toLocaleTimeString();
  152. html+= '<div >'+gLocal.gui.date+':'+strData +'</div>';
  153. html+= '<div >'+gLocal.gui.time+':'+strTime +'</div>';
  154. let dt = lesson["duration"]/60;
  155. let sdt = "";
  156. if(dt>59){
  157. sdt += Math.floor(dt/60)+"小时";
  158. }
  159. let m = (dt % 60);
  160. if(m>0){
  161. sdt +=(dt % 60)+"分钟";
  162. }
  163. html+= "<div >"+gLocal.gui.duration+":"+sdt+"</div>";
  164. let now = new Date();
  165. let lesson_time="";
  166. if(now<lesson["date"]){
  167. lesson_time = gLocal.gui.not_started;
  168. }
  169. else if(now>lesson["date"] && now<(lesson["date"]+dt*1000)){
  170. lesson_time = gLocal.gui.in_progress;
  171. }
  172. else{
  173. lesson_time = gLocal.gui.already_over;
  174. }
  175. html+= '<div ><span class="lesson_status">'+lesson_time+'</span></div>';
  176. html+= '</div>';
  177. html+= '</div>';
  178. }
  179. $("#lesson_list").html(html);
  180. });
  181. </script>
  182. <?php
  183. include "../pcdl/html_foot.php";
  184. ?>