瀏覽代碼

添加文章

visuddhinanda 5 年之前
父節點
當前提交
c70e8f4a82

+ 11 - 0
app/article/article.js

@@ -110,3 +110,14 @@ function articel_load_collect(article_id) {
     }
   );
 }
+
+function set_channal(channalid) {
+  let url = "../article/index.php?id=" + _articel_id;
+  if (channalid != "") {
+    url += "&channal=" + channalid;
+  }
+  if (_display != "") {
+    url += "&display=" + _display;
+  }
+  location.assign(url);
+}

+ 48 - 0
app/article/article_add_dlg.js

@@ -0,0 +1,48 @@
+var _dlg_div;
+function article_add_dlg_init(div) {
+  _dlg_div = div;
+  let html = "";
+  html += "<div id='article_add_dlg'>";
+  html += "<div >";
+  html += "<div >Title</div>";
+  html += "<input type='input' id='article_add_title' />";
+  html += "</div>";
+  html += "<div>";
+  html += "</div>";
+  html += "<div style='display:flex;'>";
+  html += "<button onclick='article_add_cancel()'>Cancel</button>";
+  html += "<button onclick='article_add_new()'>New</button>";
+  html += "</div>";
+  html += "</div>";
+
+  $("#" + div).append(html);
+}
+
+function article_add_dlg_show() {
+  $("#" + _dlg_div).show();
+}
+function article_add_dlg_hide() {
+  $("#" + _dlg_div).hide();
+}
+function article_add_cancel() {
+  article_add_dlg_hide();
+  $("#article_add_title").val("");
+}
+
+function article_add_new() {
+  $.post(
+    "../article/my_article_put.php",
+    {
+      title: $("#article_add_title").val(),
+    },
+    function (data) {
+      let error = JSON.parse(data);
+      if (error.status == 0) {
+        alert("ok");
+        article_add_cancel();
+      } else {
+        alert(error.message);
+      }
+    }
+  );
+}

+ 4 - 0
app/article/my_article.js

@@ -1,4 +1,8 @@
 var _display = "para";
+function my_article_init() {
+  my_article_list();
+  article_add_dlg_init("article_add_div");
+}
 function my_article_list() {
   $.get(
     "../article/list.php",

+ 12 - 4
app/article/my_article_index.php

@@ -1,9 +1,10 @@
 <?php
 require_once '../studio/index_head.php';
 ?>
-<body id="file_list_body" onLoad="my_article_list()">
+<body id="file_list_body" onLoad="my_article_init()">
 
 	<script language="javascript" src="../article/my_article.js"></script>
+	<script language="javascript" src="../article/article_add_dlg.js"></script>
 	<script >
 	var gCurrPage="article";
 	</script>
@@ -27,6 +28,14 @@ require_once '../studio/index_head.php';
 	.case_dropdown-content>.active{
 		background-color:gray;
 	}
+	.float_dlg{
+		display: none;
+    width: 15em;
+    position: absolute;
+    right: 0;
+    background-color: var(--btn-hover-bg-color);
+    padding: 10px;
+	}
 	</style>
 
 	<?php
@@ -40,13 +49,12 @@ require_once '../studio/index_head.php';
 				<div>
 					<span class="icon_btn_div">
 						<span class="icon_btn_tip"></span>
-						<button id="file_add" type="button" class="icon_btn" title=" ">
-							<a href="../course/my_course_index.php?op=new">
+						<button id="file_add" type="button" class="icon_btn" title=" " onclick="article_add_dlg_show()">
 							<svg class="icon">
 								<use xlink:href="../studio/svg/icon.svg#ic_add_circle"></use>
 							</svg>
-							</a>
 						</button>
+						<div id='article_add_div' class="float_dlg"></div>
 					</span>
 					
 					<span class="icon_btn_div">				

+ 19 - 0
app/article/my_article_put.php

@@ -0,0 +1,19 @@
+<?php
+require_once "../path.php";
+require_once "../public/_pdo.php";
+require_once '../public/function.php';
+require_once '../hostsetting/function.php';
+$respond=array("status"=>0,"message"=>"");
+PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
+
+$query="INSERT INTO article ( id,  title  , subtitle  , summary , content   , tag  , owner, setting  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
+$sth = $PDO->prepare($query);
+$sth->execute(array(UUID::v4() , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 1 , mTime() ,  mTime() , mTime() ));
+$respond=array("status"=>0,"message"=>"");
+if (!$sth || ($sth && $sth->errorCode() != 0)) {
+	$error = PDO_ErrorInfo();
+	$respond['status']=1;
+	$respond['message']=$error[2];
+}
+echo json_encode($respond, JSON_UNESCAPED_UNICODE);
+?>

+ 3 - 1
app/studio/css/style.css

@@ -4361,7 +4361,9 @@ note {
   display: none;
   text-align: center;
 }
-
+.icon_btn_div {
+  position: relative;
+}
 .icon_btn_div:hover .icon_btn_tip {
   display: inline-block;
 }

+ 4 - 2
app/term/note.js

@@ -242,8 +242,10 @@ function render_channal_list(channalinfo) {
   output += "<div>";
 
   output += "<div>";
-  output += "<a href='../wiki/wiki.php?word=" + _word;
-  output += "&channal=" + channalinfo.id + "' >";
+
+  //  output += "<a href='../wiki/wiki.php?word=" + _word;
+  //  output += "&channal=" + channalinfo.id + "' >";
+  output += "<a onclick=\"set_channal('" + channalinfo.id + "')\">";
 
   output += channalinfo["nickname"];
   output += "/" + channalinfo["name"];

+ 4 - 0
app/wiki/wiki.js

@@ -94,3 +94,7 @@ function wiki_pre_search(keyword) {
     }
   );
 }
+
+function set_channal(channalid) {
+  location.assign("../wiki/wiki.php?word=" + _word + "&channal=" + channalid);
+}