From 9cd6604210f2151d4d3a4853789eee6e2c3f259d Mon Sep 17 00:00:00 2001 From: Tedozi Manson Date: Mon, 28 Nov 2016 09:25:43 +0700 Subject: [PATCH] Refactor --- .../Controllers/Resolvers/PageController.php | 8 +- .../SlugWithoutSuffixController.php | 4 +- composer.json | 6 +- database/seeds/PagesDatabaseSeeder.php | 2 +- documentation/console/module.md | 8 +- plugins/blog/module.json | 3 +- plugins/blog/src/Providers/ModuleProvider.php | 10 +- .../src/Repositories/CategoryRepository.php | 2 +- plugins/custom-fields/module.json | 3 +- .../src/Hook/Actions/Render/Categories.php | 2 +- .../src/Hook/Actions/Render/Pages.php | 2 +- .../src/Hook/Actions/Store/Pages.php | 2 +- .../BootstrapModuleServiceProvider.php | 7 +- .../src/Providers/ModuleProvider.php | 20 +- plugins/pages/database/migrations/.gitkeep | 0 plugins/pages/database/seeds/.gitkeep | 0 plugins/pages/module.json | 10 - plugins/pages/resources/lang/.gitkeep | 0 .../resources/views/admin/edit.blade.php | 169 --------- .../resources/views/admin/index.blade.php | 52 --- .../src/Http/Controllers/PageController.php | 349 ------------------ .../src/Http/Requests/UpdatePageRequest.php | 21 -- .../Models/Contracts/PageModelContract.php | 5 - plugins/pages/src/Models/EloquentPage.php | 15 - .../BootstrapModuleServiceProvider.php | 120 ------ .../InstallModuleServiceProvider.php | 60 --- .../pages/src/Providers/ModuleProvider.php | 46 --- .../Providers/RepositoryServiceProvider.php | 28 -- .../src/Providers/RouteServiceProvider.php | 57 --- .../UninstallModuleServiceProvider.php | 40 -- .../Repositories/Contracts/PageContract.php | 23 -- .../pages/src/Repositories/PageRepository.php | 69 ---- .../PageRepositoryCacheDecorator.php | 37 -- public/admin/plugins/ckeditor/config.js | 3 +- .../src/Http/Controllers/PageController.php | 8 +- .../src/Http/Controllers/PageController.php | 8 +- 36 files changed, 41 insertions(+), 1158 deletions(-) delete mode 100644 plugins/pages/database/migrations/.gitkeep delete mode 100644 plugins/pages/database/seeds/.gitkeep delete mode 100644 plugins/pages/module.json delete mode 100644 plugins/pages/resources/lang/.gitkeep delete mode 100644 plugins/pages/resources/views/admin/edit.blade.php delete mode 100644 plugins/pages/resources/views/admin/index.blade.php delete mode 100644 plugins/pages/src/Http/Controllers/PageController.php delete mode 100644 plugins/pages/src/Http/Requests/UpdatePageRequest.php delete mode 100644 plugins/pages/src/Models/Contracts/PageModelContract.php delete mode 100644 plugins/pages/src/Models/EloquentPage.php delete mode 100644 plugins/pages/src/Providers/BootstrapModuleServiceProvider.php delete mode 100644 plugins/pages/src/Providers/InstallModuleServiceProvider.php delete mode 100644 plugins/pages/src/Providers/ModuleProvider.php delete mode 100644 plugins/pages/src/Providers/RepositoryServiceProvider.php delete mode 100644 plugins/pages/src/Providers/RouteServiceProvider.php delete mode 100644 plugins/pages/src/Providers/UninstallModuleServiceProvider.php delete mode 100644 plugins/pages/src/Repositories/Contracts/PageContract.php delete mode 100644 plugins/pages/src/Repositories/PageRepository.php delete mode 100644 plugins/pages/src/Repositories/PageRepositoryCacheDecorator.php diff --git a/app/Http/Controllers/Resolvers/PageController.php b/app/Http/Controllers/Resolvers/PageController.php index e1a1fc0..f5bce9c 100644 --- a/app/Http/Controllers/Resolvers/PageController.php +++ b/app/Http/Controllers/Resolvers/PageController.php @@ -3,10 +3,10 @@ use App\Http\Controllers\AbstractController; use WebEd\Plugins\Blog\Repositories\Contracts\PostRepositoryContract; use WebEd\Plugins\Blog\Repositories\PostRepository; -use WebEd\Plugins\Pages\Models\Contracts\PageModelContract; -use WebEd\Plugins\Pages\Models\EloquentPage; -use WebEd\Plugins\Pages\Repositories\Contracts\PageContract; -use WebEd\Plugins\Pages\Repositories\PageRepository; +use WebEd\Base\Pages\Models\Contracts\PageModelContract; +use WebEd\Base\Pages\Models\EloquentPage; +use WebEd\Base\Pages\Repositories\Contracts\PageContract; +use WebEd\Base\Pages\Repositories\PageRepository; class PageController extends AbstractController { diff --git a/app/Http/Controllers/SlugWithoutSuffixController.php b/app/Http/Controllers/SlugWithoutSuffixController.php index c58ee86..4701a79 100644 --- a/app/Http/Controllers/SlugWithoutSuffixController.php +++ b/app/Http/Controllers/SlugWithoutSuffixController.php @@ -1,8 +1,8 @@ $row) { - \WebEd\Plugins\Pages\Models\EloquentPage::create([ + \WebEd\Base\Pages\Models\EloquentPage::create([ 'title' => $row, 'page_template' => $row, 'status' => 'activated', diff --git a/documentation/console/module.md b/documentation/console/module.md index 2ac8484..1544bfe 100644 --- a/documentation/console/module.md +++ b/documentation/console/module.md @@ -11,16 +11,16 @@ php artisan cms:install --refresh ####Get all modules information ``` -php artisan cms:get:modules -php artisan cms:get:modules --type=base -php artisan cms:get:modules --type=plugins +php artisan module:list +php artisan module:list --type=base +php artisan module:list --type=plugins ``` ####Export a base module When you need to modify a base core module. It's time to use export method. To know the alias of module, just run: ``` -php artisan cms:get:modules --type=base +php artisan module:list --type=base ``` Then run ``` diff --git a/plugins/blog/module.json b/plugins/blog/module.json index 17f1d9c..40a0592 100644 --- a/plugins/blog/module.json +++ b/plugins/blog/module.json @@ -5,6 +5,5 @@ "description": "Blog management package.", "namespace": "WebEd\\Plugins\\Blog", "version": "2.0", - "autoload": "psr-4", - "enabled": false + "autoload": "psr-4" } diff --git a/plugins/blog/src/Providers/ModuleProvider.php b/plugins/blog/src/Providers/ModuleProvider.php index f50fc98..f5c69a7 100644 --- a/plugins/blog/src/Providers/ModuleProvider.php +++ b/plugins/blog/src/Providers/ModuleProvider.php @@ -41,18 +41,10 @@ public function boot() public function register() { //Load helpers - $this->loadHelpers(); + load_module_helpers(__DIR__); $this->app->register(RouteServiceProvider::class); $this->app->register(RepositoryServiceProvider::class); $this->app->register(BootstrapModuleServiceProvider::class); } - - protected function loadHelpers() - { - $helpers = $this->app['files']->glob(__DIR__ . '/../../helpers/*.php'); - foreach ($helpers as $helper) { - require_once $helper; - } - } } diff --git a/plugins/blog/src/Repositories/CategoryRepository.php b/plugins/blog/src/Repositories/CategoryRepository.php index 85a7c7b..c3c8617 100644 --- a/plugins/blog/src/Repositories/CategoryRepository.php +++ b/plugins/blog/src/Repositories/CategoryRepository.php @@ -12,7 +12,7 @@ class CategoryRepository extends AbstractBaseRepository implements CategoryRepos 'parent_id' => 'integer|min:0|nullable', 'page_template' => 'string|max:255|nullable', 'title' => 'string|max:255|required', - 'slug' => 'string|max:255|alpha_dash|unique:posts', + 'slug' => 'string|max:255|alpha_dash|unique:categories', 'description' => 'string|max:1000', 'content' => 'string', 'thumbnail' => 'string|max:255', diff --git a/plugins/custom-fields/module.json b/plugins/custom-fields/module.json index 2ad9a4f..8308105 100644 --- a/plugins/custom-fields/module.json +++ b/plugins/custom-fields/module.json @@ -5,6 +5,5 @@ "description": "Custom fields management package", "namespace": "WebEd\\Plugins\\CustomFields", "version": "2.0", - "autoload": "psr-4", - "enabled": false + "autoload": "psr-4" } diff --git a/plugins/custom-fields/src/Hook/Actions/Render/Categories.php b/plugins/custom-fields/src/Hook/Actions/Render/Categories.php index 0a849d8..8afd702 100644 --- a/plugins/custom-fields/src/Hook/Actions/Render/Categories.php +++ b/plugins/custom-fields/src/Hook/Actions/Render/Categories.php @@ -1,7 +1,7 @@ registerRule('Basic', 'Page', 'page', function () { - $pageRepository = $this->app->make(\WebEd\Plugins\Pages\Repositories\Contracts\PageContract::class); + $pageRepository = $this->app->make(\WebEd\Base\Pages\Repositories\Contracts\PageContract::class); $pages = $pageRepository->all([ 'order' => 'ASC', 'title' => 'ASC', @@ -122,7 +122,8 @@ private function registerPagesFields() private function registerBlogFields() { - if (interface_exists('\WebEd\Plugins\Blog\Repositories\Contracts\PostRepositoryContract') && + if ( + interface_exists('\WebEd\Plugins\Blog\Repositories\Contracts\PostRepositoryContract') && interface_exists('\WebEd\Plugins\Blog\Repositories\Contracts\CategoryRepositoryContract') ) { /** diff --git a/plugins/custom-fields/src/Providers/ModuleProvider.php b/plugins/custom-fields/src/Providers/ModuleProvider.php index 1d31885..c6938f3 100644 --- a/plugins/custom-fields/src/Providers/ModuleProvider.php +++ b/plugins/custom-fields/src/Providers/ModuleProvider.php @@ -34,11 +34,6 @@ public function boot() $this->publishes([ __DIR__ . '/../../database' => base_path('database'), ], 'migrations'); - - //Register related facades - $loader = \Illuminate\Foundation\AliasLoader::getInstance(); - $loader->alias('CustomFieldRules', CustomFieldRules::class); - $loader->alias('RenderCustomFields', RenderCustomFields::class); } /** @@ -49,19 +44,16 @@ public function boot() public function register() { //Load helpers - $this->loadHelpers(); + load_module_helpers(__DIR__); + + //Register related facades + $loader = \Illuminate\Foundation\AliasLoader::getInstance(); + $loader->alias('CustomFieldRules', CustomFieldRules::class); + $loader->alias('RenderCustomFields', RenderCustomFields::class); $this->app->register(RouteServiceProvider::class); $this->app->register(RepositoryServiceProvider::class); $this->app->register(HookServiceProvider::class); $this->app->register(BootstrapModuleServiceProvider::class); } - - protected function loadHelpers() - { - $helpers = $this->app['files']->glob(__DIR__ . '/../../helpers/*.php'); - foreach ($helpers as $helper) { - require_once $helper; - } - } } diff --git a/plugins/pages/database/migrations/.gitkeep b/plugins/pages/database/migrations/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/pages/database/seeds/.gitkeep b/plugins/pages/database/seeds/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/pages/module.json b/plugins/pages/module.json deleted file mode 100644 index 54ea0e3..0000000 --- a/plugins/pages/module.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "alias": "webed-pages", - "name": "Pages", - "version": "2.0", - "author": "Tedozi Manson - https://github.com/duyphan2502", - "description": "Pages management package", - "namespace": "WebEd\\Plugins\\Pages", - "autoload": "psr-4", - "enabled": false -} diff --git a/plugins/pages/resources/lang/.gitkeep b/plugins/pages/resources/lang/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/pages/resources/views/admin/edit.blade.php b/plugins/pages/resources/views/admin/edit.blade.php deleted file mode 100644 index 44e76ac..0000000 --- a/plugins/pages/resources/views/admin/edit.blade.php +++ /dev/null @@ -1,169 +0,0 @@ -@extends('webed-core::admin._master') - -@section('css') - -@endsection - -@section('js') - -@endsection - -@section('js-init') - -@endsection - -@section('content') - {!! Form::open(['class' => 'js-validate-form', 'url' => route('admin::pages.edit.post', ['id' => $currentId])]) !!} - - {!! Form::close() !!} -@endsection diff --git a/plugins/pages/resources/views/admin/index.blade.php b/plugins/pages/resources/views/admin/index.blade.php deleted file mode 100644 index b43398f..0000000 --- a/plugins/pages/resources/views/admin/index.blade.php +++ /dev/null @@ -1,52 +0,0 @@ -@extends('webed-core::admin._master') - -@section('css') - -@endsection - -@section('js') - -@endsection - -@section('js-init') - -@endsection - -@section('content') -
-
-
-
-

- - All pages -

- -
- -
- @include('webed-core::admin._components.datatables', (isset($dataTableColumns) ? $dataTableColumns : [])) -
- -
-
- @php do_action('meta_boxes', 'main', 'webed-pages.index') @endphp -
-@endsection diff --git a/plugins/pages/src/Http/Controllers/PageController.php b/plugins/pages/src/Http/Controllers/PageController.php deleted file mode 100644 index 59f70b6..0000000 --- a/plugins/pages/src/Http/Controllers/PageController.php +++ /dev/null @@ -1,349 +0,0 @@ -repository = $pageRepository; - - $this->breadcrumbs->addLink('Pages', route('admin::pages.index.get')); - - $this->getDashboardMenu($this->module); - } - - /** - * Show index page - * @method GET - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function getIndex() - { - $this->assets->addJavascripts('jquery-datatables'); - - $this->setPageTitle('CMS pages', 'All available cms pages'); - - $this->dis['dataTableColumns'] = [ - 'headings' => [ - ['name' => 'Title', 'width' => '25%'], - ['name' => 'Page template', 'width' => '15%'], - ['name' => 'Status', 'width' => '10%'], - ['name' => 'Sort order', 'width' => '10%'], - ['name' => 'Created at', 'width' => '10%'], - ['name' => 'Actions', 'width' => '20%'], - ], - 'filter' => [ - 1 => form()->text('title', '', [ - 'class' => 'form-control form-filter input-sm', - 'placeholder' => 'Search...' - ]), - 2 => form()->text('page_template', '', [ - 'class' => 'form-control form-filter input-sm', - 'placeholder' => 'Search...' - ]), - 3 => form()->select('status', [ - '' => '', - 'activated' => 'Activated', - 'disabled' => 'Disabled', - ], null, ['class' => 'form-control form-filter input-sm']) - ], - 'tableActions' => form()->select('', [ - '' => 'Select' . '...', - 'deleted' => 'Deleted', - 'activated' => 'Activated', - 'disabled' => 'Disabled', - ], null, [ - 'class' => 'table-group-action-input form-control input-inline input-small input-sm' - ]) - ]; - - $this->dis['dataTableHeadings'] = json_encode([ - ['data' => 'id', 'name' => 'id', 'searchable' => false, 'orderable' => false], - ['data' => 'title', 'name' => 'title'], - ['data' => 'page_template', 'name' => 'page_template'], - ['data' => 'status', 'name' => 'status'], - ['data' => 'order', 'name' => 'order', 'searchable' => false], - ['data' => 'created_at', 'name' => 'created_at', 'searchable' => false], - ['data' => 'actions', 'name' => 'actions', 'searchable' => false, 'orderable' => false], - ]); - - return do_filter('pages.index.get', $this)->viewAdmin('index'); - } - - /** - * Get data for DataTable - * @param DataTables $dataTable - * @return \Illuminate\Http\JsonResponse - */ - public function postListing(DataTables $dataTable) - { - $data = $dataTable - ->of($this->repository) - ->with($this->groupAction()) - ->editColumn('id', function ($item) { - return \Form::customCheckbox(['id[]' => [$item->id]]); - }) - ->editColumn('status', function ($item) { - return \Html::label($item->status, $item->status); - }) - ->addColumn('actions', function ($item) { - /*Edit link*/ - $activeLink = route('admin::pages.update-status.post', ['id' => $item->id, 'status' => 'activated']); - $disableLink = route('admin::pages.update-status.post', ['id' => $item->id, 'status' => 'disabled']); - $deleteLink = route('admin::pages.delete.delete', ['id' => $item->id]); - - /*Buttons*/ - $editBtn = link_to(route('admin::pages.edit.get', ['id' => $item->id]), 'Edit', ['class' => 'btn btn-sm btn-outline green']); - $activeBtn = ($item->status != 'activated') ? \Form::button('', [ - 'title' => 'Active this item', - 'data-ajax' => $activeLink, - 'data-method' => 'POST', - 'data-toggle' => 'confirmation', - 'class' => 'btn btn-outline blue btn-sm ajax-link', - 'type' => 'button', - ]) : ''; - $disableBtn = ($item->status != 'disabled') ? \Form::button('', [ - 'title' => 'Disable this item', - 'data-ajax' => $disableLink, - 'data-method' => 'POST', - 'data-toggle' => 'confirmation', - 'class' => 'btn btn-outline yellow-lemon btn-sm ajax-link', - 'type' => 'button', - ]) : ''; - $deleteBtn = \Form::button('', [ - 'title' => 'Delete this item', - 'data-ajax' => $deleteLink, - 'data-method' => 'DELETE', - 'data-toggle' => 'confirmation', - 'class' => 'btn btn-outline red-sunglo btn-sm ajax-link', - 'type' => 'button', - ]); - - return $editBtn . $activeBtn . $disableBtn . $deleteBtn; - }); - - return do_filter('datatables.pages.index.post', $data, $this) - ->make(true); - } - - /** - * Handle group actions - * @return array - */ - private function groupAction() - { - $data = []; - if ($this->request->get('customActionType', null) === 'group_action') { - if(!$this->userRepository->hasPermission($this->loggedInUser, 'edit-pages')) { - return [ - 'customActionMessage' => 'You do not have permission', - 'customActionStatus' => 'danger', - ]; - } - - $ids = (array)$this->request->get('id', []); - $actionValue = $this->request->get('customActionValue'); - - switch ($actionValue) { - case 'deleted': - if(!$this->userRepository->hasPermission($this->loggedInUser, 'delete-pages')) { - return [ - 'customActionMessage' => 'You do not have permission', - 'customActionStatus' => 'danger', - ]; - } - /** - * Delete pages - */ - $result = $this->deleteDelete($ids); - break; - case 'activated': - case 'disabled': - $result = $this->repository->updateMultiple($ids, [ - 'status' => $actionValue, - ], true); - break; - default: - $result = [ - 'messages' => 'Method not allowed', - 'error' => true - ]; - break; - } - $data['customActionMessage'] = $result['messages']; - $data['customActionStatus'] = $result['error'] ? 'danger' : 'success'; - - } - return $data; - } - - /** - * Update page status - * @param $id - * @param $status - * @return \Illuminate\Http\JsonResponse - */ - public function postUpdateStatus($id, $status) - { - $data = [ - 'status' => $status - ]; - $result = $this->repository->updatePage($id, $data); - return response()->json($result, $result['response_code']); - } - - /** - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function getCreate() - { - $this->assets - ->addJavascripts([ - 'jquery-ckeditor' - ]); - - $this->setPageTitle('Create page'); - $this->breadcrumbs->addLink('Create page'); - - $this->dis['object'] = $this->repository->getModel(); - $this->dis['currentId'] = 0; - - $oldInputs = old(); - if ($oldInputs) { - foreach ($oldInputs as $key => $row) { - $this->dis['object']->$key = $row; - } - } - - return do_filter('pages.create.get', $this)->viewAdmin('edit'); - } - - /** - * @param $id - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View - */ - public function getEdit($id) - { - $this->assets - ->addJavascripts([ - 'jquery-ckeditor' - ]); - - $item = $this->repository->find($id); - if (!$item) { - $this->flashMessagesHelper - ->addMessages('This page not exists', 'danger') - ->showMessagesOnSession(); - - return redirect()->back(); - } - - $this->setPageTitle('Edit page', $item->title); - $this->breadcrumbs->addLink('Edit page'); - - $this->dis['object'] = $item; - $this->dis['currentId'] = $id; - - return do_filter('pages.edit.get', $this, $id)->viewAdmin('edit'); - } - - /** - * @param $id - * @return \Illuminate\Http\RedirectResponse - */ - public function postEdit(UpdatePageRequest $pageRequest, $id = null) - { - $data = [ - 'page_template' => $this->request->get('page_template', null), - 'status' => $this->request->get('status'), - 'title' => $this->request->get('title'), - 'slug' => ($this->request->get('slug') ? str_slug($this->request->get('slug')) : str_slug($this->request->get('title'))), - 'keywords' => $this->request->get('keywords'), - 'description' => $this->request->get('description'), - 'content' => $this->request->get('content'), - 'thumbnail' => $this->request->get('thumbnail'), - 'updated_by' => $this->loggedInUser->id, - 'order' => $this->request->get('order'), - ]; - - if ((int)$id < 1) { - $result = $this->createPage($data); - } else { - $result = $this->updatePage($id, $data); - } - - do_action('pages.after-edit.post', $id, $result, $this); - - $msgType = $result['error'] ? 'danger' : 'success'; - - $this->flashMessagesHelper - ->addMessages($result['messages'], $msgType) - ->showMessagesOnSession(); - - if($result['error']) { - if(!$id) { - return redirect()->back()->withInput(); - } - } - - if ($this->request->has('_continue_edit')) { - if (!$id) { - if (!$result['error']) { - return redirect()->to(route('admin::pages.edit.get', ['id' => $result['data']->id])); - } - } - return redirect()->back(); - } - - return redirect()->to(route('admin::pages.index.get')); - } - - /** - * @param array $data - * @return array - */ - private function createPage(array $data) - { - if(!$this->userRepository->hasPermission($this->loggedInUser, 'create-pages')) { - return redirect()->to(route('admin::error', ['code' => 403])); - } - - $data['created_by'] = $this->loggedInUser->id; - - return $this->repository->createPage($data); - } - - /** - * @param $id - * @param array $data - * @return array - */ - private function updatePage($id, array $data) - { - return $this->repository->updatePage($id, $data); - } - - /** - * @param $id - * @return \Illuminate\Http\JsonResponse - */ - public function deleteDelete($id) - { - $result = $this->repository->deletePage($id); - - do_action('pages.after-delete.delete', $id, $result, $this); - - return response()->json($result, $result['response_code']); - } -} diff --git a/plugins/pages/src/Http/Requests/UpdatePageRequest.php b/plugins/pages/src/Http/Requests/UpdatePageRequest.php deleted file mode 100644 index d8e90b9..0000000 --- a/plugins/pages/src/Http/Requests/UpdatePageRequest.php +++ /dev/null @@ -1,21 +0,0 @@ - 'required|string|max:255', - 'status' => 'string|required|in:activated,disabled', - 'description' => 'string|max:1000|nullable', - 'content' => 'string|nullable', - 'thumbnail' => 'string|max:255|nullable', - 'keywords' => 'string|max:255|nullable', - 'page_template' => 'string|max:255|nullable', - ]; - - public function authorize() - { - return $this->user()->hasPermission('edit-page'); - } -} diff --git a/plugins/pages/src/Models/Contracts/PageModelContract.php b/plugins/pages/src/Models/Contracts/PageModelContract.php deleted file mode 100644 index 4af783c..0000000 --- a/plugins/pages/src/Models/Contracts/PageModelContract.php +++ /dev/null @@ -1,5 +0,0 @@ -booted(function () { - $this->booted(); - }); - } - - private function booted() - { - $this->registerMenu(); - $this->registerMenuDashboard(); - $this->registerSettings(); - } - - private function registerMenuDashboard() - { - /** - * Register to dashboard menu - */ - \DashboardMenu::registerItem([ - 'id' => 'webed-pages', - 'piority' => 1, - 'parent_id' => null, - 'heading' => 'CMS', - 'title' => 'Pages', - 'font_icon' => 'icon-notebook', - 'link' => route('admin::pages.index.get'), - 'css_class' => null, - ]); - } - - private function registerMenu() - { - /** - * Register menu widget - */ - \MenuManagement::registerWidget('Pages', 'page', function () { - $repository = app(PageContract::class) - ->orderBy('created_at', 'DESC') - ->get(); - $pages = []; - foreach ($repository as $page) { - $pages[] = [ - 'id' => $page->id, - 'title' => $page->title, - ]; - } - return $pages; - }); - - /** - * Register menu link type - */ - \MenuManagement::registerLinkType('page', function ($id) { - $page = app(PageContract::class) - ->where('id', '=', $id) - ->first(); - if (!$page) { - return null; - } - return [ - 'model_title' => $page->title, - 'url' => route('public.get-by-slug.get', ['slug' => $page->slug]), - ]; - }); - } - - private function registerSettings() - { - cms_settings() - ->addSettingField('default_homepage', [ - 'group' => 'theme-options', - 'type' => 'select', - 'piority' => 0, - 'label' => 'Default homepage', - 'helper' => null - ], function () { - /** - * @var PageRepository $pages - */ - $pages = app(PageContract::class); - $pages = $pages->where('status', '=', 'activated') - ->orderBy('order', 'ASC') - ->get(); - - $pagesArr = []; - - foreach ($pages as $page) { - $pagesArr[$page->id] = $page->title; - } - - return [ - 'default_homepage', - $pagesArr, - get_settings('default_homepage'), - ['class' => 'form-control'] - ]; - }); - } -} diff --git a/plugins/pages/src/Providers/InstallModuleServiceProvider.php b/plugins/pages/src/Providers/InstallModuleServiceProvider.php deleted file mode 100644 index e9813b7..0000000 --- a/plugins/pages/src/Providers/InstallModuleServiceProvider.php +++ /dev/null @@ -1,60 +0,0 @@ -booted(function () { - $this->booted(); - }); - } - - private function booted() - { - $this->createSchema(); - - acl_permission() - ->registerPermission('View pages', 'view-pages', $this->module) - ->registerPermission('Create page', 'create-pages', $this->module) - ->registerPermission('Edit page', 'edit-pages', $this->module) - ->registerPermission('Delete pages', 'delete-pages', $this->module); - } - - private function createSchema() - { - Schema::create('pages', function (Blueprint $table) { - $table->engine = 'InnoDB'; - $table->increments('id'); - $table->string('title'); - $table->string('page_template', 255)->nullable(); - $table->string('slug', 255)->nullable()->unique(); - $table->text('description')->nullable(); - $table->text('content')->nullable(); - $table->string('thumbnail', 255)->nullable(); - $table->string('keywords', 255)->nullable(); - $table->enum('status', ['activated', 'disabled'])->default('activated'); - $table->integer('order')->default(0); - $table->integer('created_by')->unsigned()->nullable(); - $table->integer('updated_by')->unsigned()->nullable(); - $table->timestamps(); - $table->foreign('created_by')->references('id')->on('users')->onDelete('set null'); - $table->foreign('updated_by')->references('id')->on('users')->onDelete('set null'); - }); - } -} diff --git a/plugins/pages/src/Providers/ModuleProvider.php b/plugins/pages/src/Providers/ModuleProvider.php deleted file mode 100644 index 7009afb..0000000 --- a/plugins/pages/src/Providers/ModuleProvider.php +++ /dev/null @@ -1,46 +0,0 @@ -loadViewsFrom(__DIR__ . '/../../resources/views', 'webed-pages'); - /*Load translations*/ - $this->loadTranslationsFrom(__DIR__ . '/../../resources/lang', 'webed-pages'); - /*Load migrations*/ - $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations'); - - $this->publishes([ - __DIR__ . '/../../resources/views' => config('view.paths')[0] . '/vendor/webed-pages', - ], 'views'); - $this->publishes([ - __DIR__ . '/../../resources/lang' => base_path('resources/lang/vendor/webed-pages'), - ], 'lang'); - $this->publishes([ - __DIR__ . '/../../config' => base_path('config'), - ], 'config'); - $this->publishes([ - __DIR__ . '/../../database' => base_path('database'), - ], 'migrations'); - } - - /** - * Register the application services. - * - * @return void - */ - public function register() - { - $this->app->register(RouteServiceProvider::class); - $this->app->register(RepositoryServiceProvider::class); - $this->app->register(BootstrapModuleServiceProvider::class); - } -} diff --git a/plugins/pages/src/Providers/RepositoryServiceProvider.php b/plugins/pages/src/Providers/RepositoryServiceProvider.php deleted file mode 100644 index 4ea96d8..0000000 --- a/plugins/pages/src/Providers/RepositoryServiceProvider.php +++ /dev/null @@ -1,28 +0,0 @@ -app->bind(PageContract::class, function () { - $repository = new PageRepository(new EloquentPage); - - if (config('webed-caching.repository.enabled')) { - return new PageRepositoryCacheDecorator($repository); - } - - return $repository; - }); - } -} diff --git a/plugins/pages/src/Providers/RouteServiceProvider.php b/plugins/pages/src/Providers/RouteServiceProvider.php deleted file mode 100644 index 3396b42..0000000 --- a/plugins/pages/src/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,57 +0,0 @@ -group(['namespace' => $this->namespace, 'middleware' => 'web'], function (Router $router) { - - $adminRoute = config('webed.admin_route'); - - $moduleRoute = 'pages'; - - /* - * Admin route - * */ - $router->group(['prefix' => $adminRoute], function (Router $router) use ($adminRoute, $moduleRoute) { - $router->group(['prefix' => $moduleRoute], function (Router $router) use ($adminRoute, $moduleRoute) { - $router->get('/', 'PageController@getIndex') - ->name('admin::pages.index.get') - ->middleware('has-permission:view-pages'); - - $router->post('/', 'PageController@postListing') - ->name('admin::pages.index.post') - ->middleware('has-permission:view-pages'); - - $router->post('update-status/{id}/{status}', 'PageController@postUpdateStatus') - ->name('admin::pages.update-status.post') - ->middleware('has-permission:edit-pages'); - - $router->get('create', 'PageController@getCreate') - ->name('admin::pages.create.get') - ->middleware('has-permission:create-pages'); - - $router->get('edit/{id}', 'PageController@getEdit') - ->name('admin::pages.edit.get') - ->middleware('has-permission:edit-pages'); - - $router->post('edit/{id}', 'PageController@postEdit') - ->name('admin::pages.edit.post') - ->middleware('has-permission:edit-pages'); - - $router->delete('/{id}', 'PageController@deleteDelete') - ->name('admin::pages.delete.delete') - ->middleware('has-permission:delete-pages'); - }); - }); - - }); - } -} diff --git a/plugins/pages/src/Providers/UninstallModuleServiceProvider.php b/plugins/pages/src/Providers/UninstallModuleServiceProvider.php deleted file mode 100644 index 91cc228..0000000 --- a/plugins/pages/src/Providers/UninstallModuleServiceProvider.php +++ /dev/null @@ -1,40 +0,0 @@ -booted(function () { - $this->booted(); - }); - } - - private function booted() - { - /** - * Unset related permissions - */ - acl_permission()->unsetPermissionByModule($this->module); - - $this->dropSchema(); - } - - private function dropSchema() - { - \Schema::dropIfExists('pages'); - } -} diff --git a/plugins/pages/src/Repositories/Contracts/PageContract.php b/plugins/pages/src/Repositories/Contracts/PageContract.php deleted file mode 100644 index d63b661..0000000 --- a/plugins/pages/src/Repositories/Contracts/PageContract.php +++ /dev/null @@ -1,23 +0,0 @@ - 'string|max:255|nullable', - 'title' => 'string|max:255|required', - 'slug' => 'string|max:255|alpha_dash', - 'description' => 'string|max:1000', - 'content' => 'string', - 'thumbnail' => 'string|max:255', - 'keywords' => 'string|max:255', - 'created_by' => 'integer|min:0|required', - 'updated_by' => 'integer|min:0|required', - 'status' => 'string|required|in:activated,disabled', - 'order' => 'integer|min:0', - ]; - - protected $editableFields = [ - 'page_template', - 'title', - 'slug', - 'description', - 'content', - 'thumbnail', - 'keywords', - 'created_by', - 'updated_by', - 'status', - 'order', - ]; - - /** - * @param $data - * @return array - */ - public function createPage($data) - { - return $this->editWithValidate(0, $data, true); - } - - /** - * @param $id - * @param $data - * @return array - */ - public function updatePage($id, $data) - { - $this->unsetEditableFields('created_by'); - return $this->editWithValidate($id, $data, false, true); - } - - /** - * @param int|array $ids - * @return array - */ - public function deletePage($ids) - { - $ids = (array)$ids; - - return $this->delete($ids); - } -} diff --git a/plugins/pages/src/Repositories/PageRepositoryCacheDecorator.php b/plugins/pages/src/Repositories/PageRepositoryCacheDecorator.php deleted file mode 100644 index d4d1859..0000000 --- a/plugins/pages/src/Repositories/PageRepositoryCacheDecorator.php +++ /dev/null @@ -1,37 +0,0 @@ -afterUpdate(__FUNCTION__, func_get_args()); - } - - /** - * @param $id - * @param $data - * @param array|null $dataTranslate - * @return array - */ - public function updatePage($id, $data, $dataTranslate = null) - { - return $this->afterUpdate(__FUNCTION__, func_get_args()); - } - - /** - * @param int|array $id - * @return array - */ - public function deletePage($id) - { - return $this->afterUpdate(__FUNCTION__, func_get_args()); - } -} diff --git a/public/admin/plugins/ckeditor/config.js b/public/admin/plugins/ckeditor/config.js index 710376f..5837332 100644 --- a/public/admin/plugins/ckeditor/config.js +++ b/public/admin/plugins/ckeditor/config.js @@ -9,6 +9,5 @@ CKEDITOR.editorConfig = function( config ) { // config.uiColor = '#AADC6E'; config.filebrowserBrowseUrl = FILE_MANAGER_URL + '?method=ckeditor'; config.extraPlugins = 'codeTag,insertpre'; - //config.allowedContent = true; - config.extraAllowedContent = '*[id];*[class]'; + config.allowedContent = true; }; diff --git a/themes/clean-blog/src/Http/Controllers/PageController.php b/themes/clean-blog/src/Http/Controllers/PageController.php index 56031c5..ed25a5a 100644 --- a/themes/clean-blog/src/Http/Controllers/PageController.php +++ b/themes/clean-blog/src/Http/Controllers/PageController.php @@ -3,10 +3,10 @@ use App\Http\Controllers\AbstractController; use WebEd\Plugins\Blog\Repositories\Contracts\PostRepositoryContract; use WebEd\Plugins\Blog\Repositories\PostRepository; -use WebEd\Plugins\Pages\Models\Contracts\PageModelContract; -use WebEd\Plugins\Pages\Models\EloquentPage; -use WebEd\Plugins\Pages\Repositories\Contracts\PageContract; -use WebEd\Plugins\Pages\Repositories\PageRepository; +use WebEd\Base\Pages\Models\Contracts\PageModelContract; +use WebEd\Base\Pages\Models\EloquentPage; +use WebEd\Base\Pages\Repositories\Contracts\PageContract; +use WebEd\Base\Pages\Repositories\PageRepository; class PageController extends AbstractController { diff --git a/themes/startr/src/Http/Controllers/PageController.php b/themes/startr/src/Http/Controllers/PageController.php index b1736f7..c472076 100644 --- a/themes/startr/src/Http/Controllers/PageController.php +++ b/themes/startr/src/Http/Controllers/PageController.php @@ -1,9 +1,9 @@