]> _ Git - cubist_cms-back.git/commitdiff
wip #4666 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Sep 2021 13:46:52 +0000 (15:46 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 23 Sep 2021 13:46:52 +0000 (15:46 +0200)
composer.json
src/app/Http/Controllers/Base/XSendFileController.php [new file with mode: 0644]
src/app/Http/Controllers/CubistStorageController.php [new file with mode: 0644]
src/app/Magic/Fields/Tags.php
src/app/Middleware/CubistMiddleware.php
src/routes/cubist/backpack/storage.php [new file with mode: 0644]

index a187e5269cac0a8fde94b018fded8a6ef5163651..a1001db7dfd717224426521a5b96eafcf56e290e 100644 (file)
@@ -23,7 +23,7 @@
         "ext-dom": "*",
         "ext-libxml": "*",
         "ext-json": "*",
-        "backpack/crud": "^4.1.53",
+        "backpack/crud": "^4.1.54",
         "backpack/backupmanager": "^3.0",
         "backpack/logmanager": "^4.0",
         "backpack/permissionmanager": "^6.0",
@@ -49,7 +49,9 @@
         "digitallyhappy/toggle-field-for-backpack": "^2.0",
         "calebporzio/parental": "^v0.11",
         "cache/filesystem-adapter": "^1.1",
-        "laravel/framework": "^v8.61"
+        "laravel/framework": "^v8.61",
+        "php-ffmpeg/php-ffmpeg": "^0.18.0",
+        "spatie/pdf-to-image": "^2.1"
     },
     "require-dev": {
         "filp/whoops": "^2.14",
diff --git a/src/app/Http/Controllers/Base/XSendFileController.php b/src/app/Http/Controllers/Base/XSendFileController.php
new file mode 100644 (file)
index 0000000..8392cbc
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+namespace Cubist\Backpack\Http\Controllers\Base;
+
+use Cubist\Util\Files\Files;
+use Illuminate\Routing\Controller;
+
+class XSendFileController extends Controller
+{
+    protected function xSendFile($path)
+    {
+        if (file_exists($path)) {
+            return response(null)->header('Content-Type', Files::_getMimeType($path))->header('X-Sendfile', $path);
+        } else {
+            return response(null)->setStatusCode(404);
+        }
+    }
+}
diff --git a/src/app/Http/Controllers/CubistStorageController.php b/src/app/Http/Controllers/CubistStorageController.php
new file mode 100644 (file)
index 0000000..42d0117
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace Cubist\Backpack\Http\Controllers;
+
+use Cubist\Backpack\Http\Controllers\Base\XSendFileController;
+use Illuminate\Support\Facades\Auth;
+
+class CubistStorageController extends XSendFileController
+{
+    public function storage($file)
+    {
+        if (!Auth::check()) {
+            dd(401);
+            return response(null)->setStatusCode('401');
+        }
+        if (!can('edition')) {
+            dd(403);
+            return response(null)->setStatusCode('403');
+        }
+        return $this->xSendFile(storage_path('app/public/' . $file));
+    }
+}
index a31028692eccb33ac0693fdf17230c1548574461..e6d157129eac2127c31ebb5f42f7e81a2bb1533c 100644 (file)
@@ -9,4 +9,5 @@ class Tags extends Field
     protected $_adminType = 'tags';
     protected $_cast = 'array';
     protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+    protected $_columnType = 'array';
 }
index c283ccd84f78c227f5efc8e7e7cbabbcbc837b98..7052271d511fe2e231f50eca21ea623c5e08a1e4 100644 (file)
@@ -36,7 +36,7 @@ class CubistMiddleware
 
     protected function onAdmin()
     {
-        return strpos($this->request->getPathInfo(), '/admin') === 0;
+        return strpos($this->request->getPathInfo(), backpack_url()) === 0;
     }
 
     public function handle(Request $request, Closure $next)
diff --git a/src/routes/cubist/backpack/storage.php b/src/routes/cubist/backpack/storage.php
new file mode 100644 (file)
index 0000000..275a950
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+Route::group([
+    //'prefix' => config('backpack.base.route_prefix', 'admin'),
+    'middleware' => ['web', config('backpack.base.middleware_key', 'admin')],
+], function () { // custom admin routes
+    Route::any('storage/{file?}', '\Cubist\Backpack\Http\Controllers\CubistStorageController@storage')->where(['file' => '.*']);
+});