|
@@ -10,6 +10,7 @@ use App\Models\Enums\FileObjectType;
|
|
|
use App\Models\Enums\ObjectAction;
|
|
|
use App\Repositories\ActionRepository;
|
|
|
use App\Services\File\FileAssociationService;
|
|
|
+use DOMDocument;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
@@ -38,6 +39,39 @@ class ActionController extends Controller
|
|
|
{
|
|
|
$actionObjectType = ActionObjectType::from($objectType);
|
|
|
|
|
|
+ $fileIds=$request->get('file_ids');
|
|
|
+ $comment=$request->get('comment');
|
|
|
+ $newComment = null;
|
|
|
+
|
|
|
+ $dom = new DOMDocument();
|
|
|
+ libxml_use_internal_errors(true); // 禁用错误报告
|
|
|
+ $dom->loadHTML($comment, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
|
|
+ libxml_clear_errors();
|
|
|
+ // 获取所有的 img 标签
|
|
|
+ $imgTags = $dom->getElementsByTagName('img');
|
|
|
+ if(!empty($imgTags)){
|
|
|
+ // 遍历所有的 img 标签
|
|
|
+ foreach ($imgTags as $imgTag) {
|
|
|
+ $src = $imgTag->getAttribute('src');
|
|
|
+ // 查找 &fild_ 的位置
|
|
|
+ $fildPos = strpos($src, 'fild_');
|
|
|
+ // 如果找到了 &fild_,则截取该位置之前的数据
|
|
|
+ if ($fildPos !== false) {
|
|
|
+ $src = substr($src, $fildPos); // 保留 &fild_ 及之后的部分
|
|
|
+ } else {
|
|
|
+ // 如果没有找到 &fild_,则清空整个 src 属性(或者根据需求处理)
|
|
|
+ $src = '';
|
|
|
+ }
|
|
|
+ // 设置修改后的 src 属性
|
|
|
+ $imgTag->setAttribute('src', $src);
|
|
|
+ }
|
|
|
+ $newComment = $dom->saveHTML();
|
|
|
+ $newComment = preg_replace('/^.*<body>(.*)<\/body>.*$/s', '$1', $newComment);
|
|
|
+ $newComment = trim($newComment);
|
|
|
+ }
|
|
|
+ dd($newComment);
|
|
|
+
|
|
|
+
|
|
|
$object = $actionObjectType?->modelBuilderAllowed($objectId)
|
|
|
->where("company_id", Auth::user()->company_id)
|
|
|
->findOrFail($objectId);
|
|
@@ -53,7 +87,7 @@ class ActionController extends Controller
|
|
|
$actionObjectType,
|
|
|
ObjectAction::COMMENTED,
|
|
|
projectId: $projectId,
|
|
|
- comment: $request->comment,
|
|
|
+ comment: $newComment,
|
|
|
);
|
|
|
|
|
|
$service->association(
|