diff --git a/Admin/Installer.php b/Admin/Installer.php index 7ac82a1..bdcad23 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -21,7 +21,6 @@ use phpOMS\Message\Http\HttpResponse; use phpOMS\Module\InstallerAbstract; use phpOMS\Module\ModuleInfo; use phpOMS\System\File\PathException; -use phpOMS\Uri\HttpUri; /** * Installer class. @@ -136,7 +135,7 @@ final class Installer extends InstallerAbstract $module = $app->moduleManager->get('Editor', 'ApiDocType'); $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('name', $data['name'] ?? ''); @@ -161,7 +160,7 @@ final class Installer extends InstallerAbstract } $response = new HttpResponse(); - $request = new HttpRequest(new HttpUri('')); + $request = new HttpRequest(); $request->header->account = 1; $request->setData('title', $l11n); diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 716a59f..b3db872 100755 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -18,7 +18,7 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ - '^.*/editor/create.*$' => [ + '^.*/editor/create(\?.*$|$)' => [ [ 'dest' => '\Modules\Editor\Controller\BackendController:setUpEditorEditor', 'verb' => RouteVerb::GET, @@ -38,7 +38,7 @@ return [ ], ], ], - '^.*/editor/list.*$' => [ + '^.*/editor/list(\?.*$|$)' => [ [ 'dest' => '\Modules\Editor\Controller\BackendController:viewEditorList', 'verb' => RouteVerb::GET, @@ -49,9 +49,9 @@ return [ ], ], ], - '^.*/editor/single.*$' => [ + '^.*/editor/view(\?.*$|$)' => [ [ - 'dest' => '\Modules\Editor\Controller\BackendController:viewEditorSingle', + 'dest' => '\Modules\Editor\Controller\BackendController:viewEditorView', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::NAME, @@ -60,7 +60,7 @@ return [ ], ], ], - '^.*/editor/edit.*$' => [ + '^.*/editor/edit(\?.*$|$)' => [ [ 'dest' => '\Modules\Editor\Controller\BackendController:viewEditorEdit', 'verb' => RouteVerb::GET, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f4653b..88c5d9c 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,16 @@ -# Development - ## Development environment - The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md). +The setup and configuration of the development environment is in the hands of every developer themselves. However, it is recommended to follow the setup instructions in the [Developer-Guide](https://github.com/Karaka-Management/Developer-Guide/blob/develop/general/setup.md). ## Code of conduct -Every organization member and contributor to the organization must follow the [code of conduct](../Policies & Guidelines/Code of conduct.md). +Every organization member and contributor to the organization must follow the [Code of Conduct](../Policies%20&%20Guidelines/Code%20of%20Conduct.md). + +## Becoming a contributor + +For public repositories you can immediately start by creating forks and pull requests. For private repositories which are necessary to setup the complete developer environment, feel free to request access. Please not that we may not immediately give you access to private repositories and instead will give you smaller tasks regarding public repositories. Please contact info@jingga.app for more details. (**R1**) + +For all contributions our [Contributor License Agreement "CLA"](https://github.com/Karaka-Management/Organization-Guide/blob/master/Processes/HR/Hiring/Individual%20Contributor%20License%20Agreement.md) comes into effect. (**R2**) ## Code changes @@ -14,58 +18,106 @@ Every organization member and contributor to the organization must follow the [c Generally, the development philosophy is result orientated. This means that anyone can propose tasks, pick up existing tasks or right away implement their code changes. However, implementing code changes without consulting with a senior developer in advance has a much higher risk of code changes not getting admitted. The easiest way to discuss a code change idea in advance are the github [issues](https://github.com/Karaka-Management/Karaka/issues) or [discussions](https://github.com/Karaka-Management/Karaka/discussions). -Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty. +Developers are encouraged to pick open tasks with high priorities according to their own skill level. Senior developers may directly assign tasks to developers based on their importance. New developers may find it easier to start with a task that has a low priority as they often also have a lower difficulty. -Open tasks can be found in the project overview: [PROJECT.md](https://github.com/orgs/Karaka-Management/projects/10) +Open tasks can be found in the project overview: [Todos](https://github.com/orgs/Karaka-Management/projects/10) -Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task. +Tasks currently in development are prefixed in the priority column with an asterisk `*` and a name tag in the task description of the developer who is working on the task. -The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis. +The open tasks are reviewed once a month by a senior developer. The senior developer updates the project overview if necessary and requests feedback regarding development status of important tasks under development. During this process important tasks may also get directly assigned to developers. This review is performed on a judgmental bases of the senior basis. -### Code style +### Quality -Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. +#### Code style -In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be changes in the programming language, special cases which cannot, are difficult or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. +Code changes must follow the [style guidelines](https://github.com/Karaka-Management/Developer-Guide/tree/develop/standards) (**R3**). Additionally, the automatic code style inspection tools must return no errors, failures or warnings. Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R4**) -Automated checks which are run during the review process: +In rare cases errors, failures or warnings during the automatic inspection are acceptable. Reasons can be for example special cases which are difficult automatize or must be individually configured in the inspection settings. If this is the case for a code change and if inspection configuration changes are necessary are decided by the senior developer performing the code review. (**R5**) + +Automated checks which are run during the review process (**R4**): ```sh -php ./vendor/bin/phpcs --severity=1 ./ --standard="Build/Config/phpcs.xml" +php ./vendor/bin/phpcs ./ --standard="Build/Config/phpcs.xml" +php ./vendor/bin/php-cs-fixer fix ./ --config=Build/Config/.php-cs-fixer.php --allow-risky=yes +php ./vendor/bin/phpcbf --standard=Build/Config/phpcs.xml ./ +php ./vendor/bin/rector process --dry-run --config Build/Config/rector.php ./ npx eslint ./ -c ./Build/Config/.eslintrc.json ``` -### Tests +#### Tests -Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md). Developers should check if the code changes comply with the inspection guidelines before submitting them. +Code changes must follow the inspection guidelines (i.e. code coverage) mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) (**R6**). Developers should test their changes with inspection tools and configurations mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) in advance before submitting them for review. (**R7**) -In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. +In rare cases it might be not possible to follow the inspection guidelines. In such cases the senior developer performing the code review may decide if the code change still gets accepted. (**R8**) -Automated tests which are run during the review process: +Automated tests which are run during the review process (**R7**): ```sh php ./vendor/bin/phpunit -c tests/PHPUnit/phpunit_default.xml -php ./vendor/bin/phpstan analyse --autoload-file=phpOMS/Autoloader.php -l 9 -c Build/Config/phpstan.neon ./ +php ./vendor/bin/phpstan analyse --no-progress -l 9 -c Build/Config/phpstan.neon ./ npx jasmine-node ./ ./cOMS/tests/test.sh ``` -Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. +Additional inspections which are run but might be ignored during the review depending on the use case are mentioned in the [inspection documentation](https://github.com/Karaka-Management/Developer-Guide/blob/develop/quality/inspections.md) as other checks. (**R7**) -### Demo +#### Performance -Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. +Developers should occasionaly check performance statistics. At this point no target metrics are defined. -### Code review +Since the primary application is a web based application a similar tool as the Google lighthouse tool can be used to inspect the application for best practicies which can significantly improve the application performance. The sitespeed.io tool shows potential performance improvements and slow pages. With the php trace and profiler enabled in the `php.ini` file the VM automatically generates profiling and trace reports for every web request. These can be found in the webgrind logs directory and inspected in webgrind and dropped into the trace visualizer for a flame chart visualization. With mysqldumpslow you can inspect slow sql queries which may need optimization. + +1. Automatic trace and benchmark generation with every web request in `/var/www/html/webgrind/Logs` +2. Webgrind view `http://vm_ip:82` +3. Trace visualization `http://vm_ip:81` + 1. Download the latest trace from `http://vm_ip:82/Logs` + 2. Drag and drop that downloaded `*.xt` file in the trace visualizer +4. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed` +5. Slow query inspection. + +```sh +mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log +mysqldumpslow -t 10 -s l /var/log/mysql/mysql-slow.log +``` + +#### Code review In addition to the automatic code review performed by the various inspection tools such as (phpcs, phpstan, phpunit, eslint and custom scripts) a senior developer must check the proposed code change before it is merged with the respective `develop` branch. Only upon the approval by the reviewer a code change requests gets merged as no other developers have permission in the software to make such code merges. In case a code change request is not approved the reviewer states the reason for the decision, this may include some tips and requests which will allow the contributor to make improvements so that the code change may get approved. -If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. +If the code reviewer only finds minor issues with the proposed code change the reviewer may make small changes to the proposed code change and inform the contributor to speed up the implementation process. Code reviewers are encouraged to do this with new contributors to avoid long iteration processes and to not discourage new developers. However, communication is key and severe issues with code change requests or if the contributor already made multiple code change requests in the past the reviewer should not implement the improvements by himself and rather decline the code change requests with his reasoning. (**R5**+**R8**) + +#### Demo + +Some code changes may also require changes or extensions in the demo setup scripts. The demo setup script try to simulate a real world use case by generating and modifying mostly random data. This is also a good way to setup and “manually” test the code changes in a larger picture. The demo setup script can be found in the [demoSetup](https://github.com/Karaka-Management/demoSetup) repository. The demo setup script takes a long time due to the large amount of user input simulated data which is generated. Therefore it is recommended to run this only sporadically. (**R9**) + +```sh +sudo -u www-data php -dxdebug.remote_enable=1 -dxdebug.start_with_request=yes -dxdebug.mode=coverage,develop,debug demoSetup/setup.php +``` + +#### Documentation + +Occasionally new code or code changes also require new documentation or documentation changes. Developers should make sure that the new code is also reflected in the existing documentation ([Developer-Guide](), [User-Guide]() and/or module documentation) or if additional documentation is necessary. + +#### Improvements, features, bugs + +If a developer (or employee in general) has an idea for an improvement, feature or finds a potential bug it should be reported at https://github.com/Karaka-Management/Karaka/issues. A senior developer has to check these issues and decide how to proceed with them. The decision how to proceed with the issue must be explained by the senior developer as a response in the issue. Possible steps are: + +* Accept the issue and put the task into the [Todos](https://github.com/orgs/Karaka-Management/projects/10) +* Dismiss the issue with an explanation ### Release flow +In case SCSS/CSS or JS files got changed they must get re-built locally before comitting the code change: + +```sh +npx esbuild Web/Backend/js/backend.js --bundle --outfile=Install/Application/Backend/js/backend.min.js --minify +scss cssOMS/styles.scss > cssOMS/styles.css +``` + +For JS you may also use the shorthand command `npm run build`. + Code changes must be performed in a new branch. A new branch can be created with: ```sh @@ -75,8 +127,70 @@ git checkout -b new-branch-name The name of the branch can be chosen freely however it is recommended to follow the following branch naming conventions: * `feature-*` for feature implementations +* `hotfix-*` for security related fixes/improvements * `bug-*` for bug fixes * `security-*` for security related fixes/improvements -* `general-*` for general improvements (i.e. code documentation improvements, code style improvements) +* `general-*` for general improvements (i.e. documentation, code style & performance improvements) -The senior developer who performs the code review merges the change request into the `develop` branch upon approval. \ No newline at end of file +```mermaid +%%{init: { 'gitGraph': {'mainBranchName': 'master'}} }%% + gitGraph + commit + branch hotfix-xxx + commit + checkout master + branch develop + checkout master + merge hotfix-xxx + checkout develop + branch bug-xxx + commit + commit + checkout hotfix-xxx + commit + checkout master + merge hotfix-xxx + checkout develop + merge bug-xxx + commit + checkout develop + branch feature-xxx + commit + commit + commit + checkout develop + merge feature-xxx + checkout master + merge develop + checkout develop + branch general-xxx + commit + checkout develop + merge general-xxx + branch security-xxx + commit + commit + checkout develop + merge security-xxx + checkout master + merge develop + +``` + +The senior developer who performs the code review merges the change request into the `develop` branch after their successful code review. Unsuccessful reviews lead to change requests by the original developer, other developers who can make the requested changes, changes by the senior developer who performed the review, or dismissal of the changed code. (**R10**) + +## Approved dependencies + +### Customer dependencies + +Developers may only rely on the dependencies defined in [Approved Customer Software]() when developing a solution. If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. (**R11**) + +### Developer dependencies + +Developers may only rely on the dependencies defined in [IT Equipment & Software](). If new software should be added to this list or a different version is required developers should make a request with their team leader/head of department who forwards this requests if appropriate to the CTO and explain the reasoning for the different dependency needs. The CTO can decide if the dependency will be accepted. Changing the package managers such as `composer.json` or `package.json` is not allowed by anyone else than the CTO. (**R12**) + +## Other related documents + +* [Confidentiality Policy](../Policies%20&%20Guidelines/Confidentiality%20Policy.md) +* [Organization Activity Policy](../Policies%20&%20Guidelines/Organization%20Activity%20Policy.md) +* [Tutorials](./Development/Tutorials) \ No newline at end of file diff --git a/Controller/ApiController.php b/Controller/ApiController.php index af6dca4..9659e70 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -28,7 +28,6 @@ use Modules\Media\Models\NullMedia; use Modules\Media\Models\PathSettings; use Modules\Media\Models\Reference; use Modules\Media\Models\ReferenceMapper; -use Modules\Tag\Models\NullTag; use phpOMS\Account\PermissionType; use phpOMS\Asset\AssetType; use phpOMS\Message\Http\HttpResponse; @@ -261,26 +260,8 @@ final class ApiController extends Controller $doc->version = $request->getDataString('version') ?? ''; $doc->setVirtualPath($request->getDataString('virtualpath') ?? '/'); - if (!empty($tags = $request->getDataJson('tags'))) { - foreach ($tags as $tag) { - if (!isset($tag['id'])) { - $request->setData('title', $tag['title'], true); - $request->setData('color', $tag['color'], true); - $request->setData('icon', $tag['icon'] ?? null, true); - $request->setData('language', $tag['language'], true); - - $internalResponse = new HttpResponse(); - $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse); - - if (!\is_array($data = $internalResponse->getDataArray($request->uri->__toString()))) { - continue; - } - - $doc->addTag($data['response']); - } else { - $doc->addTag(new NullTag((int) $tag['id'])); - } - } + if ($request->hasData('tags')) { + $doc->tags = $this->app->moduleManager->get('Tag', 'Api')->createTagsFromRequest($request); } return $doc; @@ -503,7 +484,7 @@ final class ApiController extends Controller { /** @var \Modules\Editor\Models\EditorDoc $doc */ $doc = EditorDocMapper::get() - ->with('media') + ->with('files') ->where('id', (int) $request->getData('id')) ->execute(); @@ -635,7 +616,7 @@ final class ApiController extends Controller /** * Routing end-point for application behavior. * - * @param EditorDoc $doc Media + * @param EditorDoc $doc Media * @param \phpOMS\Message\Http\HttpRequest $request Request * @param HttpResponse $response Response * diff --git a/Controller/ApiDocTypeController.php b/Controller/ApiDocTypeController.php index 3960bc9..91ee000 100644 --- a/Controller/ApiDocTypeController.php +++ b/Controller/ApiDocTypeController.php @@ -73,7 +73,10 @@ final class ApiDocTypeController extends Controller private function createEditorDocTypeFromRequest(RequestAbstract $request) : BaseStringL11nType { $contractType = new BaseStringL11nType(); - $contractType->setL11n($request->getDataString('title') ?? '', $request->getDataString('language') ?? ISO639x1Enum::_EN); + $contractType->setL11n( + $request->getDataString('title') ?? '', + ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? ISO639x1Enum::_EN + ); $contractType->title = $request->getDataString('name') ?? ''; return $contractType; @@ -137,12 +140,10 @@ final class ApiDocTypeController extends Controller */ private function createEditorDocTypeL11nFromRequest(RequestAbstract $request) : BaseStringL11n { - $contractTypeL11n = new BaseStringL11n(); - $contractTypeL11n->ref = $request->getDataInt('type') ?? 0; - $contractTypeL11n->setLanguage( - $request->getDataString('language') ?? $request->header->l11n->language - ); - $contractTypeL11n->content = $request->getDataString('title') ?? ''; + $contractTypeL11n = new BaseStringL11n(); + $contractTypeL11n->ref = $request->getDataInt('type') ?? 0; + $contractTypeL11n->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $request->header->l11n->language; + $contractTypeL11n->content = $request->getDataString('title') ?? ''; return $contractTypeL11n; } @@ -327,10 +328,8 @@ final class ApiDocTypeController extends Controller */ public function updateEditorDocTypeL11nFromRequest(RequestAbstract $request, BaseStringL11n $new) : BaseStringL11n { - $new->setLanguage( - $request->getDataString('language') ?? $new->language - ); - $new->content = $request->getDataString('title') ?? $new->content; + $new->language = ISO639x1Enum::tryFromValue($request->getDataString('language')) ?? $new->language; + $new->content = $request->getDataString('title') ?? $new->content; return $new; } diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 2f1949d..0537487 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -129,7 +129,7 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewEditorSingle(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface + public function viewEditorView(RequestAbstract $request, ResponseAbstract $response, array $data = []) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); @@ -137,7 +137,7 @@ final class BackendController extends Controller $doc = EditorDocMapper::get() ->with('tags') ->with('tags/title') - ->with('media') + ->with('files') ->where('id', (int) $request->getData('id')) ->where('tags/title/language', $response->header->l11n->language) ->execute(); @@ -153,7 +153,7 @@ final class BackendController extends Controller return $view; } - $view->setTemplate('/Modules/Editor/Theme/Backend/editor-single'); + $view->setTemplate('/Modules/Editor/Theme/Backend/editor-view'); $view->data['nav'] = $this->app->moduleManager->get('Navigation')->createNavigationMid(1005301001, $request, $response); $view->data['doc'] = $doc; diff --git a/LICENSE.txt b/LICENSE.txt index 18d430e..4ba0161 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -27,7 +27,7 @@ Version 2.0 Subject to the terms and conditions of this License, each Contributor grants to You after purchase a perpetual, worldwide, non-exclusive, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform the Work and such Derivative Works in Source or Object form. You are not allowed to sublicense, reproduce, or distribute the Work and such Derivative Works in Source or Object form. -3. Redistribution. +3. Redistribution You may not reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form. diff --git a/Models/EditorDoc.php b/Models/EditorDoc.php index 1b01086..d16e193 100755 --- a/Models/EditorDoc.php +++ b/Models/EditorDoc.php @@ -16,7 +16,6 @@ namespace Modules\Editor\Models; use Modules\Admin\Models\Account; use Modules\Admin\Models\NullAccount; -use Modules\Media\Models\Media; use Modules\Tag\Models\Tag; use phpOMS\Localization\BaseStringL11nType; @@ -118,14 +117,6 @@ class EditorDoc implements \JsonSerializable */ public array $tags = []; - /** - * Media files - * - * @var Media[] - * @since 1.0.0 - */ - public array $media = []; - /** * Is versioned * @@ -145,18 +136,6 @@ class EditorDoc implements \JsonSerializable $this->createdAt = new \DateTimeImmutable('now'); } - /** - * Get the id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * Get the path * @@ -183,58 +162,6 @@ class EditorDoc implements \JsonSerializable $this->virtualPath = $path; } - /** - * Get tags - * - * @return array - * - * @since 1.0.0 - */ - public function getTags() : array - { - return $this->tags; - } - - /** - * Add tag - * - * @param Tag $tag Tag - * - * @return void - * - * @since 1.0.0 - */ - public function addTag(Tag $tag) : void - { - $this->tags[] = $tag; - } - - /** - * Get all media - * - * @return Media[] - * - * @since 1.0.0 - */ - public function getMedia() : array - { - return $this->media; - } - - /** - * Add media - * - * @param Media $media Media to add - * - * @return void - * - * @since 1.0.0 - */ - public function addMedia(Media $media) : void - { - $this->media[] = $media; - } - /** * {@inheritdoc} */ @@ -265,4 +192,6 @@ class EditorDoc implements \JsonSerializable { return $this->toArray(); } + + use \Modules\Media\Models\MediaListTrait; } diff --git a/Models/EditorDocHistory.php b/Models/EditorDocHistory.php index 3fe0ead..4419db6 100755 --- a/Models/EditorDocHistory.php +++ b/Models/EditorDocHistory.php @@ -124,18 +124,6 @@ class EditorDocHistory implements \JsonSerializable return $hist; } - /** - * Get the id - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - /** * {@inheritdoc} */ diff --git a/Models/EditorDocHistoryMapper.php b/Models/EditorDocHistoryMapper.php index fe4df11..52615de 100755 --- a/Models/EditorDocHistoryMapper.php +++ b/Models/EditorDocHistoryMapper.php @@ -37,13 +37,13 @@ final class EditorDocHistoryMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'editor_doc_versioned_id' => ['name' => 'editor_doc_versioned_id', 'type' => 'int', 'internal' => 'id'], - 'editor_doc_versioned_version' => ['name' => 'editor_doc_versioned_version', 'type' => 'string', 'internal' => 'version'], - 'editor_doc_versioned_title' => ['name' => 'editor_doc_versioned_title', 'type' => 'string', 'internal' => 'title'], - 'editor_doc_versioned_plain' => ['name' => 'editor_doc_versioned_plain', 'type' => 'string', 'internal' => 'plain'], - 'editor_doc_versioned_content' => ['name' => 'editor_doc_versioned_content', 'type' => 'string', 'internal' => 'content'], - 'editor_doc_versioned_at' => ['name' => 'editor_doc_versioned_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], - 'editor_doc_versioned_by' => ['name' => 'editor_doc_versioned_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], + 'editor_doc_versioned_id' => ['name' => 'editor_doc_versioned_id', 'type' => 'int', 'internal' => 'id'], + 'editor_doc_versioned_version' => ['name' => 'editor_doc_versioned_version', 'type' => 'string', 'internal' => 'version'], + 'editor_doc_versioned_title' => ['name' => 'editor_doc_versioned_title', 'type' => 'string', 'internal' => 'title'], + 'editor_doc_versioned_plain' => ['name' => 'editor_doc_versioned_plain', 'type' => 'string', 'internal' => 'plain'], + 'editor_doc_versioned_content' => ['name' => 'editor_doc_versioned_content', 'type' => 'string', 'internal' => 'content'], + 'editor_doc_versioned_at' => ['name' => 'editor_doc_versioned_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true], + 'editor_doc_versioned_by' => ['name' => 'editor_doc_versioned_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true], ]; /** diff --git a/Models/EditorDocMapper.php b/Models/EditorDocMapper.php index b472168..abca7f9 100755 --- a/Models/EditorDocMapper.php +++ b/Models/EditorDocMapper.php @@ -40,17 +40,17 @@ final class EditorDocMapper extends DataMapperFactory * @since 1.0.0 */ public const COLUMNS = [ - 'editor_doc_id' => ['name' => 'editor_doc_id', 'type' => 'int', 'internal' => 'id'], - 'editor_doc_version' => ['name' => 'editor_doc_version', 'type' => 'string', 'internal' => 'version'], - 'editor_doc_title' => ['name' => 'editor_doc_title', 'type' => 'string', 'internal' => 'title'], - 'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'], - 'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'], - 'editor_doc_type' => ['name' => 'editor_doc_type', 'type' => 'int', 'internal' => 'type'], - 'editor_doc_virtual' => ['name' => 'editor_doc_virtual', 'type' => 'string', 'internal' => 'virtualPath'], - 'editor_doc_versioned' => ['name' => 'editor_doc_versioned', 'type' => 'bool', 'internal' => 'isVersioned'], - 'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], - 'editor_doc_created_by' => ['name' => 'editor_doc_created_by', 'type' => 'int', 'internal' => 'createdBy'], - 'editor_doc_visible' => ['name' => 'editor_doc_visible', 'type' => 'bool', 'internal' => 'isVisible'], + 'editor_doc_id' => ['name' => 'editor_doc_id', 'type' => 'int', 'internal' => 'id'], + 'editor_doc_version' => ['name' => 'editor_doc_version', 'type' => 'string', 'internal' => 'version'], + 'editor_doc_title' => ['name' => 'editor_doc_title', 'type' => 'string', 'internal' => 'title'], + 'editor_doc_plain' => ['name' => 'editor_doc_plain', 'type' => 'string', 'internal' => 'plain'], + 'editor_doc_content' => ['name' => 'editor_doc_content', 'type' => 'string', 'internal' => 'content'], + 'editor_doc_type' => ['name' => 'editor_doc_type', 'type' => 'int', 'internal' => 'type'], + 'editor_doc_virtual' => ['name' => 'editor_doc_virtual', 'type' => 'string', 'internal' => 'virtualPath'], + 'editor_doc_versioned' => ['name' => 'editor_doc_versioned', 'type' => 'bool', 'internal' => 'isVersioned'], + 'editor_doc_created_at' => ['name' => 'editor_doc_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], + 'editor_doc_created_by' => ['name' => 'editor_doc_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'editor_doc_visible' => ['name' => 'editor_doc_visible', 'type' => 'bool', 'internal' => 'isVisible'], ]; /** @@ -92,7 +92,7 @@ final class EditorDocMapper extends DataMapperFactory 'self' => 'editor_doc_tag_dst', 'external' => 'editor_doc_tag_src', ], - 'media' => [ + 'files' => [ 'mapper' => MediaMapper::class, 'table' => 'editor_doc_media', 'external' => 'editor_doc_media_dst', diff --git a/Models/EditorDocTypeMapper.php b/Models/EditorDocTypeMapper.php index cd0d816..33a362f 100755 --- a/Models/EditorDocTypeMapper.php +++ b/Models/EditorDocTypeMapper.php @@ -49,11 +49,11 @@ final class EditorDocTypeMapper extends DataMapperFactory */ public const HAS_MANY = [ 'l11n' => [ - 'mapper' => EditorDocTypeL11nMapper::class, - 'table' => 'editor_doc_type_l11n', - 'self' => 'editor_doc_type_l11n_type', - 'column' => 'content', - 'external' => null, + 'mapper' => EditorDocTypeL11nMapper::class, + 'table' => 'editor_doc_type_l11n', + 'self' => 'editor_doc_type_l11n_type', + 'column' => 'content', + 'external' => null, ], ]; diff --git a/Theme/Backend/Components/Compound/BaseView.php b/Theme/Backend/Components/Compound/BaseView.php index ec719fa..ab8e6a4 100644 --- a/Theme/Backend/Components/Compound/BaseView.php +++ b/Theme/Backend/Components/Compound/BaseView.php @@ -65,7 +65,7 @@ class BaseView extends View /** * {@inheritdoc} */ - public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) + public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) { parent::__construct($l11n, $request, $response); $this->setTemplate('/Modules/Editor/Theme/Backend/Components/Compound/compound'); @@ -81,7 +81,7 @@ class BaseView extends View /** @var array{0:string, 1?:string, 2?:array} $data */ $this->form = $data[0]; $this->virtualPath = $data[1] ?? $this->virtualPath; - $this->docs = $data[2] ?? $this->docs; + $this->docs = $data[2] ?? $this->docs; return parent::render(); } diff --git a/Theme/Backend/Components/Compound/compound.tpl.php b/Theme/Backend/Components/Compound/compound.tpl.php index 8505e2f..d334241 100644 --- a/Theme/Backend/Components/Compound/compound.tpl.php +++ b/Theme/Backend/Components/Compound/compound.tpl.php @@ -43,8 +43,11 @@ printHtml($doc->id); ?> printHtml($doc->title); ?> + docs)) : ?> + getHtml('Empty', '0', '0'); ?> + - + \ No newline at end of file diff --git a/Theme/Backend/Components/Editor/BaseView.php b/Theme/Backend/Components/Editor/BaseView.php index b04a8f0..5a7167d 100755 --- a/Theme/Backend/Components/Editor/BaseView.php +++ b/Theme/Backend/Components/Editor/BaseView.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Modules\Editor\Theme\Backend\Components\Editor; -use phpOMS\Asset\AssetType; use phpOMS\Localization\L11nManager; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; @@ -42,7 +41,7 @@ class BaseView extends View /** * {@inheritdoc} */ - public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) + public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) { parent::__construct($l11n, $request, $response); $this->setTemplate('/Modules/Editor/Theme/Backend/Components/Editor/inline-editor-tools'); diff --git a/Theme/Backend/Components/Editor/TextView.php b/Theme/Backend/Components/Editor/TextView.php index dce60af..e677d3a 100755 --- a/Theme/Backend/Components/Editor/TextView.php +++ b/Theme/Backend/Components/Editor/TextView.php @@ -105,7 +105,7 @@ class TextView extends View /** * {@inheritdoc} */ - public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) + public function __construct(?L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response) { parent::__construct($l11n, $request, $response); $this->setTemplate('/Modules/Editor/Theme/Backend/Components/Editor/inline-editor'); diff --git a/Theme/Backend/Components/Editor/inline-editor.tpl.php b/Theme/Backend/Components/Editor/inline-editor.tpl.php index 919575c..b881bcd 100755 --- a/Theme/Backend/Components/Editor/inline-editor.tpl.php +++ b/Theme/Backend/Components/Editor/inline-editor.tpl.php @@ -9,7 +9,7 @@