dict_lookup.php 22 KB

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