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. $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 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.dict_id,dict.mean,dn.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN "._TABLE_DICT_REF_NAME_." as dn ON dict.dict_id = dn.id where word = ? limit 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 "._TABLE_DICT_REF_NAME_." as info ON dict.dict_id = info.id where word = ? limit 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 "._TABLE_DICT_REF_NAME_." as info ON dict.dict_id = info.id where mean like ? limit 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. $rediskey = Redis["prefix"]."dict/user";
  301. $wordData = $redis->hGet($rediskey,$word);
  302. if($wordData){
  303. if(!empty($wordData)){
  304. $arrWord = json_decode($wordData,true);
  305. foreach ($arrWord as $one) {
  306. # code...
  307. $Fetch[] = array("id"=>$one[0],
  308. "pali"=>$one[1],
  309. "type"=>$one[2],
  310. "grammar"=>$one[3],
  311. "parent"=>$one[4],
  312. "mean"=>$one[5],
  313. "note"=>$one[6],
  314. "factors"=>$one[7],
  315. "factormean"=>$one[8],
  316. "status"=>$one[9],
  317. "confidence"=>$one[10],
  318. "creator_id"=>$one[11],
  319. "source"=>$one[12],
  320. "lang"=>$one[13],
  321. );
  322. }
  323. }
  324. }
  325. else{
  326. # 没找到就不找了
  327. }
  328. }
  329. else
  330. {
  331. PDO_Connect(_FILE_DB_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
  332. $query = "SELECT * from " . _TABLE_DICT_WBW_ . " where word = ? and source='_SYS_USER_WBW_' limit 100";
  333. $Fetch = PDO_FetchAll($query, array($word));
  334. }
  335. $iFetch = count($Fetch);
  336. if ($iFetch > 0) {
  337. $count_return++;
  338. $userlist = array();
  339. foreach ($Fetch as $value) {
  340. if (isset($userlist[$value["creator_id"]])) {
  341. $userlist[$value["creator_id"]] += 1;
  342. } else {
  343. $userlist[$value["creator_id"]] = 1;
  344. }
  345. $userwordcase = $value["type"] . "#" . $value["grammar"];
  346. $parent = $value["parent"];
  347. if(empty($parent)){
  348. $parent = "_null_";
  349. }
  350. if (isset($userdict["{$parent}"])) {
  351. $userdict["{$parent}"]["mean"] .= "$". $value["mean"] ;
  352. $userdict["{$parent}"]["factors"] .= "@". $value["factors"];
  353. $userdict["{$parent}"]["case"] .= "@".$userwordcase;
  354. } else {
  355. $userdict["{$parent}"]["mean"] = $value["mean"];
  356. $userdict["{$parent}"]["factors"] = $value["factors"];
  357. $userdict["{$parent}"]["case"] = $userwordcase;
  358. }
  359. }
  360. $output .= "<div class='dict_word'>";
  361. $output .= "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
  362. $dict_list_a[] = array("net", $_local->gui->com_dict);
  363. foreach ($userdict as $key => $value) {
  364. #语法信息查重
  365. $thiscase = array();
  366. $strCase = "";
  367. $arrCase = explode("@",$value["case"]);
  368. foreach ($arrCase as $case) {
  369. # code...
  370. $thiscase[$case] = 1;
  371. }
  372. foreach ($thiscase as $case => $casevalue) {
  373. # code...
  374. $strCase .=$case . "; ";
  375. }
  376. #语法信息替换为本地字符串
  377. foreach ($_local->grammastr as $gr) {
  378. $strCase = str_replace($gr->id, $gr->value, $strCase);
  379. }
  380. #拆分查重复
  381. $thispart = array();
  382. $strPart = "";
  383. $arrPart = explode("@",$value["factors"]);
  384. foreach ($arrPart as $part) {
  385. # code...
  386. $thispart[$part] = 1;
  387. }
  388. foreach ($thispart as $part => $partvalue) {
  389. # code...
  390. $strPart .=$part . "; ";
  391. }
  392. #意思查重复
  393. $thismean = array();
  394. $strMean = "";
  395. $arrMean = explode("$",$value["mean"]);
  396. foreach ($arrMean as $mean) {
  397. # code...
  398. $thismean[$mean] = 1;
  399. }
  400. foreach ($thismean as $mean => $meanvalue) {
  401. # code...
  402. $strMean .=$mean . "; ";
  403. }
  404. $output .= "<div class='mean'><b>{$_local->gui->gramma}</b>:{$strCase}</div>";
  405. if($key!=="_null_"){
  406. $output .= "<div class='mean'><b>{$_local->gui->parent}</b>:<a href='index.php?key={$key}'>{$key}</a></div>";
  407. }
  408. $output .= "<div class='mean'><b>{$_local->gui->g_mean}</b>:{$strMean}</div>";
  409. $output .= "<div class='mean'><b>{$_local->gui->factor}</b>:{$strPart}</div>";
  410. }
  411. $output .= "<div><span>{$_local->gui->contributor}:</span>";
  412. $userinfo = new UserInfo();
  413. foreach ($userlist as $key => $value) {
  414. $user = $userinfo->getName($key);
  415. $output .= $user["nickname"] . " ";
  416. }
  417. $output .= "</div>";
  418. $output .= "</div>";
  419. }
  420. return $output;
  421. }
  422. function lookup_term($word){
  423. global $dict_list;
  424. global $redis;
  425. global $_local;
  426. global $PDO;
  427. global $count_return;
  428. $output ="";
  429. $Fetch=array();
  430. if($redis){
  431. $wordData = $redis->hGet("dict://term",$word);
  432. if($wordData){
  433. if(!empty($wordData)){
  434. $arrWord = json_decode($wordData,true);
  435. foreach ($arrWord as $one) {
  436. # code...
  437. $Fetch[] = array("id"=>$one[0],
  438. "pali"=>$one[1],
  439. "type"=>$one[2],
  440. "gramma"=>$one[3],
  441. "parent"=>$one[4],
  442. "mean"=>$one[5],
  443. "note"=>$one[6],
  444. "factors"=>$one[7],
  445. "factormean"=>$one[8],
  446. "status"=>$one[9],
  447. "confidence"=>$one[10],
  448. "creator"=>$one[11],
  449. "dict_name"=>$one[12],
  450. "lang"=>$one[13],
  451. );
  452. }
  453. }
  454. }
  455. else{
  456. # 没找到就不找了
  457. }
  458. }
  459. else{
  460. exit;
  461. #TODO 查询term 表
  462. PDO_Connect(_FILE_DB_WBW_,_DB_USERNAME_,_DB_PASSWORD_);
  463. $query = "SELECT * from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
  464. $Fetch = PDO_FetchAll($query, array($word));
  465. }
  466. $iFetch = count($Fetch);
  467. $count_return += $iFetch;
  468. if ($iFetch > 0) {
  469. $userlist = array();
  470. foreach ($Fetch as $value) {
  471. if (isset($userlist[$value["creator"]])) {
  472. $userlist[$value["creator"]] += 1;
  473. } else {
  474. $userlist[$value["creator"]] = 1;
  475. }
  476. $userwordcase = $value["type"] . "#" . $value["gramma"];
  477. if (isset($userdict["{$userwordcase}"])) {
  478. $userdict["{$userwordcase}"]["mean"] .= $value["mean"] . ";";
  479. $userdict["{$userwordcase}"]["factors"] .= $value["factors"];
  480. } else {
  481. $userdict["{$userwordcase}"]["mean"] = $value["mean"];
  482. $userdict["{$userwordcase}"]["factors"] = $value["factors"];
  483. }
  484. }
  485. $output .= "<div class='dict_word'>";
  486. $output .= "<div class='dict'>{$_local->gui->wiki_term}</div><a name='net'></a>";
  487. $dict_list_a[] = array("net", $_local->gui->wiki_term);
  488. foreach ($userdict as $key => $value) {
  489. $output .= "<div class='mean'>{$key}:{$value["mean"]}</div>";
  490. }
  491. $output .= "<div><span>{$_local->gui->contributor}:</span>";
  492. $userinfo = new UserInfo();
  493. foreach ($userlist as $key => $value) {
  494. $user = $userinfo->getName($key);
  495. $output .= $user["nickname"] . " ";
  496. }
  497. $output .= "</div>";
  498. $output .= "</div>";
  499. }
  500. return $output;
  501. }
  502. function GrmAbbr($input,$dictid){
  503. $mean = $input;
  504. foreach (GRM_ABBR as $key => $value) {
  505. # code...
  506. if($value["dictid"]==$dictid && strpos($input,$value["abbr"]."</guide>") == false){
  507. $mean = str_ireplace($value["abbr"],"<guide gid='grammar_{$value["replace"]}' class='grammar_tag' style='display:unset;'>{$value["abbr"]}</guide>",$mean);
  508. }
  509. }
  510. return $mean;
  511. }
  512. function RenderWordDiv($dictId,$dictName,$refWordId,$word,$meaning){
  513. echo "<div class='dict_word'>";
  514. echo "<a name='ref_dict_$dictId'></a>";
  515. echo "<div class='dict'>" . $dictName . "</div>";
  516. $mean = GrmAbbr($meaning,$dictId);
  517. echo "<div class='mean'>" . $mean . "</div>";
  518. /*
  519. echo "<div class='tool'>";
  520. echo "<button onclick='refDictShowTranslateDiv(this)'>我要翻译</button>";
  521. echo "<div class='tool_innter'>";
  522. RenderUserDictEdit($word,$dictId,$refWordId);
  523. echo "</div>";
  524. echo "</div>";
  525. */
  526. echo "</div>";
  527. }
  528. function RenderUserDictEdit($word,$dictId,$refWordId){
  529. global $_local;
  530. //用户词典编辑窗口
  531. echo "<div >";
  532. echo "<form >";
  533. echo "<input type='hidden' name='word' value='{$word}'/>";
  534. echo "<input type='hidden' name='dictid' value='{$dictId}'/>";
  535. echo "<input type='hidden' name='wordid' value='{$refWordId}'/>";
  536. if ($dictId == 0) {
  537. echo "<div id='user_word_edit'>";
  538. } else {
  539. echo "<div id='user_word_edit'>";
  540. }
  541. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->language}</legend><input type='input' name='lang' value='zh-hans'/></fieldset>";
  542. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
  543. echo "<select id=\"id_type\" name=\"type\" >";
  544. foreach ($_local->type_str as $type) {
  545. echo "<option value=\"{$type->id}\" >{$type->value}</option>";
  546. }
  547. echo "</select>";
  548. echo "</fieldset>";
  549. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' name='grammar' value=''/></fieldset>";
  550. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' name='parent' placeholder='{$word}' value=''/></fieldset>";
  551. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' name='mean' value=''/></fieldset>";
  552. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea name='note'></textarea></fieldset>";
  553. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' name='parts' value=''/></fieldset>";
  554. echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' name='part_mean' value=''/></fieldset>";
  555. echo "</form>";
  556. echo "<div class=''><button onclick='SaveToMyDict()'>{$_local->gui->save}</button></div>";
  557. echo "</div>";
  558. echo "</div>";
  559. }