Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor
composer.lock
.php-version
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Onisep Ibexa Imagemap Bundle

This bundle provides an image map field type for Ibexa 3.3+.
This bundle provides an image map field type for Ibexa 4.0+.

## Installation

Expand Down Expand Up @@ -39,7 +39,7 @@ $ bin/console onisep:imagemap:dump-schema --update
To build admin assets:

```shell script
yarn encore prod --config-name=ezplatform
yarn encore prod --config-name=ibexa
```

For the front assets, you need to import the bundle files in your own entry points. For example, if your entry point is
Expand Down
31 changes: 29 additions & 2 deletions assets/css/imagemap.contenttype.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
border: 1px solid black;

svg {
fill: #17a2b8;
fill: #ae1164;
width: 40px;
height: 40px;
}
Expand All @@ -41,10 +41,37 @@
svg {
width: 50px;
height: 50px;
fill: #17a2b8;
fill: #ae1164;
}
}

.imagemap-shape {
cursor: pointer;
}

.imagemap-edit {
.ibexa-field-edit--with-preview .ibexa-field-edit-preview__visual {
grid-template-columns: 100% auto;
grid-template-rows: 40.125rem auto;

.ibexa-field-edit-preview__details {
display: none;
}

.ibexa-field-edit-preview__media {
max-height: 40rem;
}
}
}

.imagemap-areas {
margin: 1rem 0 1rem 2.5rem;
}

.imagemap-add {
margin-left: 2.5rem;
}

.imagemap-draw-buttons {
margin-bottom: 1rem;
}
16 changes: 15 additions & 1 deletion assets/js/imagemap_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const initImageMap = function (imageMap) {

const prototype = areas.parentNode.dataset.prototype;
const map = imageMap.querySelector('.imagemap-map');
const image = imageMap.querySelector('.ez-field-edit-preview__media');
const image = imageMap.querySelector('.ibexa-field-edit-preview__media');
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
const draw = SVG(svg);
const parent = image.parentNode;
Expand Down Expand Up @@ -168,6 +168,20 @@ const initArea = function (area, map, draw) {
target.querySelector('option[value="popin"]').hidden = true;
}

area.querySelectorAll('.ibexa-dropdown').forEach((dropdownContainer) => {
const dropdownAlreadyInitialized = !!global.ibexa.helpers.objectInstances.getInstance(dropdownContainer);

if (dropdownAlreadyInitialized) {
return;
}

const dropdown = new global.ibexa.core.Dropdown({
container: dropdownContainer,
});

dropdown.init();
});

recreateShape(area, draw);
}

Expand Down
24 changes: 17 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onisep/ibexa-imagemap-bundle",
"description": "Image map field type for Ibexa 3.3",
"description": "Image map field type for Ibexa 4.0+",
"type": "symfony-bundle",
"keywords": ["ibexa", "image map"],
"license": "MIT",
Expand All @@ -23,6 +23,16 @@
"homepage": "https://github.com/onisep/imagemap-bundle/graphs/contributors"
}
],
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"http-interop/http-factory-guzzle": "^1.2",
"ibexa/admin-ui": "^4.5.3",
"ibexa/core": ">=4.5.3 <4.6.2"
},
"require-dev": {
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4": {
"Onisep\\IbexaImageMapBundle\\": "src/"
Expand All @@ -33,15 +43,15 @@
"Onisep\\IbexaImageMapBundle\\Tests\\": "tests/"
}
},
"require": {
"php": ">=7.4",
"ext-json": "*",
"ezsystems/ezplatform-admin-ui": "^2.3",
"ezsystems/ezplatform-kernel": "^1.3"
"scripts": {
"phpstan": "phpstan analyse -l 1 src"
},
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
}
}
6 changes: 0 additions & 6 deletions src/Command/SchemaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public function __construct(Connection $connection)
$this->connection = $connection;
}

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
Expand All @@ -40,9 +37,6 @@ protected function configure()
;
}

/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$schemaProvider = new SchemaProvider();
Expand Down
2 changes: 1 addition & 1 deletion src/DataTransformer/ImageMapTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Onisep\IbexaImageMapBundle\DataTransformer;

use EzSystems\EzPlatformContentForms\FieldType\DataTransformer\ImageValueTransformer;
use Ibexa\ContentForms\FieldType\DataTransformer\ImageValueTransformer;
use Onisep\IbexaImageMapBundle\FieldType\ImageMap\Value;

class ImageMapTransformer extends ImageValueTransformer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ class AddDefaultViewTemplatePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$parameter = $container->getParameter('ezsettings.default.content_view_defaults');
$parameter = $container->getParameter('ibexa.site_access.config.default.content_view_defaults');
$parameter['imagemap_embed'] = [
'default' => [
'template' => '@ezdesign/default/content/imagemap_embed.html.twig',
'template' => '@ibexadesign/default/content/imagemap_embed.html.twig',
'match' => [],
],
];
$parameter['imagemap_popin'] = [
'default' => [
'template' => '@ezdesign/default/content/imagemap_popin.html.twig',
'template' => '@ibexadesign/default/content/imagemap_popin.html.twig',
'match' => [],
],
];

$container->setParameter('ezsettings.default.content_view_defaults', $parameter);
$container->setParameter('ibexa.site_access.config.default.content_view_defaults', $parameter);
}
}
2 changes: 1 addition & 1 deletion src/DependencyInjection/OnisepImageMapExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function prepend(ContainerBuilder $container)
{
$adminUiFormsConfigFile = __DIR__.'/../Resources/config/admin_ui_forms.yaml';
$config = Yaml::parseFile($adminUiFormsConfigFile);
$container->prependExtensionConfig('ezpublish', $config);
$container->prependExtensionConfig('ibexa', $config);
$container->addResource(new FileResource($adminUiFormsConfigFile));
}
}
8 changes: 4 additions & 4 deletions src/FieldType/ImageMap/FieldValueConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Onisep\IbexaImageMapBundle\FieldType\ImageMap;

use eZ\Publish\Core\FieldType\FieldSettings;
use eZ\Publish\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageConverter;
use eZ\Publish\Core\Persistence\Legacy\Content\StorageFieldDefinition;
use eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition;
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;
use Ibexa\Core\FieldType\FieldSettings;
use Ibexa\Core\Persistence\Legacy\Content\FieldValue\Converter\ImageConverter;
use Ibexa\Core\Persistence\Legacy\Content\StorageFieldDefinition;

class FieldValueConverter extends ImageConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Onisep\IbexaImageMapBundle\FieldType\ImageMap\ImageMapStorage\Gateway;

use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use Ibexa\Contracts\Core\Persistence\Content\Field;
use Ibexa\Contracts\Core\Persistence\Content\VersionInfo;
use Onisep\IbexaImageMapBundle\Database\ImageMapRepository;

class LegacyStorage
Expand All @@ -29,7 +29,7 @@ public function saveMap(VersionInfo $versionInfo, Field $field): void

$exists = $this->repository->get($fieldId, $version);

if ($exists) {
if ($exists !== null) {
$this->repository->update($fieldId, $version, $field->value->data['map']);

return;
Expand Down
30 changes: 14 additions & 16 deletions src/FieldType/ImageMap/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

namespace Onisep\IbexaImageMapBundle\FieldType\ImageMap;

use eZ\Publish\Core\Base\Utils\DeprecationWarnerInterface as DeprecationWarner;
use eZ\Publish\Core\FieldType\Image\AliasCleanerInterface;
use eZ\Publish\Core\FieldType\Image\ImageStorage;
use eZ\Publish\Core\FieldType\Image\ImageStorage\Gateway as ImageStorageGateway;
use eZ\Publish\Core\FieldType\Image\PathGenerator;
use eZ\Publish\Core\IO\FilePathNormalizerInterface;
use eZ\Publish\Core\IO\IOServiceInterface;
use eZ\Publish\Core\IO\MetadataHandler;
use eZ\Publish\SPI\Persistence\Content\Field;
use eZ\Publish\SPI\Persistence\Content\VersionInfo;
use Ibexa\Contracts\Core\FieldType\StorageGatewayInterface;
use Ibexa\Contracts\Core\Persistence\Content\Field;
use Ibexa\Contracts\Core\Persistence\Content\VersionInfo;
use Ibexa\Core\FieldType\Image\AliasCleanerInterface;
use Ibexa\Core\FieldType\Image\ImageStorage;
use Ibexa\Core\FieldType\Image\PathGenerator;
use Ibexa\Core\IO\FilePathNormalizerInterface;
use Ibexa\Core\IO\IOServiceInterface;
use Ibexa\Core\IO\MetadataHandler;
use Onisep\IbexaImageMapBundle\FieldType\ImageMap\ImageMapStorage\Gateway\LegacyStorage as ImageMapStorageGateway;

/**
Expand All @@ -24,16 +23,15 @@ class Storage extends ImageStorage
private ImageMapStorageGateway $imageMapGateway;

public function __construct(
ImageStorageGateway $baseGateway,
IOServiceInterface $IOService,
StorageGatewayInterface $gateway,
IOServiceInterface $ioService,
PathGenerator $pathGenerator,
MetadataHandler $imageSizeMetadataHandler,
DeprecationWarner $deprecationWarner,
ImageMapStorageGateway $imageMapGateway,
AliasCleanerInterface $aliasCleaner,
FilePathNormalizerInterface $filePathNormalizer
FilePathNormalizerInterface $filePathNormalizer,
ImageMapStorageGateway $imageMapGateway
) {
parent::__construct($baseGateway, $IOService, $pathGenerator, $imageSizeMetadataHandler, $deprecationWarner, $aliasCleaner, $filePathNormalizer);
parent::__construct($gateway, $ioService, $pathGenerator, $imageSizeMetadataHandler, $aliasCleaner, $filePathNormalizer);

$this->imageMapGateway = $imageMapGateway;
}
Expand Down
8 changes: 4 additions & 4 deletions src/FieldType/ImageMap/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Onisep\IbexaImageMapBundle\FieldType\ImageMap;

use eZ\Publish\Core\FieldType\Image\Type as ImageType;
use eZ\Publish\SPI\FieldType\Value as SPIValue;
use eZ\Publish\SPI\Persistence\Content\FieldValue as PersistenceValue;
use Ibexa\Contracts\Core\FieldType\Value as SPIValue;
use Ibexa\Contracts\Core\Persistence\Content\FieldValue as PersistenceValue;
use Ibexa\Core\FieldType\Image\Type as ImageType;

/**
* The ImageMap field type.
Expand All @@ -18,7 +18,7 @@ public function getFieldTypeIdentifier()
return 'imagemap';
}

public function validateFieldSettings($fieldSettings)
public function validateFieldSettings($fieldSettings): array
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/FieldType/ImageMap/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Onisep\IbexaImageMapBundle\FieldType\ImageMap;

use eZ\Publish\Core\FieldType\Image\Value as ImageValue;
use Ibexa\Core\FieldType\Image\Value as ImageValue;

/**
* Value for ImageMap field type.
Expand Down
2 changes: 1 addition & 1 deletion src/Form/ImageMapType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Onisep\IbexaImageMapBundle\Form;

use EzSystems\EzPlatformContentForms\Form\Type\FieldType\ImageFieldType;
use Ibexa\ContentForms\Form\Type\FieldType\ImageFieldType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Form/LinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Onisep\IbexaImageMapBundle\Form;

use eZ\Publish\API\Repository\ContentService;
use Ibexa\Contracts\Core\Repository\ContentService;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormInterface;
Expand Down
14 changes: 7 additions & 7 deletions src/FormMapper/ImageMapFormMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace Onisep\IbexaImageMapBundle\FormMapper;

use eZ\Publish\API\Repository\ContentTypeService;
use eZ\Publish\API\Repository\FieldTypeService;
use eZ\Publish\API\Repository\LocationService;
use EzSystems\EzPlatformAdminUi\FieldType\Mapper\AbstractRelationFormMapper;
use EzSystems\EzPlatformAdminUi\Form\Data\FieldDefinitionData;
use EzSystems\EzPlatformContentForms\Data\Content\FieldData;
use EzSystems\EzPlatformContentForms\FieldType\FieldValueFormMapperInterface;
use Ibexa\AdminUi\FieldType\Mapper\AbstractRelationFormMapper;
use Ibexa\AdminUi\Form\Data\FieldDefinitionData;
use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
use Ibexa\Contracts\ContentForms\FieldType\FieldValueFormMapperInterface;
use Ibexa\Contracts\Core\Repository\ContentTypeService;
use Ibexa\Contracts\Core\Repository\FieldTypeService;
use Ibexa\Contracts\Core\Repository\LocationService;
use Onisep\IbexaImageMapBundle\DataTransformer\ImageMapTransformer;
use Onisep\IbexaImageMapBundle\FieldType\ImageMap\Value;
use Onisep\IbexaImageMapBundle\Form\ImageMapType;
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/config/admin_ui_forms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ system:
admin_group:
admin_ui_forms:
content_edit_form_templates:
- { template: '@ezdesign/content/imagemap_form_fields.html.twig', priority: 1 }
- { template: '@ibexadesign/content/imagemap_form_fields.html.twig', priority: 1 }

default:
field_templates:
- { template: '@ezdesign/fields/imagemap_content_fields.html.twig', priority: 0 }
- { template: '@ibexadesign/fields/imagemap_content_fields.html.twig', priority: 0 }
Loading