diff --git a/app/CMS/Helpers/WidgetAreas.php b/app/CMS/Helpers/WidgetAreas.php index d102c94d..2db7e3c8 100644 --- a/app/CMS/Helpers/WidgetAreas.php +++ b/app/CMS/Helpers/WidgetAreas.php @@ -27,12 +27,12 @@ class WidgetAreas protected static function loadWidgetArea($uniqueCode) { - dd($uniqueCode); WidgetArea::where('code', $uniqueCode) ->increment('viewed'); $widgets = Cache::remember('widget-area-' . $uniqueCode, setting('widgetCacheLifetime', 5), function () use ($uniqueCode) { - $widgetArea = new WidgetArea(); + $widgetArea = app(\App\CMS\Repositories\Widgets\WidgetArea::class); + return $widgetArea->getWidgets($uniqueCode) ->get(); }); @@ -69,6 +69,8 @@ class WidgetAreas self::initWidgetAreas(); } +// dd($uniqueCode); + if (!isset(self::$widgetAreas[$uniqueCode])) { self::loadWidgetArea($uniqueCode); } diff --git a/app/Http/Controllers/Admin/Contents/ContentActions.php b/app/Http/Controllers/Admin/Contents/ContentActions.php index c73c4085..7ee63b40 100644 --- a/app/Http/Controllers/Admin/Contents/ContentActions.php +++ b/app/Http/Controllers/Admin/Contents/ContentActions.php @@ -7,6 +7,8 @@ use App\CMS\Interactions\Admin\Content\ChangeStatus; use App\CMS\Interactions\Admin\Content\DeletePage; use App\CMS\Interactions\Admin\Content\SetHomepage; use App\Http\Controllers\Admin\Controller; +use App\Models\Content\Content; +use App\Models\Content\ContentHistory; class ContentActions extends Controller { @@ -25,15 +27,13 @@ class ContentActions extends Controller * This method is called in static page overview from quick actions. It checks if status is valid, if page exists * and updates status. * - * @param $id - * @param $status + * @param Content $page + * @param $status * * @return \Illuminate\Http\RedirectResponse */ - public function changeStatus($id, $status) + public function changeStatus(Content $page, $status) { - $page = $this->content->getOne($id); - Interaction::handle(ChangeStatus::class, ['status' => $status], $page); // redirect back to overview with info for user @@ -45,14 +45,12 @@ class ContentActions extends Controller /** * Delete page * - * @param $id + * @param Content $page * * @return \Illuminate\Http\RedirectResponse */ - public function delete($id) + public function delete(Content $page) { - $page = $this->content->getOne($id); - Interaction::handle(DeletePage::class, [], $page); // redirect back to overview with info for user @@ -66,14 +64,12 @@ class ContentActions extends Controller /** * Sets page as homepage * - * @param $id + * @param Content $page * * @return \Illuminate\Http\RedirectResponse */ - public function setHomepage($id) + public function setHomepage(Content $page) { - $page = $this->content->getOne($id); - Interaction::handle(SetHomepage::class, [], $page); // redirect back to overview with info for user diff --git a/app/Http/Controllers/Admin/Contents/ContentOverview.php b/app/Http/Controllers/Admin/Contents/ContentOverview.php index b4f09afa..5a88e708 100644 --- a/app/Http/Controllers/Admin/Contents/ContentOverview.php +++ b/app/Http/Controllers/Admin/Contents/ContentOverview.php @@ -5,6 +5,7 @@ use App\CMS\Contracts\Repositories\Content as IContent; use App\CMS\Contracts\Repositories\Module as IModule; use App\CMS\Enumerations\ContentStatuses; use App\Http\Controllers\Admin\Controller; +use App\Models\Module; class ContentOverview extends Controller { @@ -26,19 +27,19 @@ class ContentOverview extends Controller /** * Overview for all content pages. * - * @param null|int $moduleId - * @param null $status + * @param Module|null $module + * @param null $status * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @internal param int|null $moduleId */ - public function index($moduleId = null, $status = null) + public function index(Module $module = null, $status = null) { // get module settings - $module = $this->module->getOne($moduleId); $pageHeading = $this->module->getOverviewTitle($module); // get pages for overview - $handler = $module !== null ? $module->handler : null; + $handler = $module->exists ? $module->handler : null; $pages = $this->content->getOverview($handler, [$status]) ->paginate(setting('paginatedResults', 20)); diff --git a/app/Http/Controllers/Admin/Contents/CreateNewContent.php b/app/Http/Controllers/Admin/Contents/CreateNewContent.php index 18081270..a1e7eeda 100644 --- a/app/Http/Controllers/Admin/Contents/CreateNewContent.php +++ b/app/Http/Controllers/Admin/Contents/CreateNewContent.php @@ -10,6 +10,7 @@ use App\Cms\Interactions\Admin\Content\NewContent; use App\Http\Controllers\Admin\Controller; use App\Http\Requests\CreateNewContentRequest; use App\Http\Requests\Request; +use App\Models\Module; use Modules\Categories\Contracts\Repositories\Category as ICategory; /** @@ -67,9 +68,8 @@ class CreateNewContent extends Controller * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function create($module) + public function create(Module $module) { - $module = $this->module->getOne($module); $statuses = ContentStatuses::getWithTranslations(); $pageHeading = $this->module->getCreateContentTitle($module); $templates = $this->template->getForModule($module); @@ -95,15 +95,14 @@ class CreateNewContent extends Controller /** * Save new content page * - * @param CreateNewContentRequest $request - * @param $moduleId + * @param CreateNewContentRequest|Request $request + * @param Module $module * * @return \Illuminate\Http\RedirectResponse + * @internal param $moduleId */ - public function store(Request $request, $moduleId) + public function store(Request $request, Module $module) { - $module = $this->module->getOne($moduleId); - // create new page Interaction::handle(NewContent::class, $request->all(), $module->handler); diff --git a/app/Http/Controllers/Admin/Contents/EditContent.php b/app/Http/Controllers/Admin/Contents/EditContent.php index 2a8d8355..8fefb577 100644 --- a/app/Http/Controllers/Admin/Contents/EditContent.php +++ b/app/Http/Controllers/Admin/Contents/EditContent.php @@ -72,14 +72,13 @@ class EditContent extends Controller /** * Display form for editing static page * - * @param $id + * @param Content $page * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function edit($id) + public function edit(Content $page) { $statuses = ContentStatuses::getWithTranslations(); - $page = $this->content->getOne($id); // get module ID $module = $this->module->getByHandler($page->moduleHandler); @@ -106,29 +105,14 @@ class EditContent extends Controller /** * Edit static page and save changes into history. * - * @param EditContentRequest $request - * @param $id + * @param EditContentRequest|Request $request + * @param Content $page * * @return \Illuminate\Http\RedirectResponse + * @internal param $id */ - public function update(Request $request, $id) + public function update(Request $request, Content $page) { - try { - /** - * @var $page Content - */ - $page = $this->content->getOne($id); - } catch (NotFoundHttpException $e) { - - // log attempt of invalid edit - Event::fire(new AttemptToEditInvalidContent($id)); - - // page for editing not found - return redirect() - ->route('content.overview') - ->with('error', trans('admin/contents.invalidPage')); - } - // edit page Interaction::handle(EditContentInteraction::class, $request->all(), $page); diff --git a/app/Http/Controllers/Admin/Contents/History.php b/app/Http/Controllers/Admin/Contents/History.php index 28b74412..7811b507 100644 --- a/app/Http/Controllers/Admin/Contents/History.php +++ b/app/Http/Controllers/Admin/Contents/History.php @@ -19,30 +19,31 @@ class History extends Controller } /** - * @param $id + * @param Content $page * * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function getOverview($id) + public function getOverview(Content $page) { - // test if given content id is static page and if exists - $content = Content::findOrFail($id); - - $history = $this->history->getStructuredHistoryOf($content); + $history = $this->history->getStructuredHistoryOf($page); return view('admin/history.overview', [ 'history' => $history, - 'page' => $content + 'page' => $page ]); } - public function getDiff($revision, $id) + /** + * @param ContentHistory $revision + * + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function getDiff(ContentHistory $revision) { - $change = $this->history->findOrFail($id); - $diff = $this->history->getDiff($change); + $diff = $this->history->getDiff($revision); return view('admin/history.diff', [ - 'change' => $change, + 'change' => $revision, 'diff' => $diff ]); } diff --git a/app/Http/Controllers/Admin/FileManager/UploadedFilesOverview.php b/app/Http/Controllers/Admin/FileManager/UploadedFilesOverview.php index 29612d5f..4f1ca901 100644 --- a/app/Http/Controllers/Admin/FileManager/UploadedFilesOverview.php +++ b/app/Http/Controllers/Admin/FileManager/UploadedFilesOverview.php @@ -32,12 +32,12 @@ class UploadedFilesOverview extends Controller */ public function index(Directory $directory = null) { - // include hidden directories? - $includeHidden = Input::get('hidden'); +// dd($directory); + // include hidden directories? $subdirectories = $this->directoryRepository->getAllSubdirectories($directory); - if (!$includeHidden) { + if (!Input::get('hidden', true)) { $subdirectories = $subdirectories->where('hidden', false); } diff --git a/app/Http/Controllers/Admin/Widgets/Areas/EditWidgetArea.php b/app/Http/Controllers/Admin/Widgets/Areas/EditWidgetArea.php index 57529865..4b93955d 100644 --- a/app/Http/Controllers/Admin/Widgets/Areas/EditWidgetArea.php +++ b/app/Http/Controllers/Admin/Widgets/Areas/EditWidgetArea.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Admin\Widgets\Areas; use App\CMS\Repositories\Widgets\WidgetArea as WidgetAreaRepository; +use App\Events\DeleteWidgetArea; use App\Http\Controllers\Admin\Controller; use App\Http\Requests\EditWidgetAreaRequest; use App\Models\Widgets\Widget; @@ -39,6 +40,7 @@ class EditWidgetArea extends Controller */ public function edit(WidgetArea $widgetArea) { + return view("test"); $associatedWidgetIds = WidgetInWidgetArea::getWidgetIdsFromArea($widgetArea->id); $widgets = Widget::where('language', LaravelLocalization::getCurrentLocale()) ->paginate(25); @@ -83,26 +85,14 @@ class EditWidgetArea extends Controller } // delete area - $area->delete(); + $widgetArea->delete(); // fire event with new widget area - Event::fire(new \App\Events\DeleteWidgetArea($area)); + Event::fire(new DeleteWidgetArea($widgetArea)); // redirect and inform user return redirect() ->route('widgetareas.overview') ->with('success', trans('admin/widgetAreas.successfullyDeleted')); } - - /** - * Redirect user to overview with message about invalid widget area - * - * @return \Illuminate\Http\RedirectResponse - */ - private function invalidArea() - { - return redirect() - ->route('widgetareas.overview') - ->with('error', trans('admin/widgetAreas.invalidArea')); - } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 0b7677f4..70219ecc 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -18,9 +18,7 @@ class Kernel extends HttpKernel { /** * The application's global HTTP middleware stack. - * * These middleware are run during every request to your application. - * * @var array */ protected $middleware = [ @@ -33,7 +31,6 @@ class Kernel extends HttpKernel ]; /** * The application's route middleware groups. - * * @var array */ protected $middlewareGroups = [ @@ -53,9 +50,7 @@ class Kernel extends HttpKernel ]; /** * The application's route middleware. - * * These middleware may be assigned to groups or used individually. - * * @var array */ protected $routeMiddleware = [ @@ -66,6 +61,7 @@ class Kernel extends HttpKernel 'throttle' => ThrottleRequests::class, 'localize' => LaravelLocalizationRoutes::class, 'localizationRedirect' => LaravelLocalizationRedirectFilter::class, - 'localeSessionRedirect' => LocaleSessionRedirect::class + 'localeSessionRedirect' => LocaleSessionRedirect::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, ]; } diff --git a/app/Http/routes.php b/app/Http/routes.php index c648aaf7..7c3340d1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -11,7 +11,7 @@ Route::pattern('url', '[0-9\-a-z]+'); /*******************************************************************************/ -Route::group(['prefix' => LaravelLocalization::setLocale()], function () { +Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['bindings']], function () { /** * This route group serves to handle request in admin */ diff --git a/app/Http/routes/admin/contents.php b/app/Http/routes/admin/contents.php index 54b70c6b..58028439 100644 --- a/app/Http/routes/admin/contents.php +++ b/app/Http/routes/admin/contents.php @@ -9,34 +9,34 @@ Route::group(['namespace' => 'Contents'], function () { ->name('content.new'); // form for editing existing static page - Route::get('content/edit/{id}', 'EditContent@edit') + Route::get('content/edit/{page}', 'EditContent@edit') ->name('content.edit'); // post method for creating new static page - Route::post('content/new/{moduleId}', 'CreateNewContent@store') + Route::post('content/new/{module}', 'CreateNewContent@store') ->name('content.newPost'); // post method for creating new static page - Route::post('content/edit/{id}', 'EditContent@update') + Route::post('content/edit/{page}', 'EditContent@update') ->name('content.editPost'); // change status of page (protected, public or draft) - Route::get('content/status/{id}/{status}', 'ContentActions@changeStatus') + Route::get('content/status/{page}/{status}', 'ContentActions@changeStatus') ->name('content.changeStatus'); // set homepage - Route::get('content/homepage/{id}', 'ContentActions@setHomepage') + Route::get('content/homepage/{page}', 'ContentActions@setHomepage') ->name('content.setHomepage'); // delete page - Route::get('content/delete/{id}', 'ContentActions@delete') + Route::get('content/delete/{page}', 'ContentActions@delete') ->name('content.delete'); // history of changes for specified page - Route::get('history/{id}', 'History@getOverview') + Route::get('history/{page}', 'History@getOverview') ->name('content.history'); // history of changes for specified page - Route::get('history/{revision}/{id}', 'History@getDiff') + Route::get('history/{revision}', 'History@getDiff') ->name('history.diff'); }); \ No newline at end of file diff --git a/app/Models/Module.php b/app/Models/Module.php index 47db16c3..43a4e2cf 100644 --- a/app/Models/Module.php +++ b/app/Models/Module.php @@ -27,4 +27,9 @@ class Module extends Model 'is_template' => 'boolean', 'has_submodules' => 'boolean' ]; + + public function getRouteKeyName() + { + return 'alias'; + } } \ No newline at end of file diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 16fd7677..98a9ad4b 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,30 +2,45 @@ namespace App\Providers; -use Illuminate\Routing\Router; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { /** - * This namespace is applied to the controller routes in your routes file. - * + * This namespace is applied to your controller routes. * In addition, it is set as the URL generator's root namespace. - * * @var string */ protected $namespace = 'App\Http\Controllers'; /** - * Define the routes for the application. - * - * @param \Illuminate\Routing\Router $router + * Define your route model bindings, pattern filters, etc. * @return void */ - public function map(Router $router) + public function boot() { - $router->group(['namespace' => $this->namespace], function ($router) { - require app_path('Http/routes.php'); - }); + parent::boot(); } -} + + /** + * Define the routes for the application. + * @return void + */ + public function map() + { + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * These routes all receive session state, CSRF protection, etc. + * @return void + */ + protected function mapWebRoutes() + { + Route::namespace($this->namespace) + ->middleware('web') + ->group(app_path('Http/routes.php')); + } +} \ No newline at end of file diff --git a/modules/Categories/Http/Controllers/CategoriesOverview.php b/modules/Categories/Http/Controllers/CategoriesOverview.php index 741754a8..3d142332 100644 --- a/modules/Categories/Http/Controllers/CategoriesOverview.php +++ b/modules/Categories/Http/Controllers/CategoriesOverview.php @@ -1,9 +1,8 @@ - - - @lang('categories::categories.name') - @lang('categories::categories.module') - @lang('categories::categories.actions') - - - - @foreach($categories as $category) - @include('categories::admin.snippets.overviewRow', ['level' => 0, 'currentCategory' => $category]) - @endforeach - - - @else -
- @lang('categories::categories.noCategories') + +
+
+ + @if(count($categories)) +
+ + + + + + + + + + + @foreach($categories as $category) + @include('categories::admin.snippets.overviewRow', ['level' => 0, 'currentCategory' => $category]) + @endforeach + +
@lang('categories::categories.name')@lang('categories::categories.module')@lang('categories::categories.actions')
+
+ @else +
+ @lang('categories::categories.noCategories') +
+ @endif
- @endif +
@stop \ No newline at end of file diff --git a/modules/Categories/Resources/views/admin/snippets/overviewRow.blade.php b/modules/Categories/Resources/views/admin/snippets/overviewRow.blade.php index 13c15e65..f92a53fa 100644 --- a/modules/Categories/Resources/views/admin/snippets/overviewRow.blade.php +++ b/modules/Categories/Resources/views/admin/snippets/overviewRow.blade.php @@ -1,11 +1,33 @@ - {{str_repeat('-', $level)}} {{$currentCategory['name']}} + {{str_repeat('-', $level)}} {{$currentCategory['name']}} @lang($modules[$currentCategory['module_id']]) - - +
+ + + + + + + + +
+
    + +
  • + +
  • +
  • + +
  • +
+
+
diff --git a/modules/Categories/composer.json b/modules/Categories/composer.json deleted file mode 100644 index 660f3a21..00000000 --- a/modules/Categories/composer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "pingpong-modules/categories", - "description": "", - "authors": [ - { - "name": "Pingpong Labs", - "email": "pingpong.labs@gmail.com" - } - ], - "autoload": { - "psr-4": { - "Modules\\Categories\\": "" - } - } -} \ No newline at end of file diff --git a/modules/Gallery/Handlers/Gallery.php b/modules/Gallery/Handlers/Gallery.php index f27a9445..ccfd44d8 100644 --- a/modules/Gallery/Handlers/Gallery.php +++ b/modules/Gallery/Handlers/Gallery.php @@ -187,9 +187,8 @@ class Gallery implements AppHandler $menu = \Menu::instance('mainMenu'); $submenu = $menu->whereTitle(trans('admin/mainMenu.contentPages')); $submenu->dropdown(trans('gallery::module.name'), function ($submenu) use ($user) { - $submenu->route('content.new', trans('gallery::admin/adminMenu.new'), ['moduleId' => self::getModuleId()], 10, ['icon' => 'fa fa-plus']); - $submenu->route('content.overview', trans('gallery::admin/adminMenu.overview'), ['moduleId' => self::getModuleId()], 20, ['icon' => 'fa fa-list']); - // $submenu->route('emails.sent', trans('contactform::admin/adminMenu.sentMessages'), [], 30, ['icon' => 'fa fa-send']); + $submenu->route('content.new', trans('gallery::admin/adminMenu.new'), ['module' => 'gallery'], 10, ['icon' => 'fa fa-plus']); + $submenu->route('content.overview', trans('gallery::admin/adminMenu.overview'), ['module' => 'gallery'], 20, ['icon' => 'fa fa-list']); }, 25, ['icon' => 'fa fa-camera']); } diff --git a/resources/views/admin/content/overview.blade.php b/resources/views/admin/content/overview.blade.php index 0bdb21bb..c1b3f433 100644 --- a/resources/views/admin/content/overview.blade.php +++ b/resources/views/admin/content/overview.blade.php @@ -4,7 +4,7 @@ @section('headerButtons') @if($module->exists === true) - + @endif @@ -36,7 +36,7 @@ @foreach($pages as $page)
- + {{$page->title}} @@ -66,7 +66,7 @@ @else tag-warning @endif">{{$statuses[$page->status]}}
@@ -87,7 +87,7 @@ @if(!$page->isHomepage)
  • - @@ -96,7 +96,7 @@ @endif
  • - @@ -104,14 +104,14 @@ @if($page->isDraft())
  • -
  • - @@ -126,7 +126,7 @@
  • - @@ -135,7 +135,7 @@ @endif
  • - diff --git a/resources/views/admin/widgets/area/edit.blade.php b/resources/views/admin/widgets/area/edit.blade.php index 67900ed5..2d1b4442 100644 --- a/resources/views/admin/widgets/area/edit.blade.php +++ b/resources/views/admin/widgets/area/edit.blade.php @@ -14,6 +14,8 @@

    @lang('admin/widgets.preview')

    +{{-- {{dd($area)}}--}} + @widgetArea($area->code)