@@ -20,6 +20,9 @@ class DhammaTermController extends Controller
$indexCol = ['id','guid','word','word_en','meaning','other_meaning','note','language','channal','updated_at'];
switch ($request->get('view')) {
+ case 'show':
+ return $this->ok(DhammaTerm::find($request->get('id')));
+ break;
case 'user':
# code...
$userUid = $_COOKIE['user_uid'];
@@ -165,6 +168,7 @@ class DhammaTermController extends Controller
public function show(DhammaTerm $dhammaTerm)
{
//
+ return $dhammaTerm;
}
/**
@@ -8,4 +8,11 @@ use Illuminate\Database\Eloquent\Model;
class DhammaTerm extends Model
use HasFactory;
+
+ protected $primaryKey = 'guid';
+ public $incrementing = false;
+ //protected $keyType = "string";
+ protected $casts = [
+ 'guid' => 'string'
+ ];
@@ -9,6 +9,7 @@ require_once "../pcdl/html_head.php";
</script>
<script src="./article.js"></script>
+ <script src="./term.js"></script>
<script src="../widget/like.js"></script>
<link type="text/css" rel="stylesheet" href="../widget/like.css"/>
@@ -473,6 +474,9 @@ function set_toc_visible(isVisible){
case "sim":
palicanon_load();
break;
+ case 'term':
+ term_load();
default:
@@ -0,0 +1,43 @@
+function term_load(){
+ let params = new URLSearchParams(document.location.search.substring(1));
+ if(params.get("view") != 'term'){
+ return;
+ }
+ $.getJSON("/api/v2/terms?view=show&id="+params.get("id"))
+ .done(function(data){
+ let result = data.data;
+ _article_date = result;
+ $("#article_title").html(result.word);
+ //$("#article_path_title").html(result.meaning);
+ $("#page_title").text(result.title);
+ $("#article_subtitle").html(result.meaning + "; " + result.other_meaning);
+ /*
+ let article_author = result.username.nickname + "@" + result.username.username;
+ if(result.lang !== "false"){
+ article_author += result.lang;
+ }else{
+ result.lang = "en";
+ $("#article_author").html( article_author );
+*/
+ //将绝对链接转换为 用户连接的主机链接
+ //result.content = result.content.replace(/www-[A-z]*.wikipali.org/g,location.host);
+ $("#contents").html(note_init(result.note,"",result.owner,result.language));
+ //处理<code>标签作为气泡注释
+ popup_init();
+ guide_init();
+ note_refresh_new(function(){
+ $.get('templiates/glossary.tpl',function(data){
+ let TermData = term_get_used();
+ let rendered = Mustache.render(data,TermData);
+ $("#glossary").html(rendered);
+ });
+ })
+ .fail(function(){
+}
@@ -10,6 +10,9 @@ class Channal extends Table
public function getChannal($id){
+ if(empty($id)){
+ return false;
$query = "SELECT * FROM ".$this->table." WHERE uid =? ";
$stmt = $this->dbh->prepare($query);
$stmt->execute(array($id));
@@ -105,9 +105,10 @@ function term_render_word_to_div(strWord,eDiv) {
"</button>";
- html += "<button class='icon_btn'><a href='#'>" + gLocal.gui.like + "</a></button>";
- html +=
- "<button class='icon_btn'><a href='#'>" + gLocal.gui.favorite + "</a></button></span>";
+ html += "<button class='icon_btn'><a href='../article/index.php?view=term&id="+iterator.guid+"&display=sent&mode=edit' target='_blank'>" + gLocal.gui.translate + "</a></button>";
+ //TODO 增加点赞按钮
+ //html += "<button class='icon_btn'><a href='#'>" + gLocal.gui.like + "</a></button>";
+ html += "</span>";
html += "</div>";
@@ -284,6 +284,10 @@ else{
.wiki_search_list li:hover {
background-color: beige;
+ .note_shell{
+ display:none;
</style>
<style media="screen and (max-width:800px)">