]> _ Git - cubist_cms-back.git/commitdiff
wip #6344 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Oct 2023 14:55:12 +0000 (16:55 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Oct 2023 14:55:12 +0000 (16:55 +0200)
src/app/Http/Controllers/Base/XSendFileController.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/views/fields/select2_from_array.blade.php

index ac36032d3556395353a893e4d5f057f444e36967..81968eb9d7fd7334d9c19e942586b48ecc1f863d 100644 (file)
@@ -12,12 +12,12 @@ class XSendFileController extends Controller
         return self::sendfile($path);
     }
 
-    public static function sendfile($path, $maxage = 86400)
+    public static function sendfile($path, $maxage = 86400, $headers = [])
     {
         $response = response(null);
         $request = request();
         if (!file_exists($path)) {
-            abort(404,'File not found');
+            abort(404, 'File not found');
         }
         $mtime = filemtime($path);
         $fsize = filesize($path);
@@ -32,6 +32,9 @@ class XSendFileController extends Controller
         } else {
             $response->header('Cache-Control', 'no-store');
         }
+        foreach ($headers as $key => $value) {
+            $response->header($key, $value);
+        }
         return $response->header('X-Sendfile', $path);
     }
 
index 9248c80d699e0b059a3fc7f2bf83910044e0f9ae..df20e3319e7c582b8bbfefff793bd0a3985a6b99 100644 (file)
@@ -37,6 +37,7 @@ use Illuminate\Support\Arr;
 use Illuminate\Support\Carbon;
 use Illuminate\Support\Facades\Cache;
 use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Log;
 use Spatie\MediaLibrary\HasMedia;
 use Spatie\MediaLibrary\InteractsWithMedia;
 use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
@@ -863,13 +864,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia
             $cloned->model_id = $newId;
             $cloned->push();
             // Copy files
-            $from = public_path('storage/' . $media->id);
-            $to = public_path('storage/' . $cloned->id);
-            if (file_exists($to)) {
-                `rm -rf $to`;
-            }
-            $cp = "cp -R $from $to";
-            `$cp`;
+            $from = storage_path('app/public/' . $media->id);
+            $to = storage_path('app/public/' . $cloned->id);
+            \Cubist\Util\Files\Files::mirrorDir($from, $to);
         }
     }
 
index 80afbdd6c1005de675bbc0c6ba8a43d3f3e7789e..d6aba02dbc25ffac951e928a864e85b80d513be8 100644 (file)
@@ -7,6 +7,9 @@
             if(null===$o || $o==='null'){
                 return false;
             }
+            if(\Cubist\Util\Json::isJson($o)){
+                $o=json_decode($o);
+            }
             if(is_scalar($o)){
                 return $o==$key;
             }
@@ -22,21 +25,21 @@ if($ajax){
 }
 @endphp
 
-        <!-- select2 from array -->
+    <!-- select2 from array -->
 @include('crud::fields.inc.wrapper_start')
 <label>{!! $field['label'] !!}</label>
 @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)
     <input type="hidden" name="{{ $field['name'] }}" value=""/>
 @endif
 <select
-        name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
-        style="width: 100%"
-        @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
-        @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
-        @if($ajax) data-ajax="{{$field['ajax']}}" @endif
-        @if($allows_html) data-allow-html="1" @endif
-        data-options="{{ json_encode($field['options']) }}"
-        data-value="{{is_scalar($o)?$o:json_encode($o)}}"
+    name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
+    style="width: 100%"
+    @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
+    @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
+    @if($ajax) data-ajax="{{$field['ajax']}}" @endif
+    @if($allows_html) data-allow-html="1" @endif
+    data-options="{{ json_encode($field['options']) }}"
+    data-value="{{is_scalar($o)?$o:json_encode($o)}}"
 >
     @if (isset($field['allows_null']) && $field['allows_null']==true)
         @if($is_null)
@@ -91,8 +94,8 @@ if($ajax){
         <link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet"
               type="text/css"/>
         <link
-                href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
-                rel="stylesheet" type="text/css"/>
+            href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
+            rel="stylesheet" type="text/css"/>
     @endpush
 
     {{-- FIELD JS - will be loaded in the after_scripts section --}}