Browse Source

修改redis key 为 url风格

visuddhinanda 5 năm trước cách đây
mục cha
commit
0998a9227d

+ 11 - 12
app/dict/function.php

@@ -5,8 +5,9 @@ require_once '../redis/function.php';
 
 function getRefFirstMeaning($word,$lang,$redis){
 	if($redis!==false){
-		$len = $redis->hLen("ref_first_mean://".$word);
-		if($len===FALSE || $len==0){
+		/*
+		$mean = $redis->hGet("ref_first_mean://".$lang,$word);
+		if($mean===FALSE){
 			PDO_Connect(_FILE_DB_REF_, _DB_USERNAME_, _DB_PASSWORD_);
 			$query = "SELECT mean,language as lang from " . _TABLE_DICT_REF_ . " where word = ?  group by language";
 			$Fetch = PDO_FetchAll($query, array($word));
@@ -14,9 +15,10 @@ function getRefFirstMeaning($word,$lang,$redis){
 				foreach ($Fetch as $key => $value) {
 					# code...
 					$redis->hSet("ref_first_mean://".$word,$value["lang"],$value["mean"]);
-				}				
+				}
 			}
 		}
+		*/
 		$mean = $redis->hGet("ref_first_mean://".$word,$lang);
 		if($mean!=FALSE){
 			return $mean;
@@ -24,24 +26,21 @@ function getRefFirstMeaning($word,$lang,$redis){
 		else{
 			if($lang!="en"){
 				$mean = $redis->hGet("ref_first_mean://".$word,"en");
-				if($mean!=FALSE){
+				if($mean!==FALSE){
 					return $mean;
 				}
 			}
 
-			$arr_keys = $redis->hGetAll("ref_first_mean://".$word);
-			if(count($arr_keys)>0){
-				foreach ($arr_keys as $key => $value) {
+			$any = $redis->hGet("ref_first_mean://com",$word);
+			if($any!==FALSE){
 					# code...
-					return $value;
-				}
+				return $any;
+
 			}
 			else{
 				return "";
 			}
-
 		}
-		
 	}
 	else{
 		PDO_Connect(_FILE_DB_REF_, _DB_USERNAME_, _DB_PASSWORD_);
@@ -65,4 +64,4 @@ function getRefFirstMeaning($word,$lang,$redis){
 				
 	}
 
-}
+}

+ 1 - 2
app/dict/redis_pm_part.php

@@ -12,9 +12,8 @@ if (PHP_SAPI == "cli") {
 		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
 			# code...
 			if(!empty($row["parts"])){
-				$redis->hSet("dict_pm_part",$row["pali"],$row["parts"]);
+				$redis->hSet("dict://pm/part",$row["pali"],$row["parts"]);
 			}
-			
 		}
 	}
 	echo "all done";

+ 1 - 1
app/dict/redis_ref_with_mean.php

@@ -13,7 +13,7 @@ if (PHP_SAPI == "cli") {
 		$stmt = $dbh->query($query);
 		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
 			# code...
-			$redis->hSet("dict_ref_with_mean",$row["word"],"1");
+			$redis->hSet("dict://ref/has_mean",$row["word"],"1");
 		}
 	}
 	echo "all done";

+ 48 - 0
app/dict/redis_refresh_first_mean.php

@@ -0,0 +1,48 @@
+<?php
+require_once "../path.php";
+require_once '../public/_pdo.php';
+require_once "../redis/function.php";
+
+if (PHP_SAPI == "cli") {
+	$redis = redis_connect();
+	if($redis!==false){
+		
+		PDO_Connect(_FILE_DB_REF_, _DB_USERNAME_, _DB_PASSWORD_);
+		$query = "SELECT language as lang from " . _TABLE_DICT_REF_ . " where 1  group by language";
+		$Fetch = PDO_FetchAll($query);
+		if(count($Fetch)>0){
+			foreach ($Fetch as $key => $value) {
+				# 获取字典中所有的语言
+				if(!empty($value["lang"])){
+					$languages[] = $value["lang"];
+				}
+			}
+			print_r($languages);
+			foreach ($languages as $thisLang) {
+				# code...
+				$query = "SELECT word,mean from " . _TABLE_DICT_REF_ . " where language = ? group by word";
+				$meanings = PDO_FetchAll($query, array($thisLang));
+				foreach ($meanings as $mean) {
+					# code...
+					$redis->hSet("ref_first_mean://".$thisLang,$mean["word"],$mean["mean"]);
+				}
+				echo $thisLang.":".$redis->hLen("ref_first_mean://".$thisLang)."\n";
+			}
+
+			$query = "SELECT word,mean from " . _TABLE_DICT_REF_ . " where 1 group by word";
+			$meanings = PDO_FetchAll($query);
+			foreach ($meanings as $mean) {
+				# code...
+				$redis->hSet("ref_first_mean://com",$mean["word"],$mean["mean"]);
+			}
+			echo $thisLang.":".$redis->hLen("ref_first_mean://com")."\n";
+		}
+
+	}
+	else{
+		echo "no redis server";
+	}
+
+}
+
+?>

+ 1 - 1
app/dict/redis_sys_rgl_part.php

@@ -12,7 +12,7 @@ if (PHP_SAPI == "cli") {
 		$stmt = $dbh->query($query);
 		while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
 			# code...
-			$redis->hSet("dict_regular_part",$row["pali"],$row["parts"]);
+			$redis->hSet("dict://regular/part",$row["pali"],$row["parts"]);
 		}
 	}
 	echo "all done";

+ 7 - 7
app/dict/turbo_split.php

@@ -519,13 +519,13 @@ function split2($word){
 		}
 		if(mb_strlen($word,"UTF-8")>4){
 		# 先看有没有中文意思
-			if($redis->hExists("dict_ref_with_mean",$word)===TRUE){
+			if($redis->hExists("dict://ref/has_mean",$word)===TRUE){
 				$newword[]=$word;
 			}
 			else{
 				#如果没有查巴缅替换拆分
-				if($redis->hExists("dict_pm_part",$word)===TRUE){
-					$pmPart = explode("+",$redis->hGet("dict_pm_part",$word)) ;
+				if($redis->hExists("dict://pm/part",$word)===TRUE){
+					$pmPart = explode("+",$redis->hGet("dict://pm/part",$word)) ;
 					foreach ($pmPart as  $pm) {
 						# code...
 						$newword[]=$pm;
@@ -533,11 +533,11 @@ function split2($word){
 				}
 				else{
 					#如果没有查规则变形
-					if($redis->hExists("dict_regular_part",$word)===TRUE){
-						$rglPart = explode("+",$redis->hGet("dict_regular_part",$word)) ;
+					if($redis->hExists("dict://regular/part",$word)===TRUE){
+						$rglPart = explode("+",$redis->hGet("dict://regular/part",$word)) ;
 						#看巴缅有没有第一部分
-						if($redis->hExists("dict_pm_part",$rglPart[0])===TRUE){
-							$pmPart = explode("+",$redis->hGet("dict_pm_part",$rglPart[0])) ;
+						if($redis->hExists("dict://pm/part",$rglPart[0])===TRUE){
+							$pmPart = explode("+",$redis->hGet("dict://pm/part",$rglPart[0])) ;
 							foreach ($pmPart as  $pm) {
 								# code...
 								$newword[]=$pm;

+ 53 - 49
app/reader/index.php

@@ -329,72 +329,76 @@ require_once "../pcdl/html_head.php";
 		</span>
 	</div>
 </div>
+
 <div id="main_view" class="main_view">
-<div id="article_head" style="border-bottom: 1px solid gray;">
-	<div id="article_title" class="term_word_head_pali"><?php echo $_local->gui->title; ?></div>
-	<div  id='path_div' style="display:flex;justify-content: space-between;">
-		<div id="article_path">
-		<span id="para_path"></span>
-		<span class="case_dropdown" id="para_path_next_level">
-		……
-		<div id="toc_next_menu" class="case_dropdown-content">
-		</div>
-		</span>
-		</div>
-		<div id="article_lang">
-			<div class="click_dropdown_div">
-				<div class="click_dropdown_button">语言</div>
-				<div class="click_dropdown_content">
-					<div class="click_dropdown_content_inner">
-						<a>简体中文</a>
+	<div id="article_head" style="border-bottom: 1px solid gray;">
+		<div id="article_title" class="term_word_head_pali"><?php echo $_local->gui->title; ?></div>
+		<div  id='path_div' style="display:flex;justify-content: space-between;">
+			<div id="article_path">
+			<span id="para_path"></span>
+			<span class="case_dropdown" id="para_path_next_level">
+			……
+			<div id="toc_next_menu" class="case_dropdown-content">
+			</div>
+			</span>
+			</div>
+			<div id="article_lang">
+				<div class="click_dropdown_div">
+					<div class="click_dropdown_button">语言</div>
+					<div class="click_dropdown_content">
+						<div class="click_dropdown_content_inner">
+							<a>简体中文</a>
+						</div>
 					</div>
 				</div>
 			</div>
 		</div>
 	</div>
-</div>
-<div id="contents_view">
-	<div id="contents_div" style="padding: 0 1em 0 30px;width:70vw;">
-		<div id="contents">
-		<?php echo $_local->gui->loading; ?>...
-		</div>
-		<div id="contents_toc">
-		</div>
-		<div id="contents_foot">
-			<div id="contents_nav" style="display:flex;justify-content: space-between;">
-				<div id="contents_nav_left"></div>
-				<div id="contents_nav_right"></div>
+	<div id="contents_view">
+		<div id="contents_div" style="padding: 0 1em 0 30px;width:70vw;">
+			<div id="contents">
+			<?php echo $_local->gui->loading; ?>...
 			</div>
-			<div id="contents_dicuse">
-			
+			<div id="contents_toc">
 			</div>
-		</div>
-	</div>
-	<div id="right_pannal">
-		<div class="fun_frame">
-			<div id = "collect_title" class="title"><?php echo $_local->gui->contents; ?></div>
-			<div id = "toc_content" class="content" style="max-height:25vw;">
+			<div id="contents_foot">
+				<div id="contents_nav" style="display:flex;justify-content: space-between;">
+					<div id="contents_nav_left"></div>
+					<div id="contents_nav_right"></div>
+				</div>
+				<div id="contents_dicuse">
+				
+				</div>
 			</div>
 		</div>
-		<div class="fun_frame">
-			<div style="display:flex;justify-content: space-between;">
-				<div class="title"><?php echo $_local->gui->contributor; ?></div>
-				<div class="click_dropdown_div">
-					<div class="channel_select_button" onclick="onChannelMultiSelectStart()"><?php echo $_local->gui->select; ?></div>
+		<div id="right_pannal">
+			<div class="fun_frame">
+				<div id = "collect_title" class="title"><?php echo $_local->gui->contents; ?></div>
+				<div id = "toc_content" class="content" style="max-height:25vw;">
 				</div>
 			</div>
-			<div class='channel_select'>
-			<button onclick='onChannelChange()'><?php echo $_local->gui->confirm; ?></button>
-				<button onclick='onChannelMultiSelectCancel()'><?php echo $_local->gui->cancel; ?></button>
-			</div>
-			<div id="channal_list" class="content" style="max-height:25vw;">
+			<div class="fun_frame">
+				<div style="display:flex;justify-content: space-between;">
+					<div class="title"><?php echo $_local->gui->contributor; ?></div>
+					<div class="click_dropdown_div">
+						<div class="channel_select_button" onclick="onChannelMultiSelectStart()"><?php echo $_local->gui->select; ?></div>
+					</div>
+				</div>
+				<div class='channel_select'>
+				<button onclick='onChannelChange()'><?php echo $_local->gui->confirm; ?></button>
+					<button onclick='onChannelMultiSelectCancel()'><?php echo $_local->gui->cancel; ?></button>
+				</div>
+				<div id="channal_list" class="content" style="max-height:25vw;">
+				</div>
 			</div>
 		</div>
 	</div>
-</div>
-</div>
 
+</div>
 
+<div id="dict_pannal">
+	<iframe src="../dict/index.php?builtin=true" name="dict" title="W3Schools Free Online Web Tutorials"></iframe>
+</div>
 <script>
 	$(document).ready(function(){
 	ntf_init();				

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 47
dicttext/thin/ref11-4.csv


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 355
dicttext/thin/ref4.csv


Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác