1) { echo "
"; foreach ($arrWordList as $oneword) { echo $oneword . "+"; } echo "
"; } $query = "select word,count from wordindex where \"word_en\" like " . $PDO->quote($searching . '%') . " OR \"word\" like " . $PDO->quote($searching . '%') . " limit 0,20"; $Fetch = PDO_FetchAll($query); $queryTime = (microtime_float() - $time_start) * 1000; $iFetch = count($Fetch); if ($iFetch > 0) { for ($i = 0; $i < $iFetch; $i++) { $word = $Fetch[$i]["word"]; $count = $Fetch[$i]["count"]; echo "$word-$count"; } } break; } case "search": { if (count($arrWordList) > 1) { $strQuery = ""; foreach ($arrWordList as $oneword) { $strQuery .= "\"text\" like \"% {$oneword} %\" AND"; } $strQuery = substr($strQuery, 0, -3); PDO_Connect(_FILE_DB_PALITEXT_); $query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery} LIMIT 0,20"; $Fetch = PDO_FetchAll($query); echo "
$query
"; $iFetch = count($Fetch); foreach ($Fetch as $row) { $html = $row["html"]; foreach ($arrWordList as $oneword) { $html = str_replace($oneword, "{$oneword}", $html); } echo "
{$html}
"; } return; } //计算某词在三藏中出现的次数 $time_start = microtime_float(); $arrRealWordList = countWordInPali($word); $countWord = count($arrRealWordList); if ($countWord == 0) { echo "

没有查到。可能是拼写有问题。

"; exit; } $strQueryWordId = "("; //实际出现的单词id查询字串 $aQueryWordList = array(); //id 为键 拼写为值的数组 $aShowWordList = array(); //拼写为键 个数为值的数组 $aShowWordIdList = array(); //拼写为键 值Id的数组 for ($i = 0; $i < $countWord; $i++) { $value = $arrRealWordList[$i]; $strQueryWordId .= "'{$value["id"]}',"; $aQueryWordList["{$value["id"]}"] = $value["word"]; $aShowWordList[$value["word"]] = $value["count"]; $aShowWordIdList[$value["word"]] = $value["id"]; } $strQueryWordId = mb_substr($strQueryWordId, 0, mb_strlen($strQueryWordId, "UTF-8") - 1, "UTF-8"); $strQueryWordId .= ")"; $queryTime = (microtime_float() - $time_start) * 1000; echo "
"; //主显示区开始 echo "
"; //主显示区左侧开始 echo "
"; echo ""; echo "
共{$countWord}单词符合
"; //显示单词列表 echo "
"; echo "全选
"; arsort($aShowWordList); $i = 0; foreach ($aShowWordList as $x => $x_value) { $wordid = $aShowWordIdList[$x]; echo ""; echo $x . ":" . $x_value; echo ""; echo ""; echo "
"; $i++; } echo ""; echo "
"; //查找这些词出现在哪些书中 echo "
"; $booklist = render_book_list($strQueryWordId); echo "
"; $wordInBookCounter = 0; $strFirstBookList = "("; foreach ($booklist as $onebook) { $wordInBookCounter += $onebook[1]; $strFirstBookList .= "'" . $onebook[0] . "',"; if ($wordInBookCounter >= 20) { break; } } $strFirstBookList = mb_substr($strFirstBookList, 0, mb_strlen($strFirstBookList, "UTF-8") - 1, "UTF-8"); $strFirstBookList .= ")"; echo "
"; //黑体字主显示区左侧结束 //黑体字主显示区右侧开始 echo "
"; //前20条记录 $time_start = microtime_float(); PDO_Connect(_FILE_DB_PALI_INDEX_); //TODO 在没有查到书的时候$strFirstBookList为 ( 需要修改 $query = "SELECT book,paragraph, wordindex FROM word WHERE \"wordindex\" in $strQueryWordId and book in $strFirstBookList group by book,paragraph LIMIT 0,20"; $Fetch = PDO_FetchAll($query); //echo "
$query
"; $queryTime = (microtime_float() - $time_start) * 1000; $iFetch = count($Fetch); if ($iFetch > 0) { PDO_Connect(_FILE_DB_PALITEXT_); for ($i = 0; $i < $iFetch; $i++) { $paliwordid = $Fetch[$i]["wordindex"]; $paliword = $aQueryWordList["{$paliwordid}"]; $book = $Fetch[$i]["book"]; $paragraph = $Fetch[$i]["paragraph"]; $bookInfo = _get_book_info($book); $bookname = $bookInfo->title; $c1 = $bookInfo->c1; $c2 = $bookInfo->c2; $c3 = $bookInfo->c3; echo "
"; echo "
$paliword
"; //echo "
"; $path_1 = $c1 . ">"; if ($c2 !== "") { $path_1 = $path_1 . $c2 . ">"; } if ($c3 !== "") { $path_1 = $path_1 . $c3 . ">"; } $path_1 = $path_1 . "《{$bookname}》>"; $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,1"; $FetchPaliText = PDO_FetchAll($query); $countPaliText = count($FetchPaliText); if ($countPaliText > 0) { $path = ""; $parent = $FetchPaliText[0]["parent"]; $deep = 0; $sFirstParentTitle = ""; //循环查找父标题 得到整条路径 while ($parent > -1) { $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1"; $FetParent = PDO_FetchAll($query); $path = "{$FetParent[0]["toc"]}>{$path}"; if ($sFirstParentTitle == "") { $sFirstParentTitle = $FetParent[0]["toc"]; } $parent = $FetParent[0]["parent"]; $deep++; if ($deep > 5) { break; } } $path = $path_1 . $path . "para. " . $paragraph; echo ""; 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, "{$paliword}", $htmltext); echo "
{$light_text}
"; } //echo "
{$light_text}
"; echo "
"; } echo "
"; } } $queryTime = (microtime_float() - $time_start) * 1000; echo "
搜索时间:$queryTime
"; echo "
"; //黑体字主显示区右侧结束 echo "
"; echo "
"; echo "
"; //黑体字主显示区结束 echo "
"; //查黑体字结束 echo "
"; break; } case "update": $target = $_GET["target"]; switch ($target) { case "bold"; $wordlist = $_GET["wordlist"]; $booklist = $_GET["booklist"]; $aBookList = ltrim($booklist, "("); $aBookList = rtrim($aBookList, ")"); $aBookList = str_replace("'", "", $aBookList); $aBookList = str_getcsv($aBookList); $arrBookType = json_decode(file_get_contents("../public/book_name/booktype.json")); //查找这些词出现在哪些书中 $newBookList = render_book_list($wordlist, $aBookList); //前20条记录 $time_start = microtime_float(); PDO_Connect(_FILE_DB_PALI_INDEX_); $query = "select * from word where \"wordindex\" in $wordlist and \"book\" in $booklist group by book,paragraph limit 0,20"; $Fetch = PDO_FetchAll($query); $queryTime = (microtime_float() - $time_start) * 1000; //echo "
搜索时间:$queryTime
"; if ($booklist == "()") { echo "
请选择书名
"; } $iFetch = count($Fetch); if ($iFetch > 0) { PDO_Connect(_FILE_DB_PALITEXT_); for ($i = 0; $i < $iFetch; $i++) { $paliword = $Fetch[$i]["wordindex"]; //$paliword=$wordlist["{$paliwordid}"]; $book = $Fetch[$i]["book"]; $bookInfo = _get_book_info($book); $bookname = $bookInfo->title; $c1 = $bookInfo->c1; $c2 = $bookInfo->c2; $c3 = $bookInfo->c3; $paragraph = $Fetch[$i]["paragraph"]; $path_1 = $c1 . ">"; if ($c2 !== "") { $path_1 = $path_1 . $c2 . ">"; } if ($c3 !== "") { $path_1 = $path_1 . $c3 . ">"; } $path_1 = $path_1 . "《{$bookname}》>"; echo "
"; echo "
《{$bookname}》 $c1 $c2
"; echo "
$paliword
"; $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20"; $FetchPaliText = PDO_FetchAll($query); $countPaliText = count($FetchPaliText); if ($countPaliText > 0) { for ($iPali = 0; $iPali < $countPaliText; $iPali++) { $path = ""; $parent = $FetchPaliText[0]["parent"]; $deep = 0; $sFirstParentTitle = ""; while ($parent > -1) { $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1"; $FetParent = PDO_FetchAll($query); if ($sFirstParentTitle == "") { $sFirstParentTitle = $FetParent[0]["toc"]; } $path = "{$FetParent[0]["toc"]}>{$path}"; $parent = $FetParent[0]["parent"]; $deep++; if ($deep > 5) { break; } } $path = $path . "No. " . $paragraph; echo ""; if (substr($paliword, -1) == "n") { $paliword = substr($paliword, 0, -1); } $light_text = str_replace($paliword, "{$paliword}", $FetchPaliText[$iPali]["html"]); echo "
{$light_text}
"; echo "
"; } } echo "
"; } } break; } break; }