|
|
@@ -14,6 +14,7 @@ use App\Models\Discussion;
|
|
|
use App\Models\PaliSentence;
|
|
|
use App\Models\SentSimIndex;
|
|
|
use App\Models\CustomBookSentence;
|
|
|
+use App\Models\CustomBook;
|
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
use Illuminate\Http\Request;
|
|
|
@@ -114,20 +115,21 @@ class CorpusController extends Controller
|
|
|
{
|
|
|
//
|
|
|
}
|
|
|
- public function getSentTpl($id,$channels,$mode='edit',$onlyProps=false){
|
|
|
+ public function getSentTpl($id,$channels,$mode='edit',$onlyProps=false,$format='react'){
|
|
|
$sent = [];
|
|
|
$sentId = \explode('-',$id);
|
|
|
if(count($sentId) !== 4){
|
|
|
return false;
|
|
|
}
|
|
|
- if((int)$sentId[0] < 1000){
|
|
|
+ $bookId = (int)$sentId[0];
|
|
|
+ if( $bookId < 1000){
|
|
|
if($mode==='read'){
|
|
|
$channelId = ChannelApi::getSysChannel('_System_Pali_VRI_');
|
|
|
}else{
|
|
|
$channelId = ChannelApi::getSysChannel('_System_Wbw_VRI_');
|
|
|
}
|
|
|
}else{
|
|
|
-
|
|
|
+ $channelId = CustomBook::where('book_id',$bookId)->value('channel_id');
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -144,49 +146,6 @@ class CorpusController extends Controller
|
|
|
|
|
|
$channelIndex = $this->getChannelIndex($channels);
|
|
|
|
|
|
- if((int)$sentId[0] >= 1000){
|
|
|
- $orgChannelId = (string)Str::uuid();
|
|
|
- //载入自定义原文
|
|
|
- $customOrigin = CustomBookSentence::
|
|
|
- where('book',(int)$sentId[0])
|
|
|
- ->where('paragraph',(int)$sentId[1])
|
|
|
- ->where('word_start',(int)$sentId[2])
|
|
|
- ->where('word_end',(int)$sentId[3])
|
|
|
- ->get();
|
|
|
- $toSentFormat = array();
|
|
|
- $owner_uid = null;
|
|
|
- foreach ($customOrigin as $custom) {
|
|
|
- if($owner_uid === null){
|
|
|
- $owner_uid = $custom->owner;
|
|
|
- }
|
|
|
- $toSentFormat[] = (object)[
|
|
|
- 'uid'=>$custom->id,
|
|
|
- 'book_id'=>$custom->book,
|
|
|
- 'paragraph'=>$custom->paragraph,
|
|
|
- 'word_start'=>$custom->word_start,
|
|
|
- "word_end"=>$custom->word_end,
|
|
|
- 'channel_uid'=>$orgChannelId,
|
|
|
- 'content'=>$custom->content,
|
|
|
- 'content_type'=>$custom->content_type,
|
|
|
- 'editor_uid'=>$custom->owner,
|
|
|
- 'acceptor_uid'=>null,
|
|
|
- 'pr_edit_at'=>null,
|
|
|
- 'create_time'=>$custom->create_time,
|
|
|
- 'modify_time'=>$custom->modify_time,
|
|
|
- 'created_at'=>$custom->created_at,
|
|
|
- 'updated_at'=>$custom->updated_at,
|
|
|
- ];
|
|
|
- }
|
|
|
- $orgChannel = (object)array(
|
|
|
- 'uid'=>$orgChannelId,
|
|
|
- 'type'=>'original',
|
|
|
- 'name'=>'custom',
|
|
|
- 'owner_uid'=>$owner_uid,
|
|
|
- 'studio'=>StudioApi::getById($owner_uid),
|
|
|
- );
|
|
|
- $channelIndex[$orgChannelId] = $orgChannel;
|
|
|
- }
|
|
|
-
|
|
|
if(isset($toSentFormat)){
|
|
|
foreach ($toSentFormat as $key => $org) {
|
|
|
$record[] = $org;
|
|
|
@@ -202,7 +161,7 @@ class CorpusController extends Controller
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- return $this->makeContent($record,$mode,$channelIndex,[],$onlyProps);
|
|
|
+ return $this->makeContent($record,$mode,$channelIndex,[],$onlyProps,false,$format);
|
|
|
}
|
|
|
/**
|
|
|
* Display the specified resource.
|
|
|
@@ -595,7 +554,7 @@ class CorpusController extends Controller
|
|
|
* $indexChannel channel索引
|
|
|
* $indexedHeading 标题索引 用于给段落加标题标签 <h1> ect.
|
|
|
*/
|
|
|
- private function makeContent($record,$mode,$indexChannel,$indexedHeading=[],$onlyProps=false,$paraMark=false){
|
|
|
+ private function makeContent($record,$mode,$indexChannel,$indexedHeading=[],$onlyProps=false,$paraMark=false,$format='react'){
|
|
|
$content = [];
|
|
|
$lastSent = "0-0";
|
|
|
$sentCount = 0;
|
|
|
@@ -677,7 +636,7 @@ class CorpusController extends Controller
|
|
|
$newSent['id'] = $row->uid;
|
|
|
$newSent['content'] = $row->content;
|
|
|
$newSent['contentType'] = $row->content_type;
|
|
|
- $newSent['html'] = "";
|
|
|
+ $newSent['html'] = '';
|
|
|
$newSent["editor"]=UserApi::getByUuid($row->editor_uid);
|
|
|
/**
|
|
|
* TODO 刷库改数据
|
|
|
@@ -704,18 +663,20 @@ class CorpusController extends Controller
|
|
|
// 传过来的数据一定有一个原文channel
|
|
|
//
|
|
|
if($mode !== "read"){
|
|
|
-
|
|
|
- $newSent['channel']['type'] = "wbw";
|
|
|
-
|
|
|
- if(isset($this->wbwChannels[0])){
|
|
|
- $newSent['channel']['name'] = $indexChannel[$this->wbwChannels[0]]->name;
|
|
|
- $newSent['channel']['id'] = $this->wbwChannels[0];
|
|
|
- //存在一个translation channel
|
|
|
- //尝试查找逐词解析数据。找到,替换现有数据
|
|
|
- $wbwData = $this->getWbw($arrSentId[0],$arrSentId[1],$arrSentId[2],$arrSentId[3],$this->wbwChannels[0]);
|
|
|
- if($wbwData){
|
|
|
- $newSent['content'] = $wbwData;
|
|
|
- $newSent['html'] = "";
|
|
|
+ if($info->content_type==='json'){
|
|
|
+ $newSent['channel']['type'] = "wbw";
|
|
|
+ if(isset($this->wbwChannels[0])){
|
|
|
+ $newSent['channel']['name'] = $indexChannel[$this->wbwChannels[0]]->name;
|
|
|
+ $newSent['channel']['id'] = $this->wbwChannels[0];
|
|
|
+ //存在一个translation channel
|
|
|
+ //尝试查找逐词解析数据。找到,替换现有数据
|
|
|
+ $wbwData = $this->getWbw($arrSentId[0],$arrSentId[1],$arrSentId[2],$arrSentId[3],
|
|
|
+ $this->wbwChannels[0]);
|
|
|
+ if($wbwData){
|
|
|
+ $newSent['content'] = $wbwData;
|
|
|
+ $newSent['contentType'] = 'json';
|
|
|
+ $newSent['html'] = "";
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
@@ -725,10 +686,12 @@ class CorpusController extends Controller
|
|
|
|
|
|
break;
|
|
|
case 'nissaya':
|
|
|
- $newSent['html'] = RedisClusters::remember("/sent/{$channelId}/{$currSentId}",
|
|
|
+ $newSent['html'] = RedisClusters::remember("/sent/{$channelId}/{$currSentId}/{$format}",
|
|
|
config('mint.cache.expire'),
|
|
|
- function() use($row,$mode){
|
|
|
- return MdRender::render($row->content,[$row->channel_uid],null,$mode,"nissaya",$row->content_type);
|
|
|
+ function() use($row,$mode,$format){
|
|
|
+ return MdRender::render($row->content,[$row->channel_uid],
|
|
|
+ null,$mode,"nissaya",
|
|
|
+ $row->content_type,$format);
|
|
|
});
|
|
|
break;
|
|
|
default:
|
|
|
@@ -737,13 +700,27 @@ class CorpusController extends Controller
|
|
|
* 包涵术语的不用cache
|
|
|
*/
|
|
|
if(strpos($row->content,'[[')===false){
|
|
|
- $newSent['html'] = RedisClusters::remember("/sent/{$channelId}/{$currSentId}",
|
|
|
+ $newSent['html'] = MdRender::render($row->content,[$row->channel_uid],
|
|
|
+ null,$mode,'translation',
|
|
|
+ $row->content_type,$format);
|
|
|
+ /*
|
|
|
+ RedisClusters::remember("/sent/{$channelId}/{$currSentId}/{$format}",
|
|
|
config('mint.cache.expire'),
|
|
|
- function() use($row){
|
|
|
- return MdRender::render($row->content,[$row->channel_uid]);
|
|
|
+ function() use($row,$mode,$format){
|
|
|
+ return MdRender::render($row->content,[$row->channel_uid],
|
|
|
+ null,$mode,'translation',
|
|
|
+ $row->content_type,$format);
|
|
|
});
|
|
|
+ */
|
|
|
}else{
|
|
|
- $mdRender = new MdRender(['debug'=>$this->debug]);
|
|
|
+ $mdRender = new MdRender(
|
|
|
+ [
|
|
|
+ 'debug'=>$this->debug,
|
|
|
+ 'format'=>$format,
|
|
|
+ 'mode'=>$mode,
|
|
|
+ 'channelType'=>'translation',
|
|
|
+ 'contentType'=>$row->content_type,
|
|
|
+ ]);
|
|
|
$newSent['html'] = $mdRender->convert($row->content,[$row->channel_uid]);
|
|
|
}
|
|
|
break;
|