visuddhinanda 4 лет назад
Родитель
Сommit
d3fbc50faa
2 измененных файлов с 31 добавлено и 14 удалено
  1. 10 5
      app/search/paliword_sc.php
  2. 21 9
      app/search/paliword_search.php

+ 10 - 5
app/search/paliword_sc.php

@@ -113,9 +113,11 @@ $aQueryWordList = array(); //id 为键 拼写为值的数组
 $aInputWordList = array(); //id 为键 拼写为值的数组 该词是否被选择
 $aShowWordList = array(); //拼写为键 个数为值的数组
 $aShowWordIdList = array(); //拼写为键 值Id的数组
+$arrQueryId=array();
 for ($i = 0; $i < $countWord; $i++) {
     $value = $arrRealWordList[$i];
     $strQueryWordId .= "'{$value["id"]}',";
+	$arrQueryId[] = $value["id"];
     $aQueryWordList["{$value["id"]}"] = $value["word"];
     $aInputWordList["{$value["id"]}"] = false;
     $aShowWordList[$value["word"]] = $value["count"];
@@ -129,6 +131,7 @@ if (isset($_GET["words"])) {
         foreach ($word_selected as $key => $value) {
             $strQueryWordId .= "'{$value}',";
             $aInputWordList["{$value}"] = true;
+			$arrQueryId[] = $value;
         }
     }
 }
@@ -210,7 +213,7 @@ $query = "SELECT count(*) from (SELECT book FROM "._TABLE_WORD_." WHERE \"wordin
 $result["record_count"] = PDO_FetchOne($query);
 $result["time"][] = array("event" => "查询记录数", "time" => microtime(true) - $_start);
 
-$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM "._TABLE_WORD_." WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY wordindex,book,paragraph ORDER BY wt DESC LIMIT ? OFFSET ?";
+$query = "SELECT book,paragraph, sum(weight) as wt FROM "._TABLE_WORD_." WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT ? OFFSET ?";
 $Fetch = PDO_FetchAll($query,array($_pagesize , $_page * $_pagesize));
 $result["time"][] = array("event" => "查询结束", "time" => microtime(true) - $_start);
 $out_data = array();
@@ -222,9 +225,11 @@ if ($iFetch > 0) {
     PDO_Connect(_FILE_DB_PALITEXT_);
     for ($i = 0; $i < $iFetch; $i++) {
         $newRecode = array();
-
-        $paliwordid = $Fetch[$i]["wordindex"];
-        $paliword = $aQueryWordList["{$paliwordid}"];
+		$paliword = array();
+		foreach ($arrQueryId as $value) {
+			# code...
+			$paliword[] = $aQueryWordList["{$value}"];
+		}
         $book = $Fetch[$i]["book"];
         $paragraph = $Fetch[$i]["paragraph"];
         $bookInfo = _get_book_info($book);
@@ -269,7 +274,7 @@ if ($iFetch > 0) {
             $newRecode["book"] = $book;
             $newRecode["para"] = $paragraph;
             $newRecode["palitext"] = $FetchPaliText[0]["html"];
-            $newRecode["keyword"] = array($paliword);
+            $newRecode["keyword"] = $paliword;
             $newRecode["wt"] = $Fetch[$i]["wt"];
             $out_data[] = $newRecode;
         }

+ 21 - 9
app/search/paliword_search.php

@@ -95,9 +95,12 @@ switch ($op) {
             $aQueryWordList = array(); //id 为键 拼写为值的数组
             $aShowWordList = array(); //拼写为键 个数为值的数组
             $aShowWordIdList = array(); //拼写为键 值Id的数组
+
+			$arrQueryId=array();
             for ($i = 0; $i < $countWord; $i++) {
                 $value = $arrRealWordList[$i];
                 $strQueryWordId .= "'{$value["id"]}',";
+				$arrQueryId[] = $value["id"];
                 $aQueryWordList["{$value["id"]}"] = $value["word"];
                 $aShowWordList[$value["word"]] = $value["count"];
                 $aShowWordIdList[$value["word"]] = $value["id"];
@@ -163,7 +166,7 @@ switch ($op) {
 
             PDO_Connect(_FILE_DB_PALI_INDEX_);
 			//TODO 在没有查到书的时候$strFirstBookList为 (  需要修改
-            $query = "SELECT book,paragraph, wordindex FROM "._TABLE_WORD_." WHERE \"wordindex\" in $strQueryWordId and book in $strFirstBookList group by book,paragraph LIMIT 20";
+            $query = "SELECT book,paragraph  FROM "._TABLE_WORD_." WHERE \"wordindex\" in $strQueryWordId and book in $strFirstBookList group by book,paragraph LIMIT 20";
             $Fetch = PDO_FetchAll($query);
             //echo "<div>$query</div>";
             $queryTime = (microtime_float() - $time_start) * 1000;
@@ -171,8 +174,11 @@ switch ($op) {
             if ($iFetch > 0) {
                 PDO_Connect(_FILE_DB_PALITEXT_);
                 for ($i = 0; $i < $iFetch; $i++) {
-                    $paliwordid = $Fetch[$i]["wordindex"];
-                    $paliword = $aQueryWordList["{$paliwordid}"];
+					$paliword = array();
+					foreach ($arrQueryId as $value) {
+						# code...
+						$paliword[] = $aQueryWordList["{$value}"];
+					}
                     $book = $Fetch[$i]["book"];
                     $paragraph = $Fetch[$i]["paragraph"];
                     $bookInfo = _get_book_info($book);
@@ -182,7 +188,7 @@ switch ($op) {
                     $c3 = $bookInfo->c3;
 
                     echo "<div class='dict_word' style='margin: 10px 0;padding: 5px;border-bottom: 1px solid var(--border-line-color);'>";
-                    echo "<div style='font-size: 130%;font-weight: 700;'>$paliword</div>";
+                    echo "<div style='font-size: 130%;font-weight: 700;'>".$paliword[0]."</div>";
                     //echo "<div class='dict_word'>";
                     $path_1 = $c1 . ">";
                     if ($c2 !== "") {
@@ -218,11 +224,17 @@ switch ($op) {
                         echo "<div class='mean' style='font-size:120%'><a href='../reader/?view=para&book={$book}&para={$paragraph}&display=para' target='_blank'>$path</a></div>";
 
                         for ($iPali = 0; $iPali < $countPaliText; $iPali++) {
-                            if (substr($paliword, -1) == "n") {
-                                $paliword = substr($paliword, 0, -1);
-                            }
-                            $htmltext = $FetchPaliText[0]["html"];
-                            $light_text = str_replace($paliword, "<hl>{$paliword}</hl>", $htmltext);
+							foreach ($paliword as $qWord) {
+								# code...
+								$light_text = $htmltext;
+								if (substr($qWord, -1) == "n") {
+									$qWord = substr($qWord, 0, -1);
+								}
+								$htmltext = $FetchPaliText[0]["html"];
+								$light_text = str_replace($qWord, "<hl>{$qWord}</hl>", $light_text);								
+							}
+
+
                             echo "<div class='wizard_par_div'>{$light_text}</div>";
                         }
                         //echo  "<div class='wizard_par_div'>{$light_text}</div>";