diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f2890b572c..5cce722948 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9036,27 +9036,27 @@ parameters: path: src/lib/Tab/Event/TabViewRenderEvent.php - - message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\ContentTab\\:\\:loadContentLanguages\\(\\) return type has no value type specified in iterable type array\\.$#" + message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\AuthorsTab\\:\\:supplyCreator\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" count: 1 - path: src/lib/Tab/LocationView/ContentTab.php + path: src/lib/Tab/LocationView/AuthorsTab.php - - message: "#^Access to protected property Ibexa\\\\AdminUi\\\\UI\\\\Value\\\\ObjectState\\\\ObjectState\\:\\:\\$objectStateGroup\\.$#" + message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\AuthorsTab\\:\\:supplyLastContributor\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" count: 1 - path: src/lib/Tab/LocationView/DetailsTab.php + path: src/lib/Tab/LocationView/AuthorsTab.php - - message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\DetailsTab\\:\\:supplyCreator\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" + message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\ContentTab\\:\\:loadContentLanguages\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 - path: src/lib/Tab/LocationView/DetailsTab.php + path: src/lib/Tab/LocationView/ContentTab.php - - message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\DetailsTab\\:\\:supplyFormLocationUpdate\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" + message: "#^Access to protected property Ibexa\\\\AdminUi\\\\UI\\\\Value\\\\ObjectState\\\\ObjectState\\:\\:\\$objectStateGroup\\.$#" count: 1 path: src/lib/Tab/LocationView/DetailsTab.php - - message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\DetailsTab\\:\\:supplyLastContributor\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" + message: "#^Method Ibexa\\\\AdminUi\\\\Tab\\\\LocationView\\\\DetailsTab\\:\\:supplyFormLocationUpdate\\(\\) has parameter \\$parameters with generic class ArrayObject but does not specify its types\\: TKey, TValue$#" count: 1 path: src/lib/Tab/LocationView/DetailsTab.php diff --git a/src/bundle/Resources/translations/ibexa_locationview.en.xliff b/src/bundle/Resources/translations/ibexa_locationview.en.xliff index 5772b85116..2b6c02e04a 100644 --- a/src/bundle/Resources/translations/ibexa_locationview.en.xliff +++ b/src/bundle/Resources/translations/ibexa_locationview.en.xliff @@ -246,9 +246,14 @@ Visibility key: tab.locations.visibility + + Authors + Authors + key: tab.name.authors + - Details - Details + Technical Details + Technical Details key: tab.name.details diff --git a/src/bundle/Resources/translations/messages.en.xliff b/src/bundle/Resources/translations/messages.en.xliff index e4274df093..60e7451243 100644 --- a/src/bundle/Resources/translations/messages.en.xliff +++ b/src/bundle/Resources/translations/messages.en.xliff @@ -71,6 +71,16 @@ Username key: authentication.username + + No suggestions available. + No suggestions available. + key: autocomplete.no_results + + + View all results + View all results + key: autocomplete.view_all_results + Go to top Go to top diff --git a/src/bundle/Resources/views/themes/admin/content/tab/authors.html.twig b/src/bundle/Resources/views/themes/admin/content/tab/authors.html.twig new file mode 100644 index 0000000000..92a8d86c47 --- /dev/null +++ b/src/bundle/Resources/views/themes/admin/content/tab/authors.html.twig @@ -0,0 +1,44 @@ +{% trans_default_domain 'ibexa_locationview' %} + +{% set creator_name %} + {% if creator is not empty %} + {% include '@ibexadesign/ui/component/user/user.html.twig' with { user: creator } only %} + {% else %} + {{ 'tab.details.creator.not_found'|trans|desc('Can\'t fetch creator') }} + {% endif %} +{% endset %} + +{% set last_contributor_name %} + {% if last_contributor is not empty %} + {% include '@ibexadesign/ui/component/user/user.html.twig' with { user: last_contributor } only %} + {% else %} + {{ 'tab.details.last_contributor.not_found'|trans|desc('Can\'t fetch last contributor') }} + {% endif %} +{% endset %} + +{% set content_details_items = [ + { + label: 'tab.details.creator'|trans()|desc('Creator'), + content: creator_name, + }, + { + label: 'tab.details.last_contributor'|trans()|desc('Last contributor'), + content: last_contributor_name, + } +] %} + +{% include '@ibexadesign/ui/component/details/details.html.twig' with { + headline: 'tab.details.content_details'|trans()|desc('Content details'), + items: content_details_items, +} only %} + +{% set technical_details_items = [ + { + label: 'tab.details.content_id'|trans()|desc('Content ID'), + content: content_info.id, + }, + { + label: 'tab.details.location_id'|trans()|desc('Location ID'), + content: location.id, + } +] %} diff --git a/src/bundle/Resources/views/themes/admin/content/tab/details.html.twig b/src/bundle/Resources/views/themes/admin/content/tab/details.html.twig index a707bc0229..f8bb3cc4bc 100644 --- a/src/bundle/Resources/views/themes/admin/content/tab/details.html.twig +++ b/src/bundle/Resources/views/themes/admin/content/tab/details.html.twig @@ -8,31 +8,7 @@ {% endfor %} {% endset %} -{% set creator_name %} - {% if creator is not empty %} - {% include '@ibexadesign/ui/component/user/user.html.twig' with { user: creator } only %} - {% else %} - {{ 'tab.details.creator.not_found'|trans|desc('Can\'t fetch creator') }} - {% endif %} -{% endset %} - -{% set last_contributor_name %} - {% if last_contributor is not empty %} - {% include '@ibexadesign/ui/component/user/user.html.twig' with { user: last_contributor } only %} - {% else %} - {{ 'tab.details.last_contributor.not_found'|trans|desc('Can\'t fetch last contributor') }} - {% endif %} -{% endset %} - {% set content_details_items = [ - { - label: 'tab.details.creator'|trans()|desc('Creator'), - content: creator_name, - }, - { - label: 'tab.details.last_contributor'|trans()|desc('Last contributor'), - content: last_contributor_name, - }, { label: 'tab.details.published_version'|trans()|desc('Published version'), content: version_info.versionNo, diff --git a/src/lib/Tab/LocationView/AuthorsTab.php b/src/lib/Tab/LocationView/AuthorsTab.php new file mode 100644 index 0000000000..dd25f37664 --- /dev/null +++ b/src/lib/Tab/LocationView/AuthorsTab.php @@ -0,0 +1,136 @@ +sectionService = $sectionService; + $this->userService = $userService; + $this->datasetFactory = $datasetFactory; + } + + /** + * @return string + */ + public function getIdentifier(): string + { + return 'authors'; + } + + /** + * @return string + */ + public function getName(): string + { + /** @Desc("authors") */ + return $this->translator->trans('tab.name.authors', [], 'ibexa_locationview'); + } + + /** + * @return int + */ + public function getOrder(): int + { + return 200; + } + + /** + * {@inheritdoc} + */ + public function getTemplate(): string + { + return '@ibexadesign/content/tab/authors.html.twig'; + } + + /** + * {@inheritdoc} + */ + public function getTemplateParameters(array $contextParameters = []): array + { + /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Content $content */ + $content = $contextParameters['content']; + + $versionInfo = $content->getVersionInfo(); + $contentInfo = $versionInfo->getContentInfo(); + + $viewParameters = new ArrayObject([ + 'content_info' => $contentInfo, + 'version_info' => $versionInfo, + ]); + + $this->supplyCreator($viewParameters, $contentInfo); + $this->supplyLastContributor($viewParameters, $versionInfo); + + return array_replace($contextParameters, $viewParameters->getArrayCopy()); + } + + /** + * @param \ArrayObject $parameters + * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo + */ + private function supplyLastContributor(ArrayObject $parameters, VersionInfo $versionInfo): void + { + $parameters['last_contributor'] = null; + if ((new UserExists($this->userService))->isSatisfiedBy($versionInfo->creatorId)) { + $parameters['last_contributor'] = $this->userService->loadUser($versionInfo->creatorId); + } + } + + /** + * @param \ArrayObject $parameters + * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo + */ + private function supplyCreator(ArrayObject $parameters, ContentInfo $contentInfo): void + { + $parameters['creator'] = null; + if ((new UserExists($this->userService))->isSatisfiedBy($contentInfo->ownerId)) { + $parameters['creator'] = $this->userService->loadUser($contentInfo->ownerId); + } + } +} diff --git a/src/lib/Tab/LocationView/DetailsTab.php b/src/lib/Tab/LocationView/DetailsTab.php index 5b94b46c9f..43ae9e89b8 100644 --- a/src/lib/Tab/LocationView/DetailsTab.php +++ b/src/lib/Tab/LocationView/DetailsTab.php @@ -15,7 +15,6 @@ use Ibexa\AdminUi\Form\Type\Location\LocationAssignSectionType; use Ibexa\AdminUi\Form\Type\Location\LocationUpdateType; use Ibexa\AdminUi\Form\Type\ObjectState\ContentObjectStateUpdateType; -use Ibexa\AdminUi\Specification\UserExists; use Ibexa\AdminUi\UI\Dataset\DatasetFactory; use Ibexa\Contracts\AdminUi\Tab\AbstractEventDispatchingTab; use Ibexa\Contracts\AdminUi\Tab\OrderedTabInterface; @@ -35,23 +34,15 @@ class DetailsTab extends AbstractEventDispatchingTab implements OrderedTabInterf { public const URI_FRAGMENT = 'ibexa-tab-location-view-details'; - /** @var \Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList */ - protected $fieldsGroupsListHelper; + protected UserService $userService; - /** @var \Ibexa\Contracts\Core\Repository\UserService */ - protected $userService; + protected SectionService $sectionService; - /** @var \Ibexa\Contracts\Core\Repository\SectionService */ - protected $sectionService; + protected DatasetFactory $datasetFactory; - /** @var \Ibexa\AdminUi\UI\Dataset\DatasetFactory */ - protected $datasetFactory; + private FormFactoryInterface $formFactory; - /** @var \Symfony\Component\Form\FormFactoryInterface */ - private $formFactory; - - /** @var \Ibexa\Contracts\Core\Repository\PermissionResolver */ - private $permissionResolver; + private PermissionResolver $permissionResolver; /** * @param \Twig\Environment $twig @@ -137,8 +128,6 @@ public function getTemplateParameters(array $contextParameters = []): array $this->supplyObjectStateParameters($viewParameters, $contentInfo); $this->supplyTranslations($viewParameters, $versionInfo); $this->supplyFormLocationUpdate($viewParameters, $location); - $this->supplyCreator($viewParameters, $contentInfo); - $this->supplyLastContributor($viewParameters, $versionInfo); $this->supplySortFieldClauseMap($viewParameters); return array_replace($contextParameters, $viewParameters->getArrayCopy()); @@ -162,30 +151,6 @@ private function supplySortFieldClauseMap(ArrayObject $parameters): void ]; } - /** - * @param \ArrayObject $parameters - * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo - */ - private function supplyCreator(ArrayObject $parameters, ContentInfo $contentInfo): void - { - $parameters['creator'] = null; - if ((new UserExists($this->userService))->isSatisfiedBy($contentInfo->ownerId)) { - $parameters['creator'] = $this->userService->loadUser($contentInfo->ownerId); - } - } - - /** - * @param \ArrayObject $parameters - * @param \Ibexa\Contracts\Core\Repository\Values\Content\VersionInfo $versionInfo - */ - private function supplyLastContributor(ArrayObject $parameters, VersionInfo $versionInfo): void - { - $parameters['last_contributor'] = null; - if ((new UserExists($this->userService))->isSatisfiedBy($versionInfo->creatorId)) { - $parameters['last_contributor'] = $this->userService->loadUser($versionInfo->creatorId); - } - } - /** * @param \ArrayObject $parameters * @param \Ibexa\Contracts\Core\Repository\Values\Content\ContentInfo $contentInfo