From 23d9fcbbcf57dfa70abe1ac1a60bafda0e0efb8a Mon Sep 17 00:00:00 2001 From: noelma Date: Mon, 7 Sep 2020 09:56:15 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20pour=20la=20version=20be?= =?UTF-8?q?ta2=20du=20CMS.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/routes.php | 13 +- Config/service.json | 31 ++-- Controller/Starterkit.php | 172 +++++++++++------- Form/FormStarterkit.php | 36 ++++ Installer.php | 29 ++- Lang/fr/main.json | 11 ++ README.md | 56 +++--- Services/HookConfig.php | 43 ++--- Services/HookUser.php | 25 ++- Views/form-starterkit-edit.php | 2 - Views/page-starterkit-admin.php | 4 - Views/page-starterkit-index.php | 3 - Views/page-starterkit-show.php | 2 - Views/starterkit/content-starterkit-admin.php | 7 + .../content-starterkit-form.php} | 0 Views/starterkit/content-starterkit-index.php | 2 + Views/starterkit/content-starterkit-show.php | 2 + 17 files changed, 260 insertions(+), 178 deletions(-) create mode 100644 Form/FormStarterkit.php create mode 100644 Lang/fr/main.json delete mode 100644 Views/form-starterkit-edit.php delete mode 100644 Views/page-starterkit-admin.php delete mode 100644 Views/page-starterkit-index.php delete mode 100644 Views/page-starterkit-show.php create mode 100644 Views/starterkit/content-starterkit-admin.php rename Views/{form-starterkit-create.php => starterkit/content-starterkit-form.php} (100%) create mode 100644 Views/starterkit/content-starterkit-index.php create mode 100644 Views/starterkit/content-starterkit-show.php diff --git a/Config/routes.php b/Config/routes.php index 4da093d..a0e19d1 100644 --- a/Config/routes.php +++ b/Config/routes.php @@ -5,10 +5,11 @@ R::useNamespace('SoosyzeExtension\Starterkit\Controller'); R::get('starterkit.index', 'starterkit/index', 'Starterkit@index'); +R::get('starterkit.show', 'starterkit/:id', 'Starterkit@show', [':id' => '\d+']); + R::get('starterkit.admin', 'admin/starterkit', 'Starterkit@admin'); -R::get('starterkit.show', 'starterkit/:id', 'Starterkit@show', [':id' => '\d']); -R::get('starterkit.create', 'starterkit/item', 'Starterkit@create'); -R::post('starterkit.store', 'starterkit/item', 'Starterkit@store'); -R::get('starterkit.edit', 'starterkit/:id/edit', 'Starterkit@edit', [':id' => '\d']); -R::post('starterkit.update', 'starterkit/:id/edit', 'Starterkit@update', [':id' => '\d']); -R::post('starterkit.delete', 'starterkit/:id/delete', 'Starterkit@delete', [':id' => '\d']); +R::get('starterkit.create', 'admin/starterkit/create', 'Starterkit@create'); +R::post('starterkit.store', 'admin/starterkit/create', 'Starterkit@store'); +R::get('starterkit.edit', 'admin/starterkit/:id/edit', 'Starterkit@edit', [':id' => '\d+']); +R::post('starterkit.update', 'admin/starterkit/:id/edit', 'Starterkit@update', [':id' => '\d+']); +R::post('starterkit.delete', 'admin/starterkit/:id/delete', 'Starterkit@delete', [':id' => '\d+']); diff --git a/Config/service.json b/Config/service.json index 9f1fec8..2c7a861 100644 --- a/Config/service.json +++ b/Config/service.json @@ -1,37 +1,32 @@ { "starterkit": { "class": "SoosyzeExtension\\Starterkit\\Services\\Starterkit", - "arguments": [ - "@query" - ] + "arguments": ["@query"] + }, + "starterkit.install": { + "class": "SoosyzeExtension\\Starterkit\\Install", + "hooks": { + "install.user": "hookInstallUser", + "install.menu": "hookInstallMenu" + } }, "starterkit.hook.config": { "class": "SoosyzeExtension\\Starterkit\\Services\\HookConfig", - "arguments": [ - "@config" - ], "hooks": { - "config.edit.menu": "menu", - "config.edit.starterkit.form.generate": "form", - "config.update.starterkit.validator": "validator", - "config.update.starterkit.before": "before" + "config.edit.menu": "menu" } }, "starterkit.hook.user": { "class": "SoosyzeExtension\\Starterkit\\Services\\HookUser", "hooks": { "user.permission.module": "hookPermission", + "route.starterkit.index": "hookStarterkitShow", + "route.starterkit.show": "hookStarterkitShow", "route.starterkit.create": "hookStarterkitCreated", "route.starterkit.store": "hookStarterkitCreated", "route.starterkit.edit": "hookStarterkitEdited", - "route.starterkit.update": "hookStarterkitEdited" - } - }, - "starterkit.install": { - "class": "SoosyzeExtension\\Starterkit\\Install", - "hooks": { - "install.user": "hookInstallUser", - "install.menu": "hookInstallMenu" + "route.starterkit.update": "hookStarterkitEdited", + "route.starterkit.delete": "hookStarterkitDelete" } } } \ No newline at end of file diff --git a/Controller/Starterkit.php b/Controller/Starterkit.php index 639bfb3..2111ff7 100644 --- a/Controller/Starterkit.php +++ b/Controller/Starterkit.php @@ -2,10 +2,10 @@ namespace SoosyzeExtension\Starterkit\Controller; -use Soosyze\Components\Form\FormBuilder; +use Psr\Http\Message\ServerRequestInterface; use Soosyze\Components\Http\Redirect; -use Soosyze\Components\Http\ServerRequest; use Soosyze\Components\Validator\Validator; +use SoosyzeExtension\Starterkit\Form\FormStarterkit; class Starterkit extends \Soosyze\Controller { @@ -16,126 +16,166 @@ public function __construct() $this->pathViews = dirname(__DIR__) . '/Views/'; } - public function index(ServerRequest $req) + public function index(ServerRequestInterface $req) { $linkShow = self::router()->getRoute('starterkit.show', [ ':id' => 1 ]); return self::template() ->view('page', [ - 'title_main' => t('Starterkit index') + 'title_main' => t('Starterkit home page') ]) - ->make('page.content', 'page-starterkit-index.php', $this->pathViews, [ + ->make('page.content', 'starterkit/content-starterkit-index.php', $this->pathViews, [ 'link_show' => $linkShow ]); } - public function admin(ServerRequest $req) + public function admin(ServerRequestInterface $req) { - $linkCreate = self::router()->getRoute('starterkit.create'); - $linkEdit = self::router()->getRoute('starterkit.edit', [ ':id' => 1 ]); + $messages = []; + if (isset($_SESSION[ 'messages' ])) { + $messages = $_SESSION[ 'messages' ]; + unset($_SESSION[ 'messages' ]); + } return self::template() ->getTheme('theme_admin') ->view('page', [ - 'title_main' => t('Starterkit admin'), + 'title_main' => t('Administer starterkit'), + 'icon' => '' ]) - ->make('page.content', 'page-starterkit-admin.php', $this->pathViews, [ - 'link_create' => $linkCreate, - 'link_edit' => $linkEdit + ->view('page.messages', $messages) + ->make('page.content', 'starterkit/content-starterkit-admin.php', $this->pathViews, [ + 'link_create' => self::router()->getRoute('starterkit.create'), + 'link_edit' => self::router()->getRoute('starterkit.edit', [ + ':id' => 1 + ]) ]); } - public function show($id, ServerRequest $req) + public function show($id, ServerRequestInterface $req) { return self::template() ->view('page', [ - 'title_main' => 'Starterkit content ' . $id, + 'title_main' => t('Starterkit :id', [ ':id' => $id ]), ]) - ->make('page.content', 'page-starterkit-show.php', $this->pathViews, [ + ->make('page.content', 'starterkit/content-starterkit-show.php', $this->pathViews, [ 'id' => $id ]); } - public function create(ServerRequest $req) + public function create(ServerRequestInterface $req) { - $action = self::router()->getRoute('starterkit.store'); - - $form = (new FormBuilder([ 'method' => 'post', 'action' => $action ])) - ->group('start-config-fieldset', 'fieldset', function ($form) { - $form->legend('start-config-legend', t('Starterkit config')) - ->group('title-group', 'div', function ($form) { - $form->label('title-label', 'Title', [ - 'for' => 'title' - ]) - ->text('title', [ - 'class' => 'form-control', - 'maxlength' => 255, - 'placeholder' => 'Field example', - 'required' => 1 - ]); - }, [ 'class' => 'form-group' ]); - }) - ->token('starterkit_create') - ->submit('submit', t('Save'), [ 'class' => 'btn btn-success' ]); + $values = []; + if (isset($_SESSION[ 'inputs' ])) { + $values = $_SESSION[ 'inputs' ]; + unset($_SESSION[ 'inputs' ]); + } + + $form = (new FormStarterkit([ + 'method' => 'post', + 'action' => self::router()->getRoute('starterkit.store') + ])) + ->setValues($values) + ->makeFields(); + + $messages = []; + if (isset($_SESSION[ 'messages' ])) { + $messages = $_SESSION[ 'messages' ]; + unset($_SESSION[ 'messages' ]); + } return self::template() ->getTheme('theme_admin') ->view('page', [ - 'title_main' => t('Starterkit create') + 'title_main' => t('Add Starterkit'), + 'icon' => '' ]) - ->make('page.content', 'form-starterkit-create.php', $this->pathViews, [ + ->view('page.messages', $messages) + ->make('page.content', 'starterkit/content-starterkit-form.php', $this->pathViews, [ 'form' => $form ]); } - public function store(ServerRequest $req) + public function store(ServerRequestInterface $req) { - $route = self::router()->getRoute('starterkit.admin'); + $validator = $this->setValidator($req); + + if ($validator->isValid()) { + $_SESSION[ 'messages' ][ 'success' ] = [ t('Your starterkit has been saved.') ]; + + return new Redirect(self::router()->getRoute('starterkit.admin')); + } - return new Redirect($route); + $_SESSION[ 'inputs' ] = $validator->getInputs(); + $_SESSION[ 'messages' ][ 'errors' ] = $validator->getKeyErrors(); + + return new Redirect(self::router()->getRoute('starterkit.create')); } - public function edit($id, ServerRequest $req) + public function edit($id, ServerRequestInterface $req) { - $action = self::router()->getRoute('starterkit.edit', [ ':id' => $id ]); - - $form = (new FormBuilder([ 'method' => 'post', 'action' => $action ])) - ->group('title-group', 'div', function ($form) use ($id) { - $form->label('title-label', 'Title', [ - 'for' => 'title' - ]) - ->text('title', [ - 'class' => 'form-control', - 'maxlength' => 255, - 'placeholder' => 'Field example', - 'required' => 1, - 'value' => $id - ]); - }, [ 'class' => 'form-group' ]) - ->token('starterkit_edit') - ->submit('submit', t('Save'), [ 'class' => 'btn btn-success' ]); + $values = [ 'title' => 'Example title' ]; + if (isset($_SESSION[ 'inputs' ])) { + $values = $_SESSION[ 'inputs' ]; + unset($_SESSION[ 'inputs' ]); + } + + $form = (new FormStarterkit([ + 'method' => 'post', + 'action' => self::router()->getRoute('starterkit.edit', [ ':id' => $id ]) + ])) + ->setValues($values) + ->makeFields(); + + $messages = []; + if (isset($_SESSION[ 'messages' ])) { + $messages = $_SESSION[ 'messages' ]; + unset($_SESSION[ 'messages' ]); + } return self::template() ->getTheme('theme_admin') ->view('page', [ - 'title_main' => t('Starterkit edit :id', [ ':id' => $id ]) + 'title_main' => t('Edit :id starterkit', [ ':id' => $id ]), + 'icon' => '' ]) - ->make('page.content', 'form-starterkit-edit.php', $this->pathViews, [ + ->view('page.messages', $messages) + ->make('page.content', 'starterkit/content-starterkit-form.php', $this->pathViews, [ 'form' => $form ]); } - public function update($id, ServerRequest $req) + public function update($id, ServerRequestInterface $req) { - $route = self::router()->getRoute('starterkit.admin'); + $validator = $this->setValidator($req); - return new Redirect($route); + if ($validator->isValid()) { + $_SESSION[ 'messages' ][ 'success' ] = [ t('Your starterkit has been saved.') ]; + + return new Redirect(self::router()->getRoute('starterkit.admin')); + } + + $_SESSION[ 'inputs' ] = $validator->getInputs(); + $_SESSION[ 'messages' ][ 'errors' ] = $validator->getKeyErrors(); + + return new Redirect(self::router()->getRoute('starterkit.edit', [ ':id' => $id ])); } - public function delete($id, ServerRequest $req) + public function delete($id, ServerRequestInterface $req) { - $route = self::router()->getRoute('starterkit.admin'); + return new Redirect(self::router()->getRoute('starterkit.admin')); + } - return new Redirect($route); + private function setValidator(ServerRequestInterface $req) + { + return (new Validator) + ->setRules([ + 'title' => 'required|string|max:255', + 'token_starterkit' => 'token' + ]) + ->setLabel([ + 'title' => t('Title') + ]) + ->setInputs($req->getParsedBody()); } } diff --git a/Form/FormStarterkit.php b/Form/FormStarterkit.php new file mode 100644 index 0000000..b59915e --- /dev/null +++ b/Form/FormStarterkit.php @@ -0,0 +1,36 @@ + '' ]; + + public function setValues(array $values) + { + $this->values = array_merge($this->values, $values); + + return $this; + } + + public function makeFields() + { + return $this->group('starterkit-fieldset', 'fieldset', function ($form) { + $form->legend('starterkit-legend', t('Fields starterkit')) + ->group('title-group', 'div', function ($form) { + $form->label('title-label', 'Title') + ->text('title', [ + 'class' => 'form-control', + 'maxlength' => 255, + 'placeholder' => t('Enter title'), + 'required' => 1, + 'value' => $this->values[ 'title' ] + ]); + }, [ 'class' => 'form-group' ]); + }) + ->token('token_starterkit') + ->submit('submit', t('Save'), [ 'class' => 'btn btn-success' ]); + } +} diff --git a/Installer.php b/Installer.php index d37742f..08e2310 100644 --- a/Installer.php +++ b/Installer.php @@ -5,12 +5,17 @@ use Psr\Container\ContainerInterface; use Queryflatfile\TableBuilder; -class Installer implements \SoosyzeCore\System\Migration +class Installer extends \SoosyzeCore\System\Migration { public function getDir() { return __DIR__ . '/composer.json'; } + + public function boot() + { + $this->loadTranslation('fr', __DIR__ . '/Lang/fr/main.json'); + } public function install(ContainerInterface $ci) { @@ -58,8 +63,8 @@ public function hookInstallMenu(ContainerInterface $ci) 'menu-admin', 50, -1 ]) ->values([ - 'starterkit.index', null, 'Starterkit', 'starterkit/index', 'menu-admin', - 50, 1 + 'starterkit.index', null, 'Starterkit', 'starterkit/index', 'menu-main', + 50, -1 ]) ->execute(); } @@ -70,15 +75,9 @@ public function hookInstallUser(ContainerInterface $ci) if ($ci->module()->has('User')) { $ci->query() ->insertInto('role_permission', [ 'role_id', 'permission_id' ]) - ->values([ 3, 'starterkit.index' ]) ->values([ 3, 'starterkit.admin' ]) ->values([ 3, 'starterkit.show' ]) - ->values([ 3, 'starterkit.created' ]) - ->values([ 3, 'starterkit.edited' ]) - ->values([ 3, 'starterkit.delete' ]) - ->values([ 2, 'starterkit.index' ]) ->values([ 2, 'starterkit.show' ]) - ->values([ 1, 'starterkit.index' ]) ->values([ 1, 'starterkit.show' ]) ->execute(); } @@ -100,12 +99,12 @@ public function hookUninstall(ContainerInterface $ci) public function hookUninstallMenu(ContainerInterface $ci) { if ($ci->module()->has('Menu')) { - $ci->query() - ->from('menu_link') - ->delete() - ->where('link', 'admin/starterkit') - ->orWhere('link', 'like', 'starterkit/%') - ->execute(); + $ci->menu()->deleteLinks(function () use ($ci) { + return $ci->query() + ->from('menu_link') + ->where('key', 'like', 'starterkit%') + ->fetchAll(); + }); } } diff --git a/Lang/fr/main.json b/Lang/fr/main.json new file mode 100644 index 0000000..8b71cef --- /dev/null +++ b/Lang/fr/main.json @@ -0,0 +1,11 @@ +{ + "Sarterkit": "Kit de démarrage", + "To start your Soosyze module with a code base (CRUD, links in menus, user rights, configuration page).": "", + "Administer starterkit": "Administrer le kit de démarrage", + "Demonstration of the add form": "Démonstration du formulaire d'ajout", + "Demonstration of the edit form": "Démonstration du formulaire d'édition", + "Starterkit home page": "Page d'accueil de Starterkit", + "View content :id": "Voir le contenu :id", + "Starterkit Content Page :id": "Page du contenu :id du Starterkit", + "Your starterkit has been saved.": "Votre kit de démarrage a été enregistré." +} diff --git a/README.md b/README.md index a3c92bd..50f0e6f 100644 --- a/README.md +++ b/README.md @@ -20,16 +20,16 @@ Pour démarrer un module Soosyze avec une base de code standard. Il s'agit d'une base de travail CRUD (Create/Read/Update/Delete). Il est conseillé, mais pas obligatoire de suivre les mêmes routes et méthodes. -| Route | Méthode HTTP* | Contrôleurs@methode | Fonction | -|-------------------------|---------------|---------------------|---------------------------------------------------| -| `starterkit/index` | GET | `Starterkit@index` | Page d'accueil du module. | -| `admin/starterkit` | GET | `Starterkit@admin` | Page d'administration du module. | -| `starterkit/:id` | GET | `Starterkit@show` | Page de contenu. | -| `starterkit/item` | GET | `Starterkit@create` | Formulaire de création du module. | -| `starterkit/item` | POST | `Starterkit@store` | Fonction de validation et d'ajout du module. | -| `starterkit/:id/edit` | GET | `Starterkit@edit` | Formulaire d'édition de votre module. | -| `starterkit/:id/edit` | POST | `Starterkit@update` | Fonction de validation et modification du module. | -| `starterkit/:id/delete` | POST | `Starterkit@delete` | Fonction de validation et suppression du module. | +| Route | Méthode HTTP* | Contrôleurs@methode | Fonction | +|-------------------------------|---------------|---------------------|---------------------------------------------------| +| `starterkit/index` | GET | `Starterkit@index` | Page d'accueil du module. | +| `starterkit/:id` | GET | `Starterkit@show` | Page de contenu. | +| `admin/starterkit` | GET | `Starterkit@admin` | Page d'administration du module. | +| `admin/starterkit/item` | GET | `Starterkit@create` | Formulaire de création du module. | +| `admin/starterkit/item` | POST | `Starterkit@store` | Fonction de validation et d'ajout du module. | +| `admin/starterkit/:id/edit` | GET | `Starterkit@edit` | Formulaire d'édition de votre module. | +| `admin/starterkit/:id/edit` | POST | `Starterkit@update` | Fonction de validation et modification du module. | +| `admin/starterkit/:id/delete` | POST | `Starterkit@delete` | Fonction de validation et suppression du module. | *Vous pouvez utiliser les méthodes HTTP que vous souhaitez, mais seules les actions GET et POST sont fonctionnelles avec les formulaires PHP. @@ -45,16 +45,13 @@ Il s'agit d'une base de travail CRUD (Create/Read/Update/Delete). Il est conseil La classe d'installateur est un service pour créer vos tables en base et insérer vos données. Il implémente le hook `install.user` pour les permissions utilisateurs. -| Nom des permissions | Utilisateurs autorisés | -|-----------------------|-----------------------------------------------------------| -| `starterkit.index ` | Utilisateurs non connectés, connectés et administrateurs | -| `starterkit.admin` | Administrateurs | -| `starterkit.show` | Utilisateurs non connectés, connectés et administrateurs | -| `starterkit.create` | Administrateurs | -| `starterkit.store` | Administrateurs | -| `starterkit.edit` | Administrateurs | -| `starterkit.update` | Administrateurs | -| `starterkit.delete` | Administrateurs | +| Nom des permissions | Utilisateurs autorisés | +|-----------------------|----------------------------------------------------------| +| `starterkit.index ` | Utilisateurs non connectés, connectés et administrateurs | +| `starterkit.admin` | Administrateurs | +| `starterkit.created` | **Supplanté par la permission `starterkit.admin`** | +| `starterkit.edited` | **Supplanté par la permission `starterkit.admin`** | +| `starterkit.deleted` | **Supplanté par la permission `starterkit.admin`** | Il implémente également le hook `install.menu` pour créer un lien dans le menu principal et d'administration. @@ -62,11 +59,10 @@ Il implémente également le hook `install.menu` pour créer un lien dans le men Le module est fournit avec 4 vues de base : -* `form-starterkit-create.php` pour le formulaire de création, -* `form-starterkit-edit.php` pour le formulaire d'édition, -* `page-starterkit-admin.php` pour votre page d'administration, -* `page-starterkit-index.php` pour votre page d'accueil, -* `page-starterkit-show.php` pour voir du contenu. +* `content-starterkit-form.php` pour le formulaire de création et d'édition, +* `content-starterkit-admin.php` pour votre page d'administration, +* `content-starterkit-index.php` pour votre page d'accueil, +* `content-starterkit-show.php` pour voir du contenu. # Requirements @@ -74,11 +70,11 @@ Starterkit module supporte jusqu'à présent toutes les versions de Soosyze CMS. ## Version PHP -| Version PHP | Starterkit module 1.x | -|----------------------------|-----------------------| -| <= 5.3 | ✗ Non supporté | -| 5.4 / 5.5 / 5.6 | ✓ Supporté | -| 7.0 / 7.1 / 7.2 / 7.3.0RC3 | ✓ Supporté | +| Version PHP | Starterkit module 1.x | +|-----------------------------|-----------------------| +| <= 5.3 | ✗ Non supporté | +| 5.4 / 5.5 / 5.6 | ✓ Supporté | +| 7.0 / 7.1 / 7.2 / 7.3 / 7.4 | ✓ Supporté | # Installation diff --git a/Services/HookConfig.php b/Services/HookConfig.php index 077f392..8aec687 100644 --- a/Services/HookConfig.php +++ b/Services/HookConfig.php @@ -2,44 +2,31 @@ namespace SoosyzeExtension\Starterkit\Services; -use Soosyze\Components\Form\FormBuilder; -use Soosyze\Components\Validator\Validator; - -class HookConfig +class HookConfig implements \SoosyzeCore\Config\Services\ConfigInterface { - /** - * @var \Soosyze\Config - */ - protected $config; - - public function __construct($config) - { - $this->config = $config; - } - - public function menu(array &$menu) + public function menu(&$menu) { - $menu['starterkit'] = [ + $menu[ 'starterkit' ] = [ 'title_link' => 'Starterkit' ]; } - public function form(FormBuilder &$form, array $data) + public function form(&$form, $data, $req) { return $form->group('start-fieldset', 'fieldset', function ($form) use ($data) { - $form->legend('start-legend', t('Starterkit config')) + $form->legend('start-legend', t('Settings')) ->group('start_check-group', 'div', function ($form) use ($data) { $form->checkbox('start_check', [ 'checked' => $data[ 'start_check' ] ]) - ->label('start_check-label', ' ' . t('Start check.'), [ + ->label('start_check-label', ' ' . t('Start check'), [ 'for' => 'start_check' ]); }, [ 'class' => 'form-group' ]) ->group('start_text-group', 'div', function ($form) use ($data) { $form->label('start_text-label', t('Start text')) ->text('start_text', [ - 'class' => 'form-control', - 'required' => 1, - 'value' => $data[ 'start_text' ] + 'class' => 'form-control', + 'required' => 1, + 'value' => $data[ 'start_text' ] ]); }, [ 'class' => 'form-group' ]); }) @@ -47,7 +34,7 @@ public function form(FormBuilder &$form, array $data) ->submit('submit', t('Save'), [ 'class' => 'btn btn-success' ]); } - public function validator(Validator &$validator) + public function validator(&$validator) { $validator->setRules([ 'start_check' => '!required|bool', @@ -56,11 +43,19 @@ public function validator(Validator &$validator) ]); } - public function before(Validator &$validator, array &$data) + public function before(&$validator, &$data, $id) { $data = [ 'start_check' => $validator->getInput('start_check'), 'start_text' => $validator->getInput('start_text') ]; } + + public function after(&$validator, $data, $id) + { + } + + public function files(&$inputsFile) + { + } } diff --git a/Services/HookUser.php b/Services/HookUser.php index d48e0cc..491e195 100644 --- a/Services/HookUser.php +++ b/Services/HookUser.php @@ -7,22 +7,31 @@ class HookUser public function hookPermission(&$permission) { $permission[ 'Starterkit' ] = [ - 'starterkit.index' => t('View'), - 'starterkit.admin' => t('Administrator'), - 'starterkit.show' => t('View content'), - 'starterkit.created' => t('Add content'), - 'starterkit.edited' => t('Edit'), - 'starterkit.delete' => t('Delete'), + 'starterkit.admin' => t('Administer starterkit'), + 'starterkit.show' => t('View starterkit content'), + 'starterkit.created' => t('Add starterkit content'), + 'starterkit.edited' => t('Edit starterkit content'), + 'starterkit.deleted' => t('Delete starterkit content'), ]; } + public function hookStarterkitShow() + { + return [ 'starterkit.admin', 'starterkit.show' ]; + } + public function hookStarterkitCreated($req) { - return 'starterkit.created'; + return [ 'starterkit.admin', 'starterkit.created' ]; } public function hookStarterkitEdited($id, $req) { - return 'starterkit.edited'; + return [ 'starterkit.admin', 'starterkit.edited' ]; + } + + public function hookStarterkitDelete($id, $req) + { + return [ 'starterkit.admin', 'starterkit.deleted' ]; } } diff --git a/Views/form-starterkit-edit.php b/Views/form-starterkit-edit.php deleted file mode 100644 index 52d529e..0000000 --- a/Views/form-starterkit-edit.php +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Views/page-starterkit-admin.php b/Views/page-starterkit-admin.php deleted file mode 100644 index 0e5965b..0000000 --- a/Views/page-starterkit-admin.php +++ /dev/null @@ -1,4 +0,0 @@ - -

-

-

\ No newline at end of file diff --git a/Views/page-starterkit-index.php b/Views/page-starterkit-index.php deleted file mode 100644 index d349cef..0000000 --- a/Views/page-starterkit-index.php +++ /dev/null @@ -1,3 +0,0 @@ - -

-

\ No newline at end of file diff --git a/Views/page-starterkit-show.php b/Views/page-starterkit-show.php deleted file mode 100644 index 84b2446..0000000 --- a/Views/page-starterkit-show.php +++ /dev/null @@ -1,2 +0,0 @@ - -

$id]); ?>

\ No newline at end of file diff --git a/Views/starterkit/content-starterkit-admin.php b/Views/starterkit/content-starterkit-admin.php new file mode 100644 index 0000000..bb03eb7 --- /dev/null +++ b/Views/starterkit/content-starterkit-admin.php @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Views/form-starterkit-create.php b/Views/starterkit/content-starterkit-form.php similarity index 100% rename from Views/form-starterkit-create.php rename to Views/starterkit/content-starterkit-form.php diff --git a/Views/starterkit/content-starterkit-index.php b/Views/starterkit/content-starterkit-index.php new file mode 100644 index 0000000..3b46258 --- /dev/null +++ b/Views/starterkit/content-starterkit-index.php @@ -0,0 +1,2 @@ + +

1 ]); ?>

\ No newline at end of file diff --git a/Views/starterkit/content-starterkit-show.php b/Views/starterkit/content-starterkit-show.php new file mode 100644 index 0000000..701f806 --- /dev/null +++ b/Views/starterkit/content-starterkit-show.php @@ -0,0 +1,2 @@ + +

$id ]); ?>

\ No newline at end of file