From: Vincent Vanwaelscappel Date: Thu, 3 Dec 2020 12:40:32 +0000 (+0100) Subject: wip #3753 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e0350a745b794714d240d85d86ff1441185f7304;p=cubist_cms-back.git wip #3753 @1 --- diff --git a/composer.json b/composer.json index 33a43e6..8a08db1 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,8 @@ "minimum-stability": "dev", "prefer-stable": true, "autoload": { - "psr-0": { - "Cubist\\Backpack\\": "src" + "psr-4": { + "Cubist\\Backpack\\": "src/app" }, "files": [ "src/app/helpers.php" diff --git a/src/CubistBackpackServiceProvider.php b/src/CubistBackpackServiceProvider.php index 85a3425..e5934fa 100644 --- a/src/CubistBackpackServiceProvider.php +++ b/src/CubistBackpackServiceProvider.php @@ -2,16 +2,16 @@ namespace Cubist\Backpack; -use Cubist\Backpack\app\Console\Commands\MigrateCommand; -use Cubist\Backpack\app\Console\Commands\GenerateCommand; -use Cubist\Backpack\app\Console\Commands\InstallCommand; -use Cubist\Backpack\app\Console\Commands\LocaleCopy; -use Cubist\Backpack\app\Console\Commands\LocaleSlugReset; -use Cubist\Backpack\app\Console\Commands\SearchIndexCommand; -use Cubist\Backpack\app\Console\Commands\UpdateCommand; +use Cubist\Backpack\Console\Commands\MigrateCommand; +use Cubist\Backpack\Console\Commands\GenerateCommand; +use Cubist\Backpack\Console\Commands\InstallCommand; +use Cubist\Backpack\Console\Commands\LocaleCopy; +use Cubist\Backpack\Console\Commands\LocaleSlugReset; +use Cubist\Backpack\Console\Commands\SearchIndexCommand; +use Cubist\Backpack\Console\Commands\UpdateCommand; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; -use Cubist\Backpack\app\CubistCrudPanel; +use Cubist\Backpack\CubistCrudPanel; class CubistBackpackServiceProvider extends ServiceProvider { diff --git a/src/app/Application.php b/src/app/Application.php index b856973..3b5f7d5 100644 --- a/src/app/Application.php +++ b/src/app/Application.php @@ -1,6 +1,6 @@ crud->hasAccessOrFail('show'); + + // get entry ID from Request (makes sure its the last ID for nested resources) + $id = $this->crud->getCurrentEntryId() ?? $id; + $setFromDb = $this->crud->get('show.setFromDb'); + + // get the info for that entry + $this->data['entry'] = $this->crud->getEntry($id); + $this->data['crud'] = $this->crud; + $this->data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.preview') . ' ' . $this->crud->entity_name; + + // set columns from db + if ($setFromDb) { + $this->crud->setFromDb(); + } + + // cycle through columns + foreach ($this->crud->columns() as $key => $column) { + + debug($column); + // remove any autoset relationship columns + if (array_key_exists('model', $column) && array_key_exists('autoset', $column) && $column['autoset']) { + $this->crud->removeColumn($column['key']); + } + + // remove any autoset table columns + if ($column['type'] == 'table' && array_key_exists('autoset', $column) && $column['autoset']) { + $this->crud->removeColumn($column['key']); + } + + // remove the row_number column, since it doesn't make sense in this context + if ($column['type'] == 'row_number') { + $this->crud->removeColumn($column['key']); + } + + // remove columns that have visibleInShow set as false + if (isset($column['visibleInShow']) && $column['visibleInShow'] == false) { + $this->crud->removeColumn($column['key']); + } + + // remove the character limit on columns that take it into account + if (in_array($column['type'], ['text', 'email', 'model_function', 'model_function_attribute', 'phone', 'row_number', 'select'])) { + $this->crud->modifyColumn($column['key'], ['limit' => ($column['limit'] ?? 999)]); + } + } + + // remove preview button from stack:line + $this->crud->removeButton('show'); + + // remove bulk actions colums + $this->crud->removeColumns(['blank_first_column', 'bulk_actions']); + + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package + return view($this->crud->getShowView(), $this->data); + } } diff --git a/src/app/Magic/BunchOfFields.php b/src/app/Magic/BunchOfFields.php index 15b1166..92c181d 100644 --- a/src/app/Magic/BunchOfFields.php +++ b/src/app/Magic/BunchOfFields.php @@ -1,11 +1,11 @@ $body ]); - /** @var Cubist\Backpack\app\Magic\Menu\Item[] $pages */ + /** @var Cubist\Backpack\Magic\Menu\Item[] $pages */ $pages = Menu::getAllNavigablePages($locale, $variant); $indexed = []; diff --git a/src/app/Magic/SubForm.php b/src/app/Magic/SubForm.php index 0c5cb4d..4a6560f 100644 --- a/src/app/Magic/SubForm.php +++ b/src/app/Magic/SubForm.php @@ -1,7 +1,7 @@ [ - 'App' => Cubist\Backpack\app\Facades\App::class, + 'App' => Cubist\Backpack\Facades\App::class, 'Arr' => Illuminate\Support\Arr::class, 'Str' => Illuminate\Support\Str::class, ], diff --git a/src/resources/install/app/Http/Controllers/PageController.php b/src/resources/install/app/Http/Controllers/PageController.php index 8881bfd..af718d8 100644 --- a/src/resources/install/app/Http/Controllers/PageController.php +++ b/src/resources/install/app/Http/Controllers/PageController.php @@ -2,7 +2,7 @@ namespace App\Http\Controllers; -use Cubist\Backpack\app\Http\Controllers\CubistPageController; +use Cubist\Backpack\Http\Controllers\CubistPageController; class PageController extends CubistPageController { diff --git a/src/resources/install/app/Http/Kernel.php b/src/resources/install/app/Http/Kernel.php index 8fbb543..88476b6 100644 --- a/src/resources/install/app/Http/Kernel.php +++ b/src/resources/install/app/Http/Kernel.php @@ -19,7 +19,7 @@ class Kernel extends HttpKernel \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, - \Cubist\Backpack\app\Middleware\VariantSelector::class, + \Cubist\Backpack\Middleware\VariantSelector::class, \Spatie\Honeypot\ProtectAgainstSpam::class, ]; @@ -35,12 +35,12 @@ class Kernel extends HttpKernel \Illuminate\Session\Middleware\StartSession::class, \Backpack\CRUD\app\Http\Middleware\UseBackpackAuthGuardInsteadOfDefaultAuthGuard::class, \Illuminate\Session\Middleware\AuthenticateSession::class, - \Cubist\Backpack\app\Middleware\VariantSelector::class, - \Cubist\Backpack\app\Middleware\LocaleSelector::class, + \Cubist\Backpack\Middleware\VariantSelector::class, + \Cubist\Backpack\Middleware\LocaleSelector::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, - \Cubist\Backpack\app\Middleware\EmailObfuscate::class, + \Cubist\Backpack\Middleware\EmailObfuscate::class, \App\Http\Middleware\Menu::class, ], @@ -83,8 +83,8 @@ class Kernel extends HttpKernel \App\Http\Middleware\Authenticate::class, \Illuminate\Routing\Middleware\ThrottleRequests::class, \Illuminate\Session\Middleware\AuthenticateSession::class, - \Cubist\Backpack\app\Middleware\VariantSelector::class, - \Cubist\Backpack\app\Middleware\LocaleSelector::class, + \Cubist\Backpack\Middleware\VariantSelector::class, + \Cubist\Backpack\Middleware\LocaleSelector::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Auth\Middleware\Authorize::class, ]; diff --git a/src/resources/install/app/Models/Locale.php b/src/resources/install/app/Models/Locale.php index fd75ee0..093c228 100644 --- a/src/resources/install/app/Models/Locale.php +++ b/src/resources/install/app/Models/Locale.php @@ -2,7 +2,7 @@ namespace App\Models; -class Locale extends \Cubist\Backpack\app\Magic\Models\Locale +class Locale extends \Cubist\Backpack\Magic\Models\Locale { } diff --git a/src/resources/install/app/Models/Page.php b/src/resources/install/app/Models/Page.php index f2fc9bb..1775a51 100644 --- a/src/resources/install/app/Models/Page.php +++ b/src/resources/install/app/Models/Page.php @@ -2,7 +2,7 @@ namespace App\Models; -use Cubist\Backpack\app\Magic\Models\CMSPage; +use Cubist\Backpack\Magic\Models\CMSPage; class Page extends CMSPage { diff --git a/src/resources/install/app/Models/Settings.php b/src/resources/install/app/Models/Settings.php index f6c57cc..7210b64 100644 --- a/src/resources/install/app/Models/Settings.php +++ b/src/resources/install/app/Models/Settings.php @@ -4,7 +4,7 @@ namespace App\Models; -class Settings extends \Cubist\Backpack\app\Magic\Models\Settings +class Settings extends \Cubist\Backpack\Magic\Models\Settings { public function setFields() { diff --git a/src/resources/install/bootstrap/app.php b/src/resources/install/bootstrap/app.php index 521fba4..8d4e15e 100644 --- a/src/resources/install/bootstrap/app.php +++ b/src/resources/install/bootstrap/app.php @@ -11,7 +11,7 @@ | */ -$app = new Cubist\Backpack\app\Application( +$app = new Cubist\Backpack\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) ); diff --git a/src/resources/install/config/markdown.php b/src/resources/install/config/markdown.php index 5f7115c..fbb3d62 100644 --- a/src/resources/install/config/markdown.php +++ b/src/resources/install/config/markdown.php @@ -42,11 +42,11 @@ return [ */ 'extensions' => [ - Cubist\Backpack\app\Markdown\Heading\Extension::class, - Cubist\Backpack\app\Markdown\Wrapper\Extension::class, + Cubist\Backpack\Markdown\Heading\Extension::class, + Cubist\Backpack\Markdown\Wrapper\Extension::class, League\CommonMark\Ext\Autolink\AutolinkExtension::class, League\CommonMark\Ext\Table\TableExtension::class, - Cubist\Backpack\app\Markdown\InternalLink\Extension::class, + Cubist\Backpack\Markdown\InternalLink\Extension::class, ], diff --git a/src/resources/views/favicon.blade.php b/src/resources/views/favicon.blade.php index 364cd70..c123d21 100644 --- a/src/resources/views/favicon.blade.php +++ b/src/resources/views/favicon.blade.php @@ -1,6 +1,6 @@ -@foreach(Cubist\Backpack\app\Http\Controllers\CubistPWAController::$faviconSizes as $size) +@foreach(Cubist\Backpack\Http\Controllers\CubistPWAController::$faviconSizes as $size) @endforeach -@foreach(Cubist\Backpack\app\Http\Controllers\CubistPWAController::$iosSizes as $size) +@foreach(Cubist\Backpack\Http\Controllers\CubistPWAController::$iosSizes as $size) @endforeach diff --git a/src/resources/views/fields/button.blade.php b/src/resources/views/fields/button.blade.php index 8cf274a..5854edc 100644 --- a/src/resources/views/fields/button.blade.php +++ b/src/resources/views/fields/button.blade.php @@ -4,7 +4,7 @@ $link_types = ['none' => 'Désactiver', 'page_link' => trans('backpack::crud.page_link'), 'internal_link' => trans('backpack::crud.internal_link'), 'external_link' => trans('backpack::crud.external_link')]; $field['allows_null'] = false; $page_model = $field['page_model']; -$active_pages = \Cubist\Backpack\app\Magic\Models\CMSPage::getPagesList(); +$active_pages = \Cubist\Backpack\Magic\Models\CMSPage::getPagesList(); $empty = ['label' => '', 'type' => 'none', 'link' => '', 'external_link' => '', 'page_id' => '']; $value = old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? []; diff --git a/src/routes/cubist/backpack/pwa.php b/src/routes/cubist/backpack/pwa.php index 1573788..3046fcc 100644 --- a/src/routes/cubist/backpack/pwa.php +++ b/src/routes/cubist/backpack/pwa.php @@ -1,3 +1,3 @@