Răsfoiți Sursa

支持三藏 转文章

visuddhinanda 4 ani în urmă
părinte
comite
6f23f105c9

+ 7 - 0
app/article/article.js

@@ -376,4 +376,11 @@ function copy_para_ref(book, para) {
 
 function edit_wbw(book, para) {
 	wbw_channal_list_open(book, [para]);
+}
+
+function to_article(){
+	article_add_dlg_show({
+		title:_sent_data.title,
+		content:_sent_data.content,
+	});
 }

+ 18 - 8
app/article/article_add_dlg.js

@@ -1,4 +1,5 @@
 var _article_add_dlg_div;
+var _article_create_param;
 function article_add_dlg_init(div) {
 	_article_add_dlg_div = div;
 	let html = "";
@@ -18,7 +19,13 @@ function article_add_dlg_init(div) {
 	$("#" + div).append(html);
 }
 
-function article_add_dlg_show() {
+function article_add_dlg_show(param=null) {
+	_article_create_param=param;
+	if(param){
+		if(typeof param.title !="undefined"){
+			$("#article_add_title").val(param.title);
+		}
+	}
 	$("#" + _article_add_dlg_div).show();
 }
 function article_add_dlg_hide() {
@@ -30,19 +37,22 @@ function article_add_cancel() {
 }
 
 function article_add_new() {
+	if(typeof _article_create_param == "undefined"){
+		_article_create_param = {
+			title: $("#article_add_title").val(),
+		}
+	}
 	$.post(
 		"../article/my_article_put.php",
-		{
-			title: $("#article_add_title").val(),
-		},
+		_article_create_param,
 		function (data) {
-			let error = JSON.parse(data);
-			if (error.status == 0) {
+			let result = JSON.parse(data);
+			if (result.ok === true) {
 				alert("ok");
 				article_add_cancel();
-				window.location.reload();
+				window.open("../article/my_article_edit.php?id="+result.data.id);
 			} else {
-				alert(error.message);
+				alert(result.message);
 			}
 		}
 	);

+ 40 - 1
app/article/index.php

@@ -136,6 +136,8 @@ require_once "../pcdl/html_head.php";
 <link href="../../node_modules/jquery.fancytree/dist/skin-win7/ui.fancytree.css" rel="stylesheet" type="text/css" class="skinswitcher">
 <script src="../tree/jquery.fancytree.js" type="text/javascript"></script>
 <script src="../article/my_collect.js" type="text/javascript"></script>
+<script language="javascript" src="../article/article_add_dlg.js"></script>
+
 
 <style>
 ul.fancytree-container{
@@ -165,6 +167,29 @@ span.fancytree-node{
 #article_path chapter{
 	display:unset;
 }
+
+.float_dlg {
+	display: none;
+	width: 25em;
+	position: absolute;
+	right: 0;
+	background-color: var(--btn-hover-bg-color);
+	padding: 10px;
+	border-radius: 5px;
+	box-shadow: 0 0 10px var(--main-color);
+	z-index: 1;
+}
+
+.float_dlg_left {
+	display: none;
+	width: 25em;
+	position: absolute;
+	background-color: var(--btn-hover-bg-color);
+	padding: 10px;
+	border-radius: 5px;
+	box-shadow: 0 0 10px var(--main-color);
+	z-index: 200;
+}
 </style>
 
 <?php
@@ -172,7 +197,7 @@ span.fancytree-node{
 ?>
 <div id="head_bar" >
 	<div style="display:flex;">
-	
+
 	</div>
 
 	<div style="margin: auto 0;">
@@ -183,6 +208,19 @@ span.fancytree-node{
 			echo "<button class='icon_btn'  title='{$_local->gui->modify} {$_local->gui->composition_structure}'>";
 			echo "<a href='../article/my_article_edit.php?id=".$_GET["id"];
 			echo "' target='_blank'>{$_local->gui->modify}</a></button>";
+		}
+		if($_GET["view"]!=="article" || $_GET["view"]!=="collection"){
+?>
+	<span class="icon_btn_div">				
+		<button id="file_add" type="button" class="icon_btn" onclick="to_article()" title=" ">
+			<svg class="icon">
+				<use xlink:href="../studio/svg/icon.svg#ic_add_circle"></use>
+			</svg>
+			转换为文章
+		</button>
+		<div id='article_add_div' class="float_dlg"></div>
+	</span>	
+<?php
 		}
 			echo "<button class='icon_btn'  title='{$_local->gui->add}{$_local->gui->subfield}'>";
 			echo "<a href='../article/frame.php?view=".$_GET["view"];
@@ -280,6 +318,7 @@ span.fancytree-node{
 
 <script>
 	$(document).ready(function(){
+		article_add_dlg_init("article_add_div");
 	ntf_init();				
 	click_dropdown_init();
 	note_create();

+ 15 - 6
app/article/my_article_put.php

@@ -8,21 +8,27 @@ require_once '../public/function.php';
 require_once '../hostsetting/function.php';
 require_once "../ucenter/active.php";
 
-$respond=array("status"=>0,"message"=>"");
+$respond=array("ok"=>true,"message"=>"");
 if(!isset($_COOKIE["userid"])){
 	#不登录不能新建
-	$respond['status']=1;
+	$respond['ok']=false;
 	$respond['message']="no power create article";
 	echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 	exit;
 }
 if(!isset($_POST["title"])){
 	#无标题不能新建
-	$respond['status']=1;
+	$respond['ok']=false;
 	$respond['message']="no title";
 	echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 	exit;
 }
+if(isset($_POST["content"])){
+	$content = $_POST["content"];
+}
+else{
+	$content = "";
+}
 PDO_Connect(_FILE_DB_USER_ARTICLE_);
 
 $query="INSERT INTO article ( id,  title  , subtitle  , summary , content   , tag  , owner, setting  , status  , create_time , modify_time , receive_time   )  VALUES  ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ";
@@ -31,12 +37,15 @@ $uuid = UUID::v4();
 //写入日志
 add_edit_event(_ARTICLE_NEW_,$uuid);
 #新建文章默认私有
-$sth->execute(array($uuid , $_POST["title"] , "" ,"", "" , "" , $_COOKIE["userid"] , "{}" , 10 , mTime() ,  mTime() , mTime() ));
-$respond=array("status"=>0,"message"=>"");
+$sth->execute(array($uuid , $_POST["title"] , "" ,"", $content , "" , $_COOKIE["userid"] , "{}" , 10 , mTime() ,  mTime() , mTime() ));
+
 if (!$sth || ($sth && $sth->errorCode() != 0)) {
 	$error = PDO_ErrorInfo();
-	$respond['status']=1;
+	$respond['ok']=false;
 	$respond['message']=$error[2];
 }
+else{
+	$respond['data']=["id"=>$uuid,"title"=>$_POST["title"]];
+}
 echo json_encode($respond, JSON_UNESCAPED_UNICODE);
 ?>