Browse Source

复刻逐词解析数据

visuddhinanda 4 years ago
parent
commit
da8cc1caaa
2 changed files with 92 additions and 15 deletions
  1. 45 7
      app/uwbw/wbw_channal_list.js
  2. 47 8
      app/uwbw/wbw_channel_list.php

+ 45 - 7
app/uwbw/wbw_channal_list.js

@@ -33,19 +33,45 @@ function wbw_channal_list_open(book, paralist) {
 				let html = "";
 				for (let index = 0; index < _wbw_channel.data.length; index++) {
 					const element = _wbw_channel.data[index];
-					html += "<div style='display:flex;line-height: 2.5em;'>";
-					html += "<span style='flex:2'>";
-					html += "<button onclick=\"wbw_create('" + index + "')\">";
+					html += "<div style='display:flex;line-height: 2.5em;border-bottom: 1px solid gray;'>";
+					html += "<span style='flex:4'>";
+					let style = "";
+					let text = "";
 					if (parseInt(element.wbw_para) > 0) {
-						html += gLocal.gui.open;
+						if (parseInt(element.power) < 20) {
+							text = "查看";
+							style = "background-color: yellow;";
+						} else {
+							text = gLocal.gui.edit;
+							style = "background-color: greenyellow;";
+						}
 					} else {
-						html += gLocal.gui.new;
+						text = gLocal.gui.new;
+					}
+					html +=
+						"<button style='" + style + "' onclick=\"wbw_create('" + index + "')\">" + text + "</button>";
+
+					if (parseInt(element.power) < 30) {
+						html += "<button onclick=\"wbw_fork('" + index + "')\">";
+						html += "复制到";
+						html += "</button>";
 					}
 
-					html += "</button>";
 					html += "</span>";
 					html += "<span  style='flex:1'>" + (index + 1) + "</span>";
-					html += "<span style='flex:3'>" + element.name + "</span>";
+					html += "<span style='flex:5'>" + element.name + "</span>";
+					html += "<span style='flex:1'>";
+					let power = [
+						{ id: 10, note: "查看者" },
+						{ id: 20, note: "编辑者" },
+						{ id: 30, note: "拥有者" },
+					];
+					for (const iterator of power) {
+						if (parseInt(element.power) == iterator.id) {
+							html += iterator.note;
+						}
+					}
+					html += "</span>";
 					html += "<span style='flex:2'>" + element.lang + "</span>";
 					html += "<span style='flex:2;display:none;'>" + element.wbw_para + "/" + element.count + "</span>";
 					html += "</div>";
@@ -87,3 +113,15 @@ function wbw_create(index) {
 		}
 	);
 }
+
+function wbw_fork(index) {
+	$("#wbw_channal_list_dlg").dialog("close");
+	let url =
+		"../doc/fork_channel.php?book=" +
+		_wbw_channel.book +
+		"&para=" +
+		_wbw_channel.para +
+		"&src_channel=" +
+		_wbw_channel.data[index].id;
+	window.open(url, "_blank");
+}

+ 47 - 8
app/uwbw/wbw_channel_list.php

@@ -2,6 +2,11 @@
 require_once '../path.php';
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
+require_once '../share/function.php';
+require_once '../channal/function.php';
+require_once '../redis/function.php';
+
+$redis = redis_connect();
 
 $output["status"] = 0;
 $output["error"] = "";
@@ -23,19 +28,53 @@ $place_holders = implode(',', array_fill(0, count($_para), '?'));
 $params = $_para;
 $params[] = $_book;
 
-PDO_Connect("" . _FILE_DB_CHANNAL_);
-$query = "SELECT * FROM channal WHERE owner = ?  LIMIT 0,100";
+#查重复
+$channelList = array();
+
+PDO_Connect(_FILE_DB_CHANNAL_);
+$query = "SELECT id FROM channal WHERE owner = ?  LIMIT 0,100";
 $FetchChannal = PDO_FetchAll($query, array($_COOKIE["userid"]));
+
+foreach ($FetchChannal as $key => $value) {
+	# code...
+	$channelList[$value["id"]]=array("power"=>30);
+}
+
+# 找协作的
+$coop_channal =  share_res_list_get($_COOKIE["userid"],2);
+foreach ($coop_channal as $key => $value) {
+	# return res_id,res_type,power res_title  res_owner_id
+	if(isset($channelList[$value["res_id"]])){
+		if($channelList[$value["res_id"]]<(int)$value["power"]){
+			$channelList[$value["res_id"]]=array("power"=>(int)$value["power"]);
+		}
+	}
+	else{
+		$channelList[$value["res_id"]]=array("power"=>(int)$value["power"]);
+	}
+}
+$channelInfo = new Channal($redis);
 $i = 0;
-foreach ($FetchChannal as $key => $row) {
-    PDO_Connect("" . _FILE_DB_USER_WBW_);
+$outputData = array();
 
+PDO_Connect( _FILE_DB_USER_WBW_);
+foreach ($channelList as $key => $row) {
     $queryParam = $params;
-    $queryParam[] = $row["id"];
+    $queryParam[] = $key;
     $query = "SELECT count(*) FROM wbw_block WHERE  paragraph IN ($place_holders)  AND book = ? AND channal = ? ";
     $wbwCount = PDO_FetchOne($query, $queryParam);
-    $FetchChannal[$key]["wbw_para"] = $wbwCount;
-    $FetchChannal[$key]["count"] = count($_para);
+    $channelList[$key]["wbw_para"] = $wbwCount;
+    $channelList[$key]["count"] = count($_para);
+	$info = $channelInfo->getChannal($key);
+    $channelList[$key]["id"] = $info["id"];
+    $channelList[$key]["name"] = $info["name"];
+    $channelList[$key]["lang"] = $info["lang"];
+	$outputData[]=$channelList[$key];
 }
-$output["data"] = $FetchChannal;
+
+# 查询全网公开 
+$query = "SELECT count(*) as co , channal FROM wbw_block WHERE  paragraph IN ($place_holders)  AND book = ? AND channal IS NOT NULL AND status = 30 group by channal ";
+
+
+$output["data"] = $outputData;
 echo json_encode($output, JSON_UNESCAPED_UNICODE);