dict_lookup.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. <?php
  2. //查询参考字典
  3. include("../log/pref_log.php");
  4. require_once '../config.php';
  5. require_once '../public/casesuf.inc';
  6. require_once '../public/union.inc';
  7. require_once "../public/_pdo.php";
  8. require_once "../public/load_lang.php"; //语言文件
  9. require_once "../public/function.php";
  10. require_once "../search/word_function.php";
  11. require_once "../ucenter/active.php";
  12. require_once "../ucenter/function.php";
  13. require_once "../dict/p_ending.php";
  14. require_once "../redis/function.php";
  15. require_once "../dict/grm_abbr.php";
  16. global $redis;
  17. $redis = redis_connect();
  18. global $count_return;
  19. $count_return = 0;
  20. $word = mb_strtolower($_GET["word"], 'UTF-8');
  21. $org_word = $word;
  22. global $dict_list;
  23. $dict_list = array();
  24. $right_word_list = "";
  25. add_edit_event(_DICT_LOOKUP_, $word);
  26. echo "<div id='dict_ref'>";
  27. #先查原词
  28. echo "<div class='pali_spell'><a name='{word_$word}'></a>" . $word . "</div>";
  29. $dict_list_a = [];
  30. //社区字典开始
  31. echo lookup_user($word);
  32. //社区字典结束
  33. echo lookup_term($word);
  34. PDO_Connect("" . _FILE_DB_REF_);
  35. //直接查询
  36. $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,100";
  37. $Fetch = PDO_FetchAll($query, array($word));
  38. $iFetch = count($Fetch);
  39. echo "<div>直接查询{$iFetch}</div>";
  40. $count_return += $iFetch;
  41. if ($iFetch > 0) {
  42. for ($i = 0; $i < $iFetch; $i++) {
  43. $mean = $Fetch[$i]["mean"];
  44. $dictid = $Fetch[$i]["dict_id"];
  45. $dict_list[$dictid] = $Fetch[$i]["shortname"];
  46. $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
  47. $outXml = "<div class='dict_word'>";
  48. $outXml = $outXml . "<a name='ref_dict_$dictid'></a>";
  49. $outXml = $outXml . "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
  50. $mean = GrmAbbr($mean,$dictid);
  51. $outXml = $outXml . "<div class='mean'>" . $mean . "</div>";
  52. $outXml = $outXml . "</div>";
  53. echo $outXml;
  54. }
  55. }
  56. //去格位除尾查
  57. echo "<div>去格位除尾查</div>";
  58. $newWord = array();
  59. for ($row = 0; $row < count($case); $row++) {
  60. $len = mb_strlen($case[$row][1], "UTF-8");
  61. $end = mb_substr($word, 0 - $len, null, "UTF-8");
  62. if ($end == $case[$row][1]) {
  63. $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $case[$row][0];
  64. if ($base != $word) {
  65. $thiscase = "";
  66. $arrCase = explode('$', $case[$row][2]);
  67. foreach ($arrCase as $value) {
  68. $caseid = "grammar_" . str_replace('.', '', $value);
  69. $thiscase .= "<guide gid='$caseid'>$value</guide>";
  70. }
  71. if (isset($newWord[$base])) {
  72. $newWord[$base] .= "<br />" . $thiscase;
  73. } else {
  74. $newWord[$base] = $thiscase;
  75. }
  76. }
  77. }
  78. }
  79. $base_list = array();
  80. if (count($newWord) > 0) {
  81. foreach ($newWord as $x => $x_value) {
  82. $titleHas = false;
  83. $userDictStr = lookup_user($x);
  84. $termDictStr = lookup_term($x);
  85. if(!empty($userDictStr) || !empty($termDictStr)){
  86. echo "<div class='pali_spell'><a name='word_$x'></a>" . $x . "</div>";
  87. $titleHas = true;
  88. }
  89. $query = "SELECT dict.id,dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
  90. $Fetch = PDO_FetchAll($query, array($x));
  91. $iFetch = count($Fetch);
  92. $count_return += $iFetch;
  93. if ($iFetch > 0) {
  94. $base_list[] = $x;
  95. $dict_list_a[] = array("word_$x", $x);
  96. if(!$titleHas){
  97. echo "<div class='pali_spell'><a name='word_$x'></a>" . $x . "</div>";
  98. }
  99. //语法信息
  100. foreach ($_local->grammastr as $gr) {
  101. $x_value = str_replace($gr->id, $gr->value, $x_value);
  102. }
  103. echo "<div class='dict_find_gramma'>" . $x_value . "</div>";
  104. echo $userDictStr;
  105. echo $termDictStr;
  106. for ($i = 0; $i < $iFetch; $i++) {
  107. $mean = $Fetch[$i]["mean"];
  108. $dictid = $Fetch[$i]["dict_id"];
  109. $dict_list[$dictid] = $Fetch[$i]["shortname"];
  110. $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
  111. RenderWordDiv($dictid,$Fetch[$i]["shortname"],$Fetch[$i]["id"],$x,$mean);
  112. }
  113. }
  114. }
  115. }
  116. //去除尾查结束
  117. //去分词除尾查
  118. echo "<div>去分词除尾查</div>";
  119. $arrBase = array();
  120. if (count($newWord) > 0) {
  121. foreach ($newWord as $base => $grammar){
  122. for ($row = 0; $row < count($p_ending); $row++) {
  123. $len = mb_strlen($p_ending[$row][1], "UTF-8");
  124. $end = mb_substr($base, 0 - $len, null, "UTF-8");
  125. if ($end == $p_ending[$row][1]) {
  126. $newbase = mb_substr($base, 0, mb_strlen($base, "UTF-8") - $len, "UTF-8") . $p_ending[$row][0];
  127. if ($newbase != $base) {
  128. $thiscase = "";
  129. $arrCase = explode('$', $p_ending[$row][2]);
  130. foreach ($arrCase as $value) {
  131. $caseid = "grammar_" . str_replace('.', '', $value);
  132. $thiscase .= "<guide gid='$caseid'>$value</guide>";
  133. }
  134. if (isset($arrBase[$newbase])) {
  135. $arrBase[$newbase]['grammar'] .= "<br />" . $thiscase;
  136. } else {
  137. $arrBase[$newbase]['grammar'] = $thiscase;
  138. $arrBase[$newbase]['parent'] = $base;
  139. }
  140. }
  141. }
  142. }
  143. }
  144. $base_list = array();
  145. if (count($arrBase) > 0) {
  146. foreach ($arrBase as $x => $x_value) {
  147. $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
  148. $Fetch = PDO_FetchAll($query, array($x));
  149. $iFetch = count($Fetch);
  150. $count_return += $iFetch;
  151. if ($iFetch > 0) {
  152. $base_list[] = $x;
  153. $dict_list_a[] = array("word_$x", $x);
  154. echo "<div class='pali_spell'><a name='word_$x'></a>" . $x . "</div>";
  155. echo "<div style='color:gray;'>{$x}➡{$x_value["parent"]}➡{$word}</div>";
  156. //替换为本地语法信息
  157. foreach ($_local->grammastr as $gr) {
  158. $x_value['grammar'] = str_replace($gr->id, $gr->value, $x_value['grammar']);
  159. }
  160. echo "<div class='dict_find_gramma'>" . $x_value['grammar'] . "</div>";
  161. for ($i = 0; $i < $iFetch; $i++) {
  162. $mean = $Fetch[$i]["mean"];
  163. $dictid = $Fetch[$i]["dict_id"];
  164. $dict_list[$dictid] = $Fetch[$i]["shortname"];
  165. $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
  166. echo "<div class='dict_word'>";
  167. echo "<a name='ref_dict_$dictid'></a>";
  168. echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
  169. $mean = GrmAbbr($mean,$dictid);
  170. echo "<div class='mean'>" . $mean . "</div>";
  171. echo "</div>";
  172. }
  173. }
  174. }
  175. }
  176. }
  177. //去除尾查结束
  178. echo "<div id='search_summary'>";
  179. echo "{$_local->gui->find_about}{$word} {$_local->gui->total}<b>{$count_return}</b>{$_local->gui->result} ";
  180. if(count($base_list)>0){
  181. echo "找到可能的拼写: ";
  182. foreach ($base_list as $key => $value) {
  183. # code...
  184. echo "<a>{$value}</a> ";
  185. }
  186. }
  187. echo "<a>查询内文</a>";
  188. echo "</div>";
  189. echo "<input type='hidden' id='word_count' value='{$count_return}' />";
  190. //查连读词
  191. /*
  192. if ($count_return < 2) {
  193. echo "<div>Junction</div>";
  194. $newWord = array();
  195. for ($row = 0; $row < count($un); $row++) {
  196. $len = mb_strlen($un[$row][1], "UTF-8");
  197. $end = mb_substr($word, 0 - $len, null, "UTF-8");
  198. if ($end == $un[$row][1]) {
  199. $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $un[$row][0];
  200. $arr_un = explode("+", $base);
  201. foreach ($arr_un as $oneword) {
  202. echo "<a onclick='dict_pre_word_click(\"$oneword\")'>$oneword</a> + ";
  203. }
  204. echo "<br />";
  205. }
  206. }
  207. }
  208. */
  209. //拆复合词
  210. echo "<div id='auto_split'></div>";
  211. //查内容
  212. if ($count_return < 4) {
  213. $word1 = $org_word;
  214. $wordInMean = "%$org_word%";
  215. echo "包含 $org_word 的:<br />";
  216. $query = "SELECT dict.dict_id,dict.word,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where mean like ? limit 0,30";
  217. $Fetch = PDO_FetchAll($query, array($wordInMean));
  218. $iFetch = count($Fetch);
  219. $count_return += $iFetch;
  220. if ($iFetch > 0) {
  221. for ($i = 0; $i < $iFetch; $i++) {
  222. $mean = $Fetch[$i]["mean"];
  223. $pos = mb_stripos($mean, $word, 0, "UTF-8");
  224. if ($pos) {
  225. if ($pos > 20) {
  226. $start = $pos - 20;
  227. } else {
  228. $start = 0;
  229. }
  230. $newmean = mb_substr($mean, $start, 100, "UTF-8");
  231. } else {
  232. $newmean = $mean;
  233. }
  234. $pos = mb_stripos($newmean, $word1, 0, "UTF-8");
  235. $head = mb_substr($newmean, 0, $pos, "UTF-8");
  236. $mid = mb_substr($newmean, $pos, mb_strlen($word1, "UTF-8"), "UTF-8");
  237. $end = mb_substr($newmean, $pos + mb_strlen($word1, "UTF-8"), null, "UTF-8");
  238. $heigh_light_mean = "$head<hl>$mid</hl>$end";
  239. echo "<div class='dict_word'>";
  240. echo "<div class='pali'><a href='index.php?key={$Fetch[$i]["word"]}'>" . $Fetch[$i]["word"] . "</a></div>";
  241. echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
  242. echo "<div class='mean'>" . $heigh_light_mean . "</div>";
  243. echo "<div><a href='index.php?key={$Fetch[$i]["word"]}&hightlight={$org_word}'>详情</a></div>";
  244. echo "</div>";
  245. }
  246. }
  247. }
  248. else{
  249. }
  250. echo "<div id='dictlist'>";
  251. foreach ($dict_list_a as $x_value) {
  252. if (substr($x_value[0], 0, 4) == "word") {
  253. echo "<div class='pali_spell'>";
  254. echo "<a href='#{$x_value[0]}'>$x_value[1]</a></div>";
  255. } else {
  256. echo "<div><a href='#{$x_value[0]}'>$x_value[1]</a></div>";
  257. }
  258. }
  259. echo "<div>";
  260. $arrWords = countWordInPali($word, true);
  261. $weight = 0;
  262. foreach ($arrWords as $oneword) {
  263. $weight += $oneword["count"] * $oneword["len"];
  264. }
  265. //echo "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
  266. //echo "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
  267. $right_word_list .= "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
  268. $right_word_list .= "<div>{$_local->gui->real_declension}:" . count($arrWords) . " {$_local->gui->forms}</div>";
  269. foreach ($arrWords as $oneword) {
  270. if ($oneword["bold"] > 0) {
  271. //echo "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
  272. $right_word_list .= "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
  273. } else {
  274. //echo "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
  275. $right_word_list .= "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
  276. }
  277. }
  278. echo "</div>";
  279. echo "</div>";
  280. echo "</div>";
  281. //参考字典查询结束
  282. //用户词典编辑窗口
  283. echo "<div id='dict_user' >";
  284. echo "<div><a href='word_statistics.php?word={$word}'>";
  285. echo "<svg t='1596783175334' class='icon' style='font-size: xxx-large; fill: var(--link-hover-color); margin: 5px;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='7755' width='200' height='200'><path d='M1019.904 450.56L536.576 557.056l417.792 208.896C999.424 692.224 1024 606.208 1024 512c0-20.48 0-40.96-4.096-61.44z m-12.288-61.44C958.464 184.32 786.432 28.672 573.44 4.096L446.464 512l561.152-122.88zM737.28 970.752c73.728-36.864 139.264-90.112 188.416-159.744L507.904 602.112l229.376 368.64zM512 0C229.376 0 0 229.376 0 512s229.376 512 512 512c61.44 0 118.784-12.288 172.032-28.672L385.024 512 512 0z' p-id='7756'></path></svg>";
  286. echo "<span>{$_local->gui->click_to_chart}</span></a></div>";
  287. echo $right_word_list;
  288. echo "</div>";
  289. //查用户词典结束
  290. PrefLog();
  291. function lookup_user($word){
  292. global $dict_list;
  293. global $redis;
  294. global $_local;
  295. global $PDO;
  296. global $count_return;
  297. $output ="";
  298. $Fetch=array();
  299. if($redis){
  300. $wordData = $redis->hGet("dict://user",$word);
  301. if($wordData){
  302. if(!empty($wordData)){
  303. $arrWord = json_decode($wordData,true);
  304. foreach ($arrWord as $one) {
  305. # code...
  306. $Fetch[] = array("id"=>$one[0],
  307. "pali"=>$one[1],
  308. "type"=>$one[2],
  309. "gramma"=>$one[3],
  310. "parent"=>$one[4],
  311. "mean"=>$one[5],
  312. "note"=>$one[6],
  313. "factors"=>$one[7],
  314. "factormean"=>$one[8],
  315. "status"=>$one[9],
  316. "confidence"=>$one[10],
  317. "creator"=>$one[11],
  318. "dict_name"=>$one[12],
  319. "lang"=>$one[13],
  320. );
  321. }
  322. }
  323. }
  324. else{
  325. # 没找到就不找了
  326. }
  327. }
  328. else{
  329. PDO_Connect("" . _FILE_DB_WBW_);
  330. $query = "SELECT * from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
  331. $Fetch = PDO_FetchAll($query, array($word));
  332. }
  333. $iFetch = count($Fetch);
  334. if ($iFetch > 0) {
  335. $count_return++;
  336. $userlist = array();
  337. foreach ($Fetch as $value) {
  338. if (isset($userlist[$value["creator"]])) {
  339. $userlist[$value["creator"]] += 1;
  340. } else {
  341. $userlist[$value["creator"]] = 1;
  342. }
  343. $userwordcase = $value["type"] . "#" . $value["gramma"];
  344. $parent = $value["parent"];
  345. if(empty($parent)){
  346. $parent = "_null_";
  347. }
  348. if (isset($userdict["{$parent}"])) {
  349. $userdict["{$parent}"]["mean"] .= "$". $value["mean"] ;
  350. $userdict["{$parent}"]["factors"] .= "@". $value["factors"];
  351. $userdict["{$parent}"]["case"] .= "@".$userwordcase;
  352. } else {
  353. $userdict["{$parent}"]["mean"] = $value["mean"];
  354. $userdict["{$parent}"]["factors"] = $value["factors"];
  355. $userdict["{$parent}"]["case"] = $userwordcase;
  356. }
  357. }
  358. $output .= "<div class='dict_word'>";
  359. $output .= "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
  360. $dict_list_a[] = array("net", $_local->gui->com_dict);
  361. foreach ($userdict as $key => $value) {
  362. #语法信息查重
  363. $thiscase = array();
  364. $strCase = "";
  365. $arrCase = explode("@",$value["case"]);
  366. foreach ($arrCase as $case) {
  367. # code...
  368. $thiscase[$case] = 1;
  369. }
  370. foreach ($thiscase as $case => $casevalue) {
  371. # code...
  372. $strCase .=$case . "; ";
  373. }
  374. #语法信息替换为本地字符串
  375. foreach ($_local->grammastr as $gr) {
  376. $strCase = str_replace($gr->id, $gr->value, $strCase);
  377. }
  378. #拆分查重复
  379. $thispart = array();
  380. $strPart = "";
  381. $arrPart = explode("@",$value["factors"]);
  382. foreach ($arrPart as $part) {
  383. # code...
  384. $thispart[$part] = 1;
  385. }
  386. foreach ($thispart as $part => $partvalue) {
  387. # code...
  388. $strPart .=$part . "; ";
  389. }
  390. #意思查重复
  391. $thismean = array();
  392. $strMean = "";
  393. $arrMean = explode("$",$value["mean"]);
  394. foreach ($arrMean as $mean) {
  395. # code...
  396. $thismean[$mean] = 1;
  397. }
  398. foreach ($thismean as $mean => $meanvalue) {
  399. # code...
  400. $strMean .=$mean . "; ";
  401. }
  402. $output .= "<div class='mean'><b>{$_local->gui->gramma}</b>:{$strCase}</div>";
  403. if($key!=="_null_"){
  404. $output .= "<div class='mean'><b>{$_local->gui->parent}</b>:<a href='index.php?key={$key}'>{$key}</a></div>";
  405. }
  406. $output .= "<div class='mean'><b>{$_local->gui->g_mean}</b>:{$strMean}</div>";
  407. $output .= "<div class='mean'><b>{$_local->gui->factor}</b>:{$strPart}</div>";
  408. }
  409. $output .= "<div><span>{$_local->gui->contributor}:</span>";
  410. $userinfo = new UserInfo();
  411. foreach ($userlist as $key => $value) {
  412. $user = $userinfo->getName($key);
  413. $output .= $user["nickname"] . " ";
  414. }
  415. $output .= "</div>";
  416. $output .= "</div>";
  417. }
  418. return $output;
  419. }
  420. function lookup_term($word){
  421. global $dict_list;
  422. global $redis;
  423. global $_local;
  424. global $PDO;
  425. global $count_return;
  426. $output ="";
  427. $Fetch=array();
  428. if($redis){
  429. $wordData = $redis->hGet("dict://term",$word);
  430. if($wordData){
  431. if(!empty($wordData)){
  432. $arrWord = json_decode($wordData,true);
  433. foreach ($arrWord as $one) {
  434. # code...
  435. $Fetch[] = array("id"=>$one[0],
  436. "pali"=>$one[1],
  437. "type"=>$one[2],
  438. "gramma"=>$one[3],
  439. "parent"=>$one[4],
  440. "mean"=>$one[5],
  441. "note"=>$one[6],
  442. "factors"=>$one[7],
  443. "factormean"=>$one[8],
  444. "status"=>$one[9],
  445. "confidence"=>$one[10],
  446. "creator"=>$one[11],
  447. "dict_name"=>$one[12],
  448. "lang"=>$one[13],
  449. );
  450. }
  451. }
  452. }
  453. else{
  454. # 没找到就不找了
  455. }
  456. }
  457. else{
  458. PDO_Connect("" . _FILE_DB_WBW_);
  459. $query = "SELECT * from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
  460. $Fetch = PDO_FetchAll($query, array($word));
  461. }
  462. $iFetch = count($Fetch);
  463. $count_return += $iFetch;
  464. if ($iFetch > 0) {
  465. $userlist = array();
  466. foreach ($Fetch as $value) {
  467. if (isset($userlist[$value["creator"]])) {
  468. $userlist[$value["creator"]] += 1;
  469. } else {
  470. $userlist[$value["creator"]] = 1;
  471. }
  472. $userwordcase = $value["type"] . "#" . $value["gramma"];
  473. if (isset($userdict["{$userwordcase}"])) {
  474. $userdict["{$userwordcase}"]["mean"] .= $value["mean"] . ";";
  475. $userdict["{$userwordcase}"]["factors"] .= $value["factors"];
  476. } else {
  477. $userdict["{$userwordcase}"]["mean"] = $value["mean"];
  478. $userdict["{$userwordcase}"]["factors"] = $value["factors"];
  479. }
  480. }
  481. $output .= "<div class='dict_word'>";
  482. $output .= "<div class='dict'>{$_local->gui->wiki_term}</div><a name='net'></a>";
  483. $dict_list_a[] = array("net", $_local->gui->wiki_term);
  484. foreach ($userdict as $key => $value) {
  485. $output .= "<div class='mean'>{$key}:{$value["mean"]}</div>";
  486. }
  487. $output .= "<div><span>{$_local->gui->contributor}:</span>";
  488. $userinfo = new UserInfo();
  489. foreach ($userlist as $key => $value) {
  490. $user = $userinfo->getName($key);
  491. $output .= $user["nickname"] . " ";
  492. }
  493. $output .= "</div>";
  494. $output .= "</div>";
  495. }
  496. return $output;
  497. }
  498. function GrmAbbr($input,$dictid){
  499. $mean = $input;
  500. foreach (GRM_ABBR as $key => $value) {
  501. # code...
  502. if($value["dictid"]==$dictid && strpos($input,$value["abbr"]."</guide>") == false){
  503. $mean = str_ireplace($value["abbr"],"<guide gid='grammar_{$value["replace"]}' class='grammar_tag' style='display:unset;'>{$value["abbr"]}</guide>",$mean);
  504. }
  505. }
  506. return $mean;
  507. }
  508. function RenderWordDiv($dictId,$dictName,$refWordId,$word,$meaning){
  509. echo "<div class='dict_word'>";
  510. echo "<a name='ref_dict_$dictId'></a>";
  511. echo "<div class='dict'>" . $dictName . "</div>";
  512. $mean = GrmAbbr($meaning,$dictId);
  513. echo "<div class='mean'>" . $mean . "</div>";
  514. /*
  515. echo "<div class='tool'>";
  516. echo "<button onclick='refDictShowTranslateDiv(this)'>我要翻译</button>";
  517. echo "<div class='tool_innter'>";
  518. RenderUserDictEdit($word,$dictId,$refWordId);
  519. echo "</div>";
  520. echo "</div>";
  521. */
  522. echo "</div>";
  523. }
  524. function RenderUserDictEdit($word,$dictId,$refWordId){
  525. global $_local;
  526. //用户词典编辑窗口
  527. echo "<div >";
  528. echo "<form >";
  529. echo "<input type='hidden' name='word' value='{$word}'/>";
  530. echo "<input type='hidden' name='dictid' value='{$dictId}'/>";
  531. echo "<input type='hidden' name='wordid' value='{$refWordId}'/>";
  532. if ($dictId == 0) {
  533. echo "<div id='user_word_edit'>";
  534. } else {
  535. echo "<div id='user_word_edit'>";
  536. }
  537. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->language}</legend><input type='input' name='lang' value='zh-hans'/></fieldset>";
  538. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
  539. echo "<select id=\"id_type\" name=\"type\" >";
  540. foreach ($_local->type_str as $type) {
  541. echo "<option value=\"{$type->id}\" >{$type->value}</option>";
  542. }
  543. echo "</select>";
  544. echo "</fieldset>";
  545. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' name='grammar' value=''/></fieldset>";
  546. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' name='parent' placeholder='{$word}' value=''/></fieldset>";
  547. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' name='mean' value=''/></fieldset>";
  548. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea name='note'></textarea></fieldset>";
  549. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' name='parts' value=''/></fieldset>";
  550. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' name='part_mean' value=''/></fieldset>";
  551. echo "</form>";
  552. echo "<div class=''><button onclick='SaveToMyDict()'>{$_local->gui->save}</button></div>";
  553. echo "</div>";
  554. echo "</div>";
  555. }