diff --git a/Admin/Installer.php b/Admin/Installer.php index d4107e1..e9c1a8e 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -150,7 +150,7 @@ final class Installer extends InstallerAbstract /** @var \Modules\Editor\Models\EditorDocType $type */ $type = $responseData['response']; - $id = $type->getId(); + $id = $type->id; $isFirst = true; foreach ($data['l11n'] as $l11n) { diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 367f7f4..2a76f31 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -280,23 +280,23 @@ final class ApiController extends Controller $collection = null; foreach ($uploaded as $media) { - $accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login + $accountPath = '/Accounts/' . $account->id . ' ' . $account->login . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') - . '/' . $doc->getId(); + . '/' . $doc->id; if ($collection === null) { $collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection( $accountPath, $request->header->account, - __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->getId() + __DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->id . '/Editor/' . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->id ); } $this->createModelRelation( $request->header->account, - $doc->getId(), - $media->getId(), + $doc->id, + $media->id, EditorDocMapper::class, 'media', '', @@ -305,7 +305,7 @@ final class ApiController extends Controller $ref = new Reference(); $ref->name = $media->name; - $ref->source = new NullMedia($media->getId()); + $ref->source = new NullMedia($media->id); $ref->createdBy = new NullAccount($request->header->account); $ref->setVirtualPath($accountPath); @@ -313,8 +313,8 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -336,7 +336,7 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, - $doc->getId(), + $doc->id, (int) $media, EditorDocMapper::class, 'media', @@ -355,8 +355,8 @@ final class ApiController extends Controller $this->createModel($request->header->account, $ref, ReferenceMapper::class, 'media_reference', $request->getOrigin()); $this->createModelRelation( $request->header->account, - $collection->getId(), - $ref->getId(), + $collection->id, + $ref->id, CollectionMapper::class, 'sources', '', @@ -381,7 +381,7 @@ final class ApiController extends Controller . $doc->createdAt->format('Y') . '/' . $doc->createdAt->format('m') . '/' . $doc->createdAt->format('d') . '/' - . $doc->getId(); + . $doc->id; } /** @@ -586,7 +586,7 @@ final class ApiController extends Controller foreach ($uploaded as $file) { $this->createModelRelation( $request->header->account, - $file->getId(), + $file->id, $request->getDataInt('type'), MediaMapper::class, 'types', @@ -599,7 +599,7 @@ final class ApiController extends Controller $this->createModelRelation( $request->header->account, (int) $request->getData('doc'), - \reset($uploaded)->getId(), + \reset($uploaded)->id, EditorDocMapper::class, 'media', '', $request->getOrigin() ); diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 96d7f07..e4c5bff 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -142,9 +142,9 @@ final class BackendController extends Controller $accountId = $request->header->account; - if ($doc->createdBy->getId() !== $accountId + if ($doc->createdBy->id !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; @@ -162,7 +162,7 @@ final class BackendController extends Controller $view->addData('tagSelector', $tagSelector); $view->addData('editable', $this->app->accountManager->get($accountId)->hasPermission( - PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::MODIFY, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ); return $view; @@ -188,9 +188,9 @@ final class BackendController extends Controller $doc = EditorDocMapper::get()->where('id', (int) $request->getData('id'))->execute(); $accountId = $request->header->account; - if ($doc->createdBy->getId() !== $accountId + if ($doc->createdBy->id !== $accountId && !$this->app->accountManager->get($accountId)->hasPermission( - PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->getId()) + PermissionType::READ, $this->app->unitId, $this->app->appId, self::NAME, PermissionCategory::DOC, $doc->id) ) { $view->setTemplate('/Web/Backend/Error/403_inline'); $response->header->status = RequestStatusCode::R_403; diff --git a/Models/EditorDoc.php b/Models/EditorDoc.php index 8c17563..94cfef9 100755 --- a/Models/EditorDoc.php +++ b/Models/EditorDoc.php @@ -35,7 +35,7 @@ class EditorDoc implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Version. diff --git a/Models/EditorDocHistory.php b/Models/EditorDocHistory.php index 019e2e4..6be2f4d 100755 --- a/Models/EditorDocHistory.php +++ b/Models/EditorDocHistory.php @@ -33,7 +33,7 @@ class EditorDocHistory implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Doc ID. @@ -114,7 +114,7 @@ class EditorDocHistory implements \JsonSerializable public static function createFromDoc(EditorDoc $doc) : self { $hist = new self(); - $hist->doc = $doc->getId(); + $hist->doc = $doc->id; $hist->createdBy = $doc->createdBy; $hist->title = $doc->title; $hist->plain = $doc->plain; diff --git a/Models/EditorDocType.php b/Models/EditorDocType.php index 5e10b8a..57f46a9 100755 --- a/Models/EditorDocType.php +++ b/Models/EditorDocType.php @@ -33,7 +33,7 @@ class EditorDocType implements \JsonSerializable * @var int * @since 1.0.0 */ - protected int $id = 0; + public int $id = 0; /** * Name. diff --git a/Theme/Backend/editor-create.tpl.php b/Theme/Backend/editor-create.tpl.php index 7b12d47..7dc4551 100755 --- a/Theme/Backend/editor-create.tpl.php +++ b/Theme/Backend/editor-create.tpl.php @@ -17,7 +17,7 @@ use phpOMS\Uri\UriFactory; /** @var \Modules\Editor\Models\EditorDoc $doc */ $doc = $this->getData('doc') ?? new NullEditorDoc(); -$isNewDoc = $doc instanceof NullEditorDoc; +$isNewDoc = $doc->id === 0; /** @var \phpOMS\Views\View $this */ echo $this->getData('nav')->render(); ?> diff --git a/Theme/Backend/editor-list.tpl.php b/Theme/Backend/editor-list.tpl.php index 5d75e18..9606ac0 100755 --- a/Theme/Backend/editor-list.tpl.php +++ b/Theme/Backend/editor-list.tpl.php @@ -25,10 +25,10 @@ $collections = $this->getData('collections'); $mediaPath = \urldecode($this->getData('path') ?? '/'); $account = $this->getData('account'); -$accountDir = $account->getId() . ' ' . $account->login; +$accountDir = $account->id . ' ' . $account->login; -$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->getId() . '&ptype=p'; -$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->getId() . '&ptype=n'; +$previous = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \reset($docs)->id . '&ptype=p'; +$next = empty($docs) ? '{/base}/editor/list' : '{/base}/editor/list?{?}&id=' . \end($docs)->id . '&ptype=n'; $docs = $this->getData('docs'); @@ -134,11 +134,11 @@ echo $this->getData('nav')->render(); ?> printHtml($value->name); ?> - printHtml($value->createdBy->name1); ?> + printHtml($value->createdBy->name1); ?> printHtml($value->createdAt->format('Y-m-d')); ?> $value) : ++$count; - $url = UriFactory::build('{/base}/editor/single?{?}&id=' . $value->getId()); ?> + $url = UriFactory::build('{/base}/editor/single?{?}&id=' . $value->id); ?> printHtml($value->title); ?> - printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?> + printHtml($this->renderUserName('%3$s %2$s %1$s', [$value->createdBy->name1, $value->createdBy->name2, $value->createdBy->name3, $value->createdBy->login ?? ''])); ?> printHtml($value->createdAt->format('Y-m-d')); ?> diff --git a/Theme/Backend/editor-single.tpl.php b/Theme/Backend/editor-single.tpl.php index 5d414ea..29a8d25 100755 --- a/Theme/Backend/editor-single.tpl.php +++ b/Theme/Backend/editor-single.tpl.php @@ -45,7 +45,7 @@ echo $this->getData('nav')->render(); ?>
- getHtml('Edit', '0', '0'); ?> + getHtml('Edit', '0', '0'); ?>
@@ -57,9 +57,9 @@ echo $this->getData('nav')->render(); ?> extension === 'collection' ? UriFactory::build('{/base}/media/list?path=' . \rtrim($file->getVirtualPath(), '/') . '/' . $file->name) - : UriFactory::build('{/base}/media/single?id=' . $file->getId() + : UriFactory::build('{/base}/media/single?id=' . $file->id . '&path={?path}' . ( - $file->getId() === 0 + $file->id === 0 ? '/' . $file->name : '' ) diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php index 83581aa..0c47f88 100755 --- a/tests/Controller/ApiControllerTest.php +++ b/tests/Controller/ApiControllerTest.php @@ -126,7 +126,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiEditorCreate($request, $response); self::assertEquals('Controller Test Title', $response->get('')['response']->title); - self::assertGreaterThan(0, $response->get('')['response']->getId()); + self::assertGreaterThan(0, $response->get('')['response']->id); } /** @@ -228,7 +228,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase self::assertEquals('Changed Title', $response->get('')['response']->title); self::assertEquals('Changed Title', EditorDocMapper::get()->where('id', 1)->execute()->title); - self::assertEquals(1, $response->get('')['response']->getId()); + self::assertEquals(1, $response->get('')['response']->id); } /** @@ -268,7 +268,7 @@ final class ApiControllerTest extends \PHPUnit\Framework\TestCase $this->module->apiEditorDelete($request, $response); - self::assertEquals($docId, $response->get('')['response']->getId()); + self::assertEquals($docId, $response->get('')['response']->id); self::assertInstanceOf(NullEditorDoc::class, EditorDocMapper::get()->where('id', $docId)->execute()); } } diff --git a/tests/Models/EditorDocMapperTest.php b/tests/Models/EditorDocMapperTest.php index e845563..0231a45 100755 --- a/tests/Models/EditorDocMapperTest.php +++ b/tests/Models/EditorDocMapperTest.php @@ -37,17 +37,17 @@ final class EditorDocMapperTest extends \PHPUnit\Framework\TestCase $doc->setVirtualPath('/some/test/path'); $id = EditorDocMapper::create()->execute($doc); - self::assertGreaterThan(0, $doc->getId()); - self::assertEquals($id, $doc->getId()); + self::assertGreaterThan(0, $doc->id); + self::assertEquals($id, $doc->id); - $docR = EditorDocMapper::get()->where('id', $doc->getId())->execute(); + $docR = EditorDocMapper::get()->where('id', $doc->id)->execute(); self::assertEquals($doc->createdAt->format('Y-m-d'), $docR->createdAt->format('Y-m-d')); - self::assertEquals($doc->createdBy->getId(), $docR->createdBy->getId()); + self::assertEquals($doc->createdBy->id, $docR->createdBy->id); self::assertEquals($doc->content, $docR->content); self::assertEquals($doc->title, $docR->title); self::assertEquals($doc->getVirtualPath(), $docR->getVirtualPath()); $docR2 = EditorDocMapper::getByVirtualPath('/some/test/path', 1)->execute(); - self::assertEquals($docR->getId(), \reset($docR2)->getId()); + self::assertEquals($docR->id, \reset($docR2)->id); } } diff --git a/tests/Models/EditorDocTest.php b/tests/Models/EditorDocTest.php index 5162f59..f339759 100755 --- a/tests/Models/EditorDocTest.php +++ b/tests/Models/EditorDocTest.php @@ -40,8 +40,8 @@ final class EditorDocTest extends \PHPUnit\Framework\TestCase */ public function testDefault() : void { - self::assertEquals(0, $this->doc->getId()); - self::assertEquals(0, $this->doc->createdBy->getId()); + self::assertEquals(0, $this->doc->id); + self::assertEquals(0, $this->doc->createdBy->id); self::assertEquals('', $this->doc->title); self::assertEquals('', $this->doc->content); self::assertEquals('', $this->doc->plain); @@ -57,7 +57,7 @@ final class EditorDocTest extends \PHPUnit\Framework\TestCase public function testCreatedByInputOutput() : void { $this->doc->createdBy = new NullAccount(1); - self::assertEquals(1, $this->doc->createdBy->getId()); + self::assertEquals(1, $this->doc->createdBy->id); } /** diff --git a/tests/Models/NullEditorDocTest.php b/tests/Models/NullEditorDocTest.php index 2602cff..11a6855 100755 --- a/tests/Models/NullEditorDocTest.php +++ b/tests/Models/NullEditorDocTest.php @@ -37,6 +37,6 @@ final class NullEditorDocTest extends \PHPUnit\Framework\TestCase public function testId() : void { $null = new NullEditorDoc(2); - self::assertEquals(2, $null->getId()); + self::assertEquals(2, $null->id); } }