فهرست منبع

术语放 GLOBALS 里面

visuddhinanda 1 سال پیش
والد
کامیت
447f9ea3f5
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      app/Http/Api/TemplateRender.php

+ 7 - 0
app/Http/Api/TemplateRender.php

@@ -46,6 +46,7 @@ class TemplateRender{
         $this->format = $format;
         $this->studioId = $studioId;
         $this->debug = $debug;
+        $this->glossaryKey = 'glossary';
 
         if(count($this->channel_id)>0){
             $channelId = $this->channel_id[0];
@@ -58,6 +59,9 @@ class TemplateRender{
             $this->langFamily = explode('-',$lang)[0];
         }
     }
+    public function glossaryKey(){
+        return $this->glossaryKey;
+    }
     /**
      * TODO 设置默认语言。在渲染某些内容的时候需要语言信息
      */
@@ -285,8 +289,11 @@ class TemplateRender{
                 break;
             case 'html':
                 if(isset($props["meaning"])){
+                    $GLOBALS[$this->glossaryKey][$props["word"]] = $props['meaning'];
+
                     $key = 'term-'.$props["word"];
                     $termHead = "<a href='#'>".$props['meaning']."</a>";
+
                     if(isset($GLOBALS[$key])){
                         $output = $termHead;
                     }else{