2
0

dict_lookup.php 22 KB

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