dict_lookup.php 22 KB

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