diff --git a/.github/workflows/codeception.yml b/.github/workflows/codeception.yml index 88c03dcb..9bd767e5 100644 --- a/.github/workflows/codeception.yml +++ b/.github/workflows/codeception.yml @@ -11,16 +11,16 @@ jobs: env: TEST_BUNDLE_NAME: "ToolboxBundle" TEST_BUNDLE_INSTALLER_CLASS: "ToolboxBundle\\Tool\\Install" - TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests" + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "1.0" + PIMCORE_CODECEPTION_VERSION: "2.0" - PIMCORE_ENVIRONMENT: test + APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test" PIMCORE_TEST_URL: "http://localhost" - PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/tests/_output/var/classes/DataObject" + PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/lib/test-bundle/tests/_output/var/classes/DataObject" SYMFONY_DEPRECATIONS_HELPER: "weak" PIMCORE_PHP_ERROR_REPORTING: 32767 @@ -41,33 +41,28 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [7.4] - symfony: [^4.4] - pimcore: [~6.6.0, ~6.7.0, ~6.8.0, ~6.9.0] + php: [ 8.0 ] + symfony: [ ^5.3 ] + pimcore: [ ~10.1.0 ] include: - - pimcore: ~6.6.0 - template_tag: v2.6.0 - - pimcore: ~6.7.0 - template_tag: v2.7.0 - - pimcore: ~6.8.0 - template_tag: v2.8.0 - - pimcore: ~6.8.0 - symfony: ^3.4 - php: 7.4 - template_tag: v2.8.0 - - pimcore: ~6.9.0 - template_tag: v2.8.19 + - pimcore: ~10.1.0 + template_tag: v10.1.0 steps: - uses: actions/checkout@v2 + with: + path: lib/test-bundle - name: Generate Application Structure run: | git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git - mv skeleton/app . + mv skeleton/composer.json . mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . mv skeleton/var . - mv skeleton/web . - mv skeleton/src/AppBundle src + rm -r skeleton - name: Setup Pimcore Codeception Framework env: @@ -110,7 +105,7 @@ jobs: - name: Start Webserver and Chrome run: | wget https://get.symfony.com/cli/installer -O - | bash - ~/.symfony/bin/symfony server:start --port=8080 --dir=web --force-php-discovery --allow-http --no-tls --daemon + ~/.symfony/bin/symfony server:start --port=8080 --dir=public --force-php-discovery --allow-http --no-tls --daemon - name: Get Composer Cache Directory id: composer-cache @@ -135,17 +130,17 @@ jobs: - name: Assets Install run: | - bin/console assets:install web --relative --symlink + bin/console assets:install public --relative --symlink - name: Tests run: | bin/console cache:warmup --env=test - vendor/bin/codecept run --env github -c ${{ env.GITHUB_WORKSPACE }} + vendor/bin/codecept run --env github -c ${{ github.workspace }}/lib/test-bundle - name: Log Output uses: actions/upload-artifact@v2 if: failure() with: name: "Logs (PHP ${{ matrix.php }}, Pimcore ${{ matrix.pimcore }}, Symfony ${{ matrix.symfony }})" - path: tests/_output/ + path: ${{ github.workspace }}/lib/test-bundle/tests/_output/ if-no-files-found: ignore diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index 1d7e0e42..0e1e1b3e 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -11,13 +11,13 @@ jobs: env: TEST_BUNDLE_NAME: "ToolboxBundle" TEST_BUNDLE_INSTALLER_CLASS: "ToolboxBundle\\Tool\\Install" - TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests" + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "1.0" + PIMCORE_CODECEPTION_VERSION: "2.0" - PIMCORE_ENVIRONMENT: test + APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test" PIMCORE_TEST_URL: "http://localhost" @@ -40,24 +40,28 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [7.4] - symfony: [^4.4] - pimcore: [^6.8] + php: [ 8.0 ] + symfony: [ ^5.3 ] + pimcore: [ ~10.1.0 ] include: - - pimcore: ^6.8 - template_tag: v2.8.0 - + - pimcore: ~10.1.0 + template_tag: v10.1.0 steps: - uses: actions/checkout@v2 + with: + path: lib/test-bundle - name: Generate Application Structure run: | git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git - mv skeleton/app . + mv skeleton/composer.json . mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . mv skeleton/var . - mv skeleton/web . - mv skeleton/src/AppBundle src + rm -r skeleton - name: Setup Pimcore Codeception Framework env: @@ -116,10 +120,10 @@ jobs: - name: Assets Install run: | - bin/console assets:install web --relative --symlink + bin/console assets:install public --relative --symlink - name: Easy Coding Standard Check continue-on-error: true run: | bin/console cache:warmup --env=test - vendor/bin/ecs check src/ToolboxBundle --config easy-coding-standard.yml \ No newline at end of file + vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src/ToolboxBundle --config ${{ github.workspace }}/lib/test-bundle/ecs.php \ No newline at end of file diff --git a/.github/workflows/php-stan.yml b/.github/workflows/php-stan.yml index 21df6b78..88587b6a 100644 --- a/.github/workflows/php-stan.yml +++ b/.github/workflows/php-stan.yml @@ -11,13 +11,13 @@ jobs: env: TEST_BUNDLE_NAME: "ToolboxBundle" TEST_BUNDLE_INSTALLER_CLASS: "ToolboxBundle\\Tool\\Install" - TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests" + TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests" TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}" PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework" - PIMCORE_CODECEPTION_VERSION: "1.0" + PIMCORE_CODECEPTION_VERSION: "2.0" - PIMCORE_ENVIRONMENT: test + APP_ENV: test PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test" PIMCORE_TEST_URL: "http://localhost" @@ -40,23 +40,28 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: matrix: - php: [7.4] - symfony: [^4.4] - pimcore: [^6.8] + php: [ 8.0 ] + symfony: [ ^5.3 ] + pimcore: [ ~10.1.0 ] include: - - pimcore: ^6.8 - template_tag: v2.8.0 + - pimcore: ~10.1.0 + template_tag: v10.1.0 steps: - uses: actions/checkout@v2 + with: + path: lib/test-bundle - name: Generate Application Structure run: | git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git - mv skeleton/app . + mv skeleton/composer.json . mv skeleton/bin . + mv skeleton/config . + mv skeleton/public . + mv skeleton/src . + mv skeleton/templates . mv skeleton/var . - mv skeleton/web . - mv skeleton/src/AppBundle src + rm -r skeleton - name: Setup Pimcore Codeception Framework env: @@ -115,9 +120,9 @@ jobs: - name: Assets Install run: | - bin/console assets:install web --relative --symlink + bin/console assets:install public --relative --symlink - name: Php Stan run: | bin/console cache:warmup --env=test - vendor/bin/phpstan analyse -c phpstan.neon -a tests/_phpstan-bootstrap.php src -l 2 \ No newline at end of file + vendor/bin/phpstan analyse -c ${{ github.workspace }}/lib/test-bundle/phpstan.neon -a ${{ github.workspace }}/lib/test-bundle/tests/_phpstan-bootstrap.php ${{ github.workspace }}/lib/test-bundle/src -l 4 \ No newline at end of file diff --git a/README.md b/README.md index ce32790b..35a72329 100644 --- a/README.md +++ b/README.md @@ -6,51 +6,40 @@ The Toolbox is a Kickstarter for your every day project. It provides some import [![Software License](https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat-square)](LICENSE.md) [![Latest Release](https://img.shields.io/packagist/v/dachcom-digital/toolbox.svg?style=flat-square)](https://packagist.org/packages/dachcom-digital/toolbox) [![Tests](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-toolbox/Codeception?style=flat-square&logo=github&label=codeception)](https://github.com/dachcom-digital/pimcore-toolbox/actions?query=workflow%3A%22Codeception%22) -[![PhpStan](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-toolbox/PHP%20Stan?style=flat-square&logo=github&label=phpstan%20level%202)](https://github.com/dachcom-digital/pimcore-toolbox/actions?query=workflow%3A%22PHP%20Stan%22) +[![PhpStan](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-toolbox/PHP%20Stan?style=flat-square&logo=github&label=phpstan%20level%204)](https://github.com/dachcom-digital/pimcore-toolbox/actions?query=workflow%3A%22PHP%20Stan%22) + +![Pimcore Toolbox](https://user-images.githubusercontent.com/700119/135613598-a9ef2c69-9a44-41cd-8542-596a0322d3da.png) -![pimcore-toolbox](https://user-images.githubusercontent.com/700119/27372271-541e6106-5664-11e7-9159-7f4aefa26cb6.png) ### Release Plan | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|-----------------------------------|----------------------------|--------------|----------------|------------| -| **3.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 16.07.2019 | Feature Branch | 3.x | -| **2.8** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 30.06.2019 | Bugfix only | 2.8 | +| **4.x** | `10.1` | `5.3` | 01.10.2021 | Feature Branch | dev-master | +| **3.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 16.07.2019 | Unsupported | 3.x | +| **2.8** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 30.06.2019 | Unsupported | 2.8 | | **1.8** | `4.0` | -- | 28.04.2017 | Unsupported | pimcore4 | ### Installation ```json "require" : { - "dachcom-digital/toolbox" : "~3.3.0" + "dachcom-digital/toolbox" : "~4.0.0" } ``` -### Installation via Extension Manager -After you have installed the Toolbox Bundle via composer, open pimcore backend and go to `Tools` => `Extension`: -- Click the green `+` Button in `Enable / Disable` row -- Click the green `+` Button in `Install/Uninstall` row +### Installation +- Execute: `$ bin/console pimcore:bundle:enable ToolboxBundle` +- Execute: `$ bin/console pimcore:bundle:install ToolboxBundle` ## Upgrading - -### Upgrading via Extension Manager -After you have updated the Toolbox Bundle via composer, open pimcore backend and go to `Tools` => `Extension`: -- Click the green `+` Button in `Update` row - -### Upgrading via CommandLine -After you have updated the Toolbox Bundle via composer: -- Execute: `$ bin/console pimcore:bundle:update ToolboxBundle` - -### Migrate via CommandLine -Does actually the same as the update command and preferred in CI-Workflow: -- Execute: `$ bin/console pimcore:migrations:migrate -b ToolboxBundle` +- Execute: `$ bin/console doctrine:migrations:version --add --all --prefix 'ToolboxBundle\Migrations'` ## What's the meaning of Toolbox? - create often used bricks in a second - extend, override toolbox bricks - add config elements via yml configuration - add consistent and beautiful config elements -- implement conditions to your config (for example: display a dropdown in config window if another checkbox has been checked) - add your custom bricks while using the toolbox config environment - removes the default `pimcore_area_*` element wrapper from each brick @@ -95,7 +84,6 @@ The Toolbox provides a lot of [ready-to-use Bricks](docs/11_ElementsOverview.md) - [Code Style](docs/1_CodeStyle.md) - [Helper Commands](docs/2_Commands.md) - [Toolbox Elements Overview](docs/11_ElementsOverview.md) -- [Conditional Logic in Configuration](docs/12_ConditionalLogic.md) - [CK-Editor Configuration](docs/13_CkEditor.md) - [Image Thumbnails Strategy](docs/14_ImageThumbnails.md) - [Configuration Context](docs/15_Context.md) diff --git a/UPGRADE.md b/UPGRADE.md index 41b2acab..f92ea41f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,52 +1,38 @@ # Upgrade Notes -![upgrade](https://user-images.githubusercontent.com/700119/31535145-3c01a264-affa-11e7-8d86-f04c33571f65.png) +## Migrating from Version 3.x to Version 4.0.0 +⚠️ If you're still on version `2.x`, you need to install `3.x` first, then [migrate](https://github.com/dachcom-digital/pimcore-toolbox/blob/3.x/UPGRADE.md) to `3.3`. After that, you're able to update to `^4.0`. + +### Global Changes +- All deprecations have been removed: + - Legacy Service Alias `toolbox.area.brick.base_brick` has been removed + - Config Node `toolbar.x`, `toolbar.y`, `toolbar.xAlign`, `toolbar.yAlign`, `toolbar.title` has been removed + - Config Node `area_block_configuration.controlsAlign`, `area_block_configuration.controlsTrigger` has added + - Config Node `disallowed_subareas`: `areas_appearance` + - Config Node `disallowed_content_snippet_areas`: `snippet_areas_appearance` + - Config Node `ToolboxBundle\Calculator\*`: `column_calculator|slide_calculator` + - ⚠️ Element `pimcore_dynamiclink` has been removed: If you're still using this element in your project, you need to [migrate](https://github.com/dachcom-digital/pimcore-toolbox/blob/3.x/docs/70_ConfigurationFlags.md#-use_dynamic_links-flag) to pimcore_link first (via TB 3.x)! +- All Folders in `views` are lowercase/dashed now (`areas/google-map`, `areas/iframe`, `areas/link-list`, `areas/paralax-container`, `areas/slide-columns`, `toolbox/bootstrap4`, ...) + +### Editable Changes +- Instead of `pimcore.area.brick` you need to use the `toolbox.area.brick` tag to register your brick. Also remove `setAreaBrickType` call from your service definition +- Always use `$info->setParam(key, value)` instead of `$info->setParams()`, otherwise you'll overwrite given parameters from the toolbox abstract brick +- Remove `{{ elementConfigBar|raw }}` in your templates +- Conditional Logic feature for editable has been removed +- Reload property in node `config.reload` has been removed. Use `config_parameter.reload_on_close: true` instead +- Custom view has been removed, TB is now using the pimcore defaults dialog box configuration + - Config Node `col_class` (In`[BRICKNAME].config_elements.[ELEMENT]` has been removed + +### Type Changes +- `StoreProviderInterface::getValues():array` needs to return an array (return type declaration added) +- `ContextResolverInterface::getCurrentContextIdentifier():?string` needs to return null|string (return type declaration added) + +### New Features +- ⚠️ [Editable Permissions](https://github.com/dachcom-digital/pimcore-toolbox/issues/161) have been added. Non-Admin Users will **NOT** be able to add editables until you enabled specific permissions for them! +- Google Maps Improved: + - Only call API if address has changed + - Better Error Reporting: Display some notes (only in editmode), if something went wrong during API call +- Simple Area Brick: Create a simple editable without creating any php classes. Read more about it [here](./docs/10_CustomBricks.md#simple-brick)) *** -After every update you should check the pimcore extension manager. -Just click the "update" button or execute the migration command to finish the bundle update. - -#### Update from Version 3.2.5 to Version 3.3.0 -- **[NEW FEATURE]**: Pimcore 6.9.0 ready -- **[IMPROVEMENT]**: use no-cookie domain for youtube videos [@ghettopro](https://github.com/dachcom-digital/pimcore-toolbox/pull/153) -- **[BUG FIX]**: Fix invalid asset video markup [@gpalmisano](https://github.com/dachcom-digital/pimcore-toolbox/pull/154) -- **[BUG FIX]**: Fix google maps locations with single quotes [#151](https://github.com/dachcom-digital/pimcore-toolbox/issues/151) -- **[BUG FIX]**: Fix wrong container parameter concatenation [#150](https://github.com/dachcom-digital/pimcore-toolbox/issues/150) - -#### Update from Version 3.2.4 to Version 3.2.5 -- **[BUG FIX]**: Fix column adjuster column_store availability check - -#### Update from Version 3.2.3 to Version 3.2.4 -- **[IMPROVEMENT]**: Assert correct order in download listing when members join is active - -#### Update from Version 3.2.2 to Version 3.2.3 -- **[NEW FEATURE]**: Pimcore 6.8.0 ready -- **[BUGFIX]**: Use `config` property on Pimcore >= 6.8 [#146](https://github.com/dachcom-digital/pimcore-toolbox/issues/146) - -#### Update from Version 3.2.1 to Version 3.2.2 -- **[NEW FEATURE]** : UIkit3 theme added [@AndiKeiser](https://github.com/dachcom-digital/pimcore-toolbox/pull/138) - -#### Update from Version 3.2.0 to Version 3.2.1 -- **[NEW FEATURE]**: Pimcore 6.6.0 ready -- **[NEW FEATURE]** : Fix rendering of multiple t-col-half elements [@christopher-siegel](https://github.com/dachcom-digital/pimcore-toolbox/pull/135) - -#### Update from Version 3.1.x to Version 3.2.0 -- **[NEW FEATURE]**: Pimcore 6.4.0 and Pimcore 6.5.0 ready -- **[NEW FEATURE]**: Store Provider added (https://github.com/dachcom-digital/pimcore-toolbox/pull/128) -- **[IMPROVEMENT]**: Better Google API Key Fetching: Introduces `toolbox.google_maps.browser_api_key` and `toolbox.google_maps.simple_api_key`. Read more about it [here](./docs/11_ElementsOverview.md#google-map) -- **[BUG FIX]**: Video Autoplay Fix (https://github.com/dachcom-digital/pimcore-toolbox/issues/129) - -#### Update from Version 3.x to Version 3.1.0 -- **[NEW FEATURE]**: Pimcore 6.3.0 ready -- **[BUG FIX]**: [Fix wrong index in bootstrap tabs for active element](https://github.com/dachcom-digital/pimcore-toolbox/issues/119) - -*** - -#### Update from Version 2.x to Version 3.0.0 -- **[NEW FEATURE]**: Pimcore 6.0.0 ready -- **[BC BREAK]**: All Controllers are registered as services now! -- **[ATTENTION]**: All `href`, `multihref` elements has been replaced by `relation`, `relations` - -*** - -Toolbox 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-toolbox/blob/2.8/UPGRADE.md +Toolbox 3.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-toolbox/blob/3.x/UPGRADE.md diff --git a/composer.json b/composer.json index c6e5373e..63063e9e 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "dachcom-digital/toolbox", "type": "pimcore-bundle", "license": "GPL-3.0-or-later", - "description": "Pimcore Project Kickstarter.", + "description": "Pimcore X Project Kickstarter", "keywords": ["pimcore", "toolbox"], "homepage": "https://github.com/dachcom-digital/pimcore-toolbox", "authors": [ @@ -21,10 +21,7 @@ "autoload-dev": { "psr-4": { "": "src/" - }, - "classmap": [ - "app/TestKernel.php" - ] + } }, "extra": { "pimcore": { @@ -34,15 +31,14 @@ } }, "require": { - "pimcore/pimcore": "^6.0" + "pimcore/pimcore": "^10.1" }, "require-dev": { - "codeception/codeception": "~2.4.0", + "codeception/codeception": "^4.1", + "codeception/module-webdriver": "^1.4", + "codeception/module-symfony": "^1.6", "phpstan/phpstan": "^0.12", "phpstan/phpstan-symfony": "^0.12", - "symplify/easy-coding-standard": "^5.4" - }, - "conflict": { - "symfony/monolog-bundle": "3.6.0" + "symplify/easy-coding-standard": "^9.0" } } diff --git a/docs/0_Usage.md b/docs/0_Usage.md index 44c76439..be34938f 100644 --- a/docs/0_Usage.md +++ b/docs/0_Usage.md @@ -27,11 +27,11 @@ Of course, you're able to extend/modify the toolbar configuration: ```yaml area_block_configuration: toolbar: - title: 'Your Toolbar Title' width: 200 - x: 10 - y: 125 buttonWidth: 200 + buttonMaxCharacters: 40 + controlsAlign: 'top' + controlsTrigger: 'hover' # define custom groups. Note: The "toolbox" group will be generated automatically. groups: @@ -50,7 +50,7 @@ Use the `snippet_areas_appearance` config node to disable bricks in specific sn ```yaml # define which elements should not appear in snippet documents toolbox: - disallowed_content_snippet_areas: + snippet_areas_appearance: snippet_c: disallowed: - parallaxContainer diff --git a/docs/10_CustomBricks.md b/docs/10_CustomBricks.md index bd264e47..eba414d6 100644 --- a/docs/10_CustomBricks.md +++ b/docs/10_CustomBricks.md @@ -1,26 +1,25 @@ # Custom Bricks -There are three simple steps to create a custom Brick with a Toolbox context. +If you want to have full control about your area brick, create a [default brick](./10_CustomBricks.md#default-brick). +If you just want to create a simple brick, create a [simple brick](./10_CustomBricks.md#simple-brick). With simple bricks you don't have to create any php classes at all but. -1. Add this configuration to `/app/config/pimcore/config.yml`: +- [Default Brick](./10_CustomBricks.md#default-brick) +- [Simple Brick](./10_CustomBricks.md#simple-brick) +- [Bricks without Editables (No Config Dialog)](./10_CustomBricks.md#bricks-without-editables-no-config-dialog) +- [Bricks with tabbed config dialog](./10_CustomBricks.md#tabbed-config-dialog) -> **Tip:** Add this to a separate config file. +## Default Brick + +There are three simple steps to create a custom brick: + +1. Add this configuration to `/config/packages/toolbox.yml`: -### Code Style -> **Important!** Don't use dashes in your area name! Always use Camel- or Snake Case! -> Example: Instead of `my-brick` you need to define your custom area as `my_brick` or `myBrick`. -> Since it's symfony standard, we recommend to use the underscore strategy! - ```yaml -# It's always a good idea to add your brick as a service. services: - AppBundle\Document\Areabrick\MyBrick\MyBrick: + App\Document\Areabrick\MyBrick\MyBrick: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick - calls: - # set the brick type to external - - [setAreaBrickType, ['external']] tags: - - { name: pimcore.area.brick, id: my_brick } + - { name: toolbox.area.brick, id: my_brick } toolbox: custom_areas: @@ -30,82 +29,186 @@ toolbox: title1: type: input title: That's a Title - col_class: t-col-half description: Lorem Ipsum # default config for input - # see: https://www.pimcore.org/docs/5.0.0/Documents/Editables/Input.html#page_Configuration + # see: https://pimcore.com/docs/pimcore/10.0/Development_Documentation/Documents/Editables/Input.html#page_Configuration config: ~ title2: type: input title: That's also a Title - col_class: t-col-half description: Lorem Ipsum config: ~ ``` -2. Add the Area Class to `AppBundle/Document/Areabrick/MyBrick/MyBrick.php`: +2. Add the area class to `App/Document/Areabrick/MyBrick/MyBrick.php`: ```php getTemplateDirectoryName(), $this->getTemplateSuffix()); + } + + public function getName():string { return 'My Brick'; } - public function getDescription() + public function getDescription():string { return 'My Brick'; } - public function getIcon() + public function getIcon():string { - return '/static/areas/my_brick/icon.svg'; + return '/static/areas/my-brick/icon.svg'; } } ``` -3. Add the view to `/app/Resources/views/Areas/my_brick/view.html.twig`: +3. Add the view to `/templates/areas/my-brick/view.html.twig`: ```twig -{{ elementConfigBar|raw }} -
-

{{ pimcore_input('title1').getData() }}

-

{{ pimcore_input('title2').getData() }}

+
+

{{ pimcore_input('title1').data }}

+

{{ pimcore_input('title2').data }}

``` -### Adding Bricks from Bundles +That's it. If you want to refresh the permission table you also need to execute the `bin/console cache:clear` command. -If you want to add bricks from other bundles, eg. `src/DemoBundle` and you want to load the view from the bundle directory itself, then you have to override the template location: +*** -```php - + {{ pimcore_input('title').data }} +
+``` + +That's it. If you want to refresh the permission table you also need to execute the `bin/console cache:clear` command. + +*** + +## Bricks without Editables (No Config Dialog) +Sometimes you need a real simple area brick without any configuration for editors. +To do so, you only need to change the parent class: + +```yaml +services: + # for default bricks + App\Document\Areabrick\MyBrick\MyBrick: + parent: ToolboxBundle\Document\Areabrick\AbstractBaseAreabrick + tags: + - { name: toolbox.area.brick, id: my_brick_without_configurable_options } + + # for simple bricks + app.brick.my_simple_brick_without_configurable_options: + parent: ToolboxBundle\Document\Areabrick\AbstractBaseAreabrick + tags: + - { name: toolbox.area.simple_brick, id: my_simple_brick_without_configurable_options, title: 'My Simple Brick (Without configurable Options)' } +``` + +*** + +### Tabbed Config Dialog +![image](https://user-images.githubusercontent.com/700119/135585193-0a3d37df-5492-4b41-b2b2-a97220f53986.png) + +To use tabs in your config dialog, you have to define them via the tab config node: + +```yaml +toolbox: + custom_areas: + dummy_brick: + tabs: # <-- define tabs here first! + tab1: 'Tab 1' + tab2: 'Tab 2' + config_elements: + title1: + type: input + title: That's Title I + description: Lorem Ipsum + tab: tab1 # <-- add to tab1 + config: ~ + title2: + type: input + title: That's Title II + description: Lorem Ipsum + tab: tab1 # <-- add to tab1 + config: ~ + title3: + type: input + title: That's Titel III + description: Lorem Ipsum + tab: tab2 # <-- add to tab2 + config: ~ +``` \ No newline at end of file diff --git a/docs/11_ElementsOverview.md b/docs/11_ElementsOverview.md index 4859e902..0fde315d 100644 --- a/docs/11_ElementsOverview.md +++ b/docs/11_ElementsOverview.md @@ -266,10 +266,10 @@ toolbox: simple_api_key: false ``` ### jQuery Plugin -There is also a jquery plugin for the google maps element. Read more about it [here](80_Javascript.md#google-maps-extension) +There is also a jquery plugin for the google maps element. Read more about it [here](80_Javascript.md) ### Route Link Renderer -There is a macro in `views/Macro/mapLink.html.twig` (used in `views/Theme/GoogleMap/infoWindow.html.twig`) which will render the map route link: +There is a macro in `views/Macro/mapLink.html.twig` (used in `views/[THEME NAME]/google-map/info-window.html.twig`) which will render the map route link: ```twig {# default #} @@ -311,7 +311,7 @@ Create an iFrame field. | `additional_classes` | select | Add custom classes | - | see [section additional classes](#additional-classes) | ### jQuery Plugin -There is also a jquery plugin for the iFrame element. Read more about it [here](80_Javascript.md#iframe-extension). +There is also a jquery plugin for the iFrame element. Read more about it [here](80_Javascript.md). We can't provide any out-of-the-box solution for changing the iframe height dynamically (cross-domain policy), so you need to take care about that by yourself. Possible Solutions to mastering dynamic iFrame heights: @@ -522,7 +522,7 @@ toolbox: ``` ### jQuery Plugin -There is also a jquery plugin for the video element. Read more about it [here](80_Javascript.md#video-extension) +There is also a jquery plugin for the video element. Read more about it [here](80_Javascript.md) # Element Config Field Overview In short, you're able to use all the [pimcore editables](https://www.pimcore.org/docs/5.0.0/Documents/Editables/index.html). diff --git a/docs/12_ConditionalLogic.md b/docs/12_ConditionalLogic.md deleted file mode 100644 index a98adff4..00000000 --- a/docs/12_ConditionalLogic.md +++ /dev/null @@ -1,34 +0,0 @@ -# Conditional Logic - -Define some conditions to display/hide config elements. - -Append the condition field. -In this example, we only show the field `layout` if `type` selected value is "direct". - -> condition changes need a reload of the edit window. - -```yaml -toolbox: - areas: - teaser: - config_elements: - type: - type: select - title: 'Type' - config: - name: type - store: - direct: 'Direct' - snippet: 'Snippet' - default: direct - - layout: - type: select - title: 'Layout' - conditions: - - type: direct - config: - store: - default: 'Default' - default: default -``` diff --git a/docs/13_CkEditor.md b/docs/13_CkEditor.md index d6b5af83..1699ce93 100644 --- a/docs/13_CkEditor.md +++ b/docs/13_CkEditor.md @@ -117,4 +117,4 @@ Toolbox provides some CK-Editor Plugins: ![ck-editor-google-opt-out](https://user-images.githubusercontent.com/700119/37820009-9dd6a418-2e7f-11e8-94b4-99c7a001a3a9.png) Add a link to allow user to disable google analytics tracking. -There is also a [frontend Javascript Plugin](./80_Javascript.md#google-opt-out-link-extension). +There is also a [frontend Javascript Plugin](./80_Javascript.md). diff --git a/docs/15_Context.md b/docs/15_Context.md index 15e0e4c6..a2c0ba3a 100644 --- a/docs/15_Context.md +++ b/docs/15_Context.md @@ -69,7 +69,7 @@ If the resolver returns `null` the main configuration will be used. ```yml toolbox: - context_resolver: 'AppBundle\Services\ToolboxBundle\ContextResolver' + context_resolver: 'App\Services\ToolboxBundle\ContextResolver' ``` ### Create Context Resolver Class @@ -77,7 +77,7 @@ toolbox: ```php documentResolver = $documentResolver; } - public function getCurrentContextIdentifier() + public function getCurrentContextIdentifier(): ?string { - $request = $this->requestStack->getMasterRequest(); + $request = $this->requestStack->getMainRequest(); $site = null; diff --git a/docs/16_EditableStoreProvider.md b/docs/16_EditableStoreProvider.md index c6c8adfe..4006fb35 100644 --- a/docs/16_EditableStoreProvider.md +++ b/docs/16_EditableStoreProvider.md @@ -38,7 +38,7 @@ Now we need to register our new service: ```yml # app/config.yml services: - AppBundle\Toolbox\MyStoreProvider: + App\Toolbox\MyStoreProvider: tags: - { name: toolbox.editable.store_provider, identifier: 'my_awesome_store_provider' } @@ -49,16 +49,13 @@ services: ```php 'My Value', diff --git a/docs/20_DynamicLinkElement.md b/docs/20_DynamicLinkElement.md index 31b270c4..b105c60f 100644 --- a/docs/20_DynamicLinkElement.md +++ b/docs/20_DynamicLinkElement.md @@ -22,7 +22,7 @@ services: autowire: true public: false - AppBundle\EventListener\ObjectUrlListener: + App\EventListener\ObjectUrlListener: tags: - { name: kernel.event_listener, event: toolbox.dynamiclink.object.url, method: checkUrl } ``` @@ -35,7 +35,7 @@ You also need to setup a static route (in this case the `news_detail` route). ```php Note: This is only necessary if want to update from TB <= `2.1.2` and there are offset columns (for example `column_o1_6_o1_6`) in your configuration to migrate! -> if you don't have any offset columns, just skip this. - -```yaml -toolbox: - flags: - strict_column_counter: true -``` - -### Explanation -In Toolbox <= `2.1.2` the column calculator counts every element from the config. For example: `column_6_6` creates two column items: `column_0` and `column_1`. -If you're going to switch the column config to `column_o1_6_o1_6` the calculator will also create two columns but with different indexes: `column_1` and `column_3`. -As you can see, this isn't quite right. After switching the column config, the existing data from `column_0` and `column_1` is gone. - -### Solution -In Toolbox >= `2.2` the offset columns get skipped during calculation. With that your data stays with the column change. -**Important**: You only need to add this flag if you're using some offset columns in your toolbox configuration. If you're not using offset columns, just update and ignore this flag. - *** -## 🚩 use_dynamic_links flag -The dynamic link flag is set to `false` by default. If you want to change it, you need to add this to your app config: - -```yaml -toolbox: - flags: - use_dynamic_links: true -``` - -### Explanation -In Pimcore 4 there was no way to add object paths to the link tag so we implemented the dynamic link element. -Now, with Pimcore 5 we're able to add dynamic object links via the [linkGenerator service](https://pimcore.com/docs/5.x/Development_Documentation/Objects/Object_Classes/Class_Settings/Link_Generator.html). -Since Toolbox `2.5.0` we're using the `pimcore_link` element instead of `pimcore_dynamiclink`. - -### Migration -The Migration is very easy: - -1. If you have added the `use_dynamic_links` flag, remove it since it's disabled by default anyway -2. Check your templates for `pimcore_dynamiclink` and replace it with `pimcore_link` -3. Remove all your event listeners with tag `toolbox.dynamiclink.object.url` -3. Run the migration script: `$ bin/console toolbox:migrate-dynamic-link` -4. Implement a `LinkGenerator` service for each object type like described in the pimcore docs (you're might be able to adapt some code from step 3). -4. Check your frontend and backend, all your links should be transformed without loosing any data \ No newline at end of file +Currently, no configuration flags available. +> If you're updating from 2.x/3.x to 4.x please check out old configuration flags (https://github.com/dachcom-digital/pimcore-toolbox/blob/3.x/docs/70_ConfigurationFlags.md) first! diff --git a/docs/80_Javascript.md b/docs/80_Javascript.md index dc0aec7b..2fd2fb64 100644 --- a/docs/80_Javascript.md +++ b/docs/80_Javascript.md @@ -1,282 +1,14 @@ # Javascript Plugins -We're providing some helpful Javascript Plugins to simplify your daily work with the ToolboxBundle. -Of course it's up to you to copy those files into your project and modify them as required. -> Note: Make sure that jQuery has been initialized, before you load one of those toolbox extensions. +## Jquery +All jQuery Extensions are available on npmjs.com via [jquery-pimcore-toolbox](https://www.npmjs.com/package/jquery-pimcore-toolbox). -## Overview -- [Core Plugin](#core-plugin) -- [Google Maps Extension](#google-maps-extension) -- [Video Extension](#video-extension) -- [iFrame Extension](#iframe-extension) -- [Google Opt-Out Extension](#google-opt-out-link-extension) - -## Core Plugin -This Plugin will automatically register all toolbox extensions: - -### Enable Plugin - -```html - -``` - -```javascript -$(function () { - $.toolboxCore({}); -}); -``` - -### Extended Usage -```javascript -$(function () { - $.toolboxCore({ - editmode: false, - theme: 'bootstrap4', - googleMapsHandler: { - enabled: true, - selector: '.toolbox-googlemap', - config: { - centerMapOnResize: true - } - }, - videoHandler: { - enabled: true, - config: { - videoIdExtractor: { - custom: function (videoId) { - console.log(videoId); - return videoId; - } - }, - apiParameter: { - youtube: { - rel: 0 //disable related videos - }, - vimeo: {} - } - } - }, - iframeHandler: { - enabled: true, - config: { - } - } - }); -}); -``` - -## Google Maps Extension -This Extension will enable the google maps rendering. -If you're using the `toolboxCore` instance, you only need to include the javascript file: - -### Enable Extension -```html - -``` - -Single Call (after new elements have been dynamically added for example) -```javascript -$(function () { - $('.toolbox-googlemap').toolboxGoogleMaps({}); -}); -``` - -### Extended Usage -```javascript -$(function () { - $.toolboxGoogleMaps({ - centerMapOnResize: true, - theme: 'bootstrap4' - }); -}); -``` - -### Options --- - -## Video Extension -This Extension will enable the video rendering. -If you're using the `toolboxCore` instance, you only need to include the javascript file: - -### Enable Extension -```html - -``` - -Single Call (after new elements have been dynamically added for example) - -```javascript -$(function () { - $('.toolbox-video').toolboxVideo({}); -}); -``` - -### Extended Usage -```javascript -$(function () { - $.toolboxVideo({ - theme: 'bootstrap4', - videoIdExtractor: { - custom: function (videoId) { - console.log(videoId); - return videoId; - } - }, - resources: { - youtube: 'https://www.youtube.com/iframe_api', - vimeo: 'https://player.vimeo.com/api/player.js', - }, - apiParameter: { - youtube: { - rel: 0 //disable related videos - }, - vimeo: {} - } - }); -}); -``` - -### Video Extended I: Open Video in a Light Box -If you have selected the Light Box option, you need to take care about the video by yourself: - -```javascript -$('.toolbox-video') - .on('toolbox.video.youtube.lightbox', function (ev, params) { - // implement your own openVideo() function somewhere. - openVideo('https://youtube.com/watch?v=' + params.videoId); - }) - .on('toolbox.video.vimeo.lightbox', function (ev, params) { - // implement your own openVideo() function somewhere. - openVideo('https://vimeo.com/' + params.videoId); - }); -``` - - -### Video Extended II: Use Pimcore Assets as Video -If you're using pimcore video assets, you need to provide your own player api. -Pimcore will render a default html5 video tag in frontend. - -If you want to add the autoplay function, you need to add a play and pause event: - -```javascript -$('.toolbox-video[data-type="asset"]') - .on('toolbox.video.asset.play', function (ev, params) { - // hit the play button of your html5 video. - // this is also the place where to trigger the play state for your custom framework (video.js for example) - console.log($(this).find('video')) - $(this).find('video').get(0).play(); - }) - .on('toolbox.video.asset.pause', function (ev, params) { - // hit the pause button of your html5 video. - $(this).find('video').get(0).pause(); - }); -``` - -### Video Extended III: Use a custom player engine -If you have a different engine, you need to do some further work. - -#### Add some markup -```twig -
-
-
-
-
-
-
-``` - -#### Initialize Player -```javascript -$(function () { - $.toolboxVideo({ - theme: 'bootstrap4', - videoIdExtractor: { - custom: function (videoId) { - // parse your video id - console.log(videoId); - return videoId; - } - } - }); -}); +### Installation +```bash +npm i jquery-pimcore-toolbox ``` -### Add a Setup Listener -``` -$('.toolbox-video[data-type="custom"]') - .on('toolbox.video.custom.setup', function (ev, videoClass) { - // setup your element - console.log(videoClass); - }); -``` - -## iFrame Extension -This Extension will enable the iFrame rendering. -We can't provide any out-of-the-box solution for changing the iframe height dynamically (cross-domain policy), so you need to take care about that by yourself. - -If you're using the `toolboxCore` instance, you only need to include the javascript file: - -### Enable Extension -```html - -``` - -### Single Call -```javascript -$(function () { - $('.toolbox-iframe').toolboxIframe({}); -}); -``` +Read more about installation and usage on [github](https://github.com/dachcom-digital/jquery-pimcore-toolbox). -### Events -There are two events available: - -#### Event toolbox.iframe.load - -```javascript -$('.toolbox-iframe').on('toolbox.iframe.load', function(ev) { - console.log($(this), ev); -}) -``` - -#### Event toolbox.iframe.loaded - -```javascript -$('.toolbox-iframe').on('toolbox.iframe.loaded', function(ev) { - console.log($(this), ev); - // use the iframe-resizer plugin for example - // @see https://github.com/davidjbradshaw/iframe-resizer - // $(this).find('iframe').iFrameResize( [{options}] ); -}) -``` - -## Google Opt-Out Link Extension -This Extension searches for google opt-out links. -By clicking on a link with the class `a.google-opt-out-link` a cookie will be stored to prevent future analytic tracking. - -If you're using the `toolboxCore` instance, you only need to include the javascript file: - -### Enable Extension -```html - -``` - -### Single Call -```javascript -$(function () { - $('a.google-opt-out-link').toolboxGoogleOptOutLink({}); -}); -``` - -### Extended Usage -```javascript -$(function () { - $('a.google-opt-out-link').toolboxGoogleOptOutLink({ - notify: function(message) { - // implement your message style here - console.log(message); - } - }); -}); -``` +## Alpine.js +TBD \ No newline at end of file diff --git a/easy-coding-standard.yml b/easy-coding-standard.yml deleted file mode 100644 index 26db9c00..00000000 --- a/easy-coding-standard.yml +++ /dev/null @@ -1,108 +0,0 @@ -imports: - - { resource: '%vendor_dir%/symplify/easy-coding-standard/config/psr2.yml' } - -services: - PhpCsFixer\Fixer\Basic\BracesFixer: - allow_single_line_closure: true - PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer: ~ - PhpCsFixer\Fixer\Operator\ConcatSpaceFixer: - spacing: one - PhpCsFixer\Fixer\Operator\NewWithBracesFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer: - tags: - - method - - param - - property - - return - - throws - - type - - var - PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer: - align_double_arrow: true - PhpCsFixer\Fixer\Operator\IncrementStyleFixer: - style: post - PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: ~ - PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer: ~ - PhpCsFixer\Fixer\CastNotation\CastSpacesFixer: ~ - PhpCsFixer\Fixer\LanguageConstruct\DeclareEqualNormalizeFixer: ~ - PhpCsFixer\Fixer\FunctionNotation\FunctionTypehintSpaceFixer: ~ - PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer: - comment_types: - - hash - PhpCsFixer\Fixer\ControlStructure\IncludeFixer: ~ - PhpCsFixer\Fixer\CastNotation\LowercaseCastFixer: ~ - PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer: - elements: - - method - PhpCsFixer\Fixer\Casing\NativeFunctionCasingFixer: ~ - PhpCsFixer\Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer: ~ - PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer: ~ - PhpCsFixer\Fixer\Comment\NoEmptyCommentFixer: ~ - PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocSeparationFixer: ~ - PhpCsFixer\Fixer\Semicolon\NoEmptyStatementFixer: ~ - PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer: ~ - PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer: - tokens: - - curly_brace_block - - extra - - parenthesis_brace_block - - square_brace_block - - throw - - use - PhpCsFixer\Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer: ~ - PhpCsFixer\Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer: ~ - PhpCsFixer\Fixer\CastNotation\NoShortBoolCastFixer: ~ - PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer: ~ - PhpCsFixer\Fixer\Whitespace\NoSpacesAroundOffsetFixer: ~ - PhpCsFixer\Fixer\ControlStructure\NoTrailingCommaInListCallFixer: ~ - PhpCsFixer\Fixer\ControlStructure\NoUnneededControlParenthesesFixer: ~ - PhpCsFixer\Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer: ~ - PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer: ~ - PhpCsFixer\Fixer\ArrayNotation\NormalizeIndexBraceFixer: ~ - PhpCsFixer\Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocInlineTagFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocNoAccessFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocNoEmptyReturnFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocScalarFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocTrimFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocVarWithoutNameFixer: ~ - PhpCsFixer\Fixer\FunctionNotation\ReturnTypeDeclarationFixer: ~ - PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer: ~ - PhpCsFixer\Fixer\CastNotation\ShortScalarCastFixer: ~ - PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer: ~ - PhpCsFixer\Fixer\Semicolon\SpaceAfterSemicolonFixer: ~ - PhpCsFixer\Fixer\Operator\StandardizeNotEqualsFixer: ~ - PhpCsFixer\Fixer\Operator\TernaryOperatorSpacesFixer: ~ - PhpCsFixer\Fixer\ArrayNotation\TrimArraySpacesFixer: ~ - PhpCsFixer\Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer: ~ - PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer: - singleLine: true - PhpCsFixer\Fixer\Casing\MagicConstantCasingFixer: ~ - PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer: ~ - PhpCsFixer\Fixer\Alias\NoMixedEchoPrintFixer: - use: echo - PhpCsFixer\Fixer\Import\NoLeadingImportSlashFixer: ~ - PhpCsFixer\Fixer\Import\NoUnusedImportsFixer: ~ - PhpCsFixer\Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer: ~ - PhpCsFixer\Fixer\Phpdoc\PhpdocNoAliasTagFixer: ~ - PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer: ~ - PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer: ~ - PhpCsFixer\Fixer\ClassNotation\SingleClassElementPerStatementFixer: ~ - - # new since PHP-CS-Fixer 2.6 - PhpCsFixer\Fixer\ControlStructure\NoUnneededCurlyBracesFixer: ~ - PhpCsFixer\Fixer\ClassNotation\NoUnneededFinalMethodFixer: ~ - PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer: ~ - - # new since 2.11 - PhpCsFixer\Fixer\Operator\StandardizeIncrementFixer: ~ diff --git a/ecs.php b/ecs.php new file mode 100644 index 00000000..b5e05a8e --- /dev/null +++ b/ecs.php @@ -0,0 +1,162 @@ +parameters(); + $parameters->set(Option::SETS, [SetList::CLEAN_CODE, SetList::PSR_12]); + + $services = $containerConfigurator->services(); + + $services->set(Fixer\Basic\BracesFixer::class) + ->call('configure', [ + [ + 'allow_single_line_closure' => true, + ] + ]); + + $services->set(Fixer\PhpTag\BlankLineAfterOpeningTagFixer::class); + + $services->set(Fixer\Operator\ConcatSpaceFixer::class) + ->call('configure', [ + [ + 'spacing' => 'one', + ] + ]); + + $services->set(Fixer\Operator\NewWithBracesFixer::class); + + $services->set(Fixer\Phpdoc\PhpdocAlignFixer::class) + ->call('configure', [ + [ + 'tags' => ['method', 'param', 'property', 'return', 'throws', 'type', 'var'], + ] + ]); + + $services->set(Fixer\Operator\BinaryOperatorSpacesFixer::class) + ->call('configure', [ + [ + 'operators' => [ + '=' => 'single_space', + '=>' => 'align', + ] + ] + ]); + $services->set(Fixer\Operator\IncrementStyleFixer::class) + ->call('configure', [ + [ + 'style' => 'post', + ] + ]); + + $services->set(Fixer\Operator\UnaryOperatorSpacesFixer::class); + $services->set(Fixer\Whitespace\BlankLineBeforeStatementFixer::class); + $services->set(Fixer\CastNotation\CastSpacesFixer::class); + $services->set(Fixer\LanguageConstruct\DeclareEqualNormalizeFixer::class); + $services->set(Fixer\FunctionNotation\FunctionTypehintSpaceFixer::class); + $services->set(Fixer\Comment\SingleLineCommentStyleFixer::class) + ->call('configure', [ + [ + 'comment_types' => ['hash'], + ] + ]); + + $services->set(Fixer\ControlStructure\IncludeFixer::class); + $services->set(Fixer\CastNotation\LowercaseCastFixer::class); + $services->set(Fixer\ClassNotation\ClassAttributesSeparationFixer::class) + ->call('configure', [ + [ + 'elements' => [ + 'const' => 'none', + 'method' => 'one', + 'property' => 'none', + 'trait_import' => 'none' + ], + ] + ]); + + $services->set(Fixer\Casing\NativeFunctionCasingFixer::class); + $services->set(Fixer\ClassNotation\NoBlankLinesAfterClassOpeningFixer::class); + $services->set(Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer::class); + $services->set(Fixer\Comment\NoEmptyCommentFixer::class); + $services->set(Fixer\Phpdoc\NoEmptyPhpdocFixer::class); + $services->set(Fixer\Phpdoc\PhpdocSeparationFixer::class); + $services->set(Fixer\Semicolon\NoEmptyStatementFixer::class); + $services->set(Fixer\Whitespace\ArrayIndentationFixer::class); + $services->set(Fixer\Whitespace\NoExtraBlankLinesFixer::class) + ->call('configure', [ + [ + 'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'], + ] + ]); + + $services->set(Fixer\NamespaceNotation\NoLeadingNamespaceWhitespaceFixer::class); + $services->set(Fixer\ArrayNotation\NoMultilineWhitespaceAroundDoubleArrowFixer::class); + $services->set(Fixer\CastNotation\NoShortBoolCastFixer::class); + $services->set(Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer::class); + $services->set(Fixer\Whitespace\NoSpacesAroundOffsetFixer::class); + $services->set(Fixer\ControlStructure\NoTrailingCommaInListCallFixer::class); + $services->set(Fixer\ControlStructure\NoUnneededControlParenthesesFixer::class); + $services->set(Fixer\ArrayNotation\NoWhitespaceBeforeCommaInArrayFixer::class); + $services->set(Fixer\Whitespace\NoWhitespaceInBlankLineFixer::class); + $services->set(Fixer\ArrayNotation\NormalizeIndexBraceFixer::class); + $services->set(Fixer\Operator\ObjectOperatorWithoutWhitespaceFixer::class); + $services->set(Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer::class); + $services->set(Fixer\Phpdoc\PhpdocIndentFixer::class); + $services->set(Fixer\Phpdoc\PhpdocInlineTagFixer::class); + $services->set(Fixer\Phpdoc\PhpdocNoAccessFixer::class); + $services->set(Fixer\Phpdoc\PhpdocNoEmptyReturnFixer::class); + $services->set(Fixer\Phpdoc\PhpdocNoPackageFixer::class); + $services->set(Fixer\Phpdoc\PhpdocNoUselessInheritdocFixer::class); + $services->set(Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer::class); + $services->set(Fixer\Phpdoc\PhpdocScalarFixer::class); + $services->set(Fixer\Phpdoc\PhpdocSingleLineVarSpacingFixer::class); + $services->set(Fixer\Phpdoc\PhpdocSummaryFixer::class); + $services->set(Fixer\Phpdoc\PhpdocToCommentFixer::class); + $services->set(Fixer\Phpdoc\PhpdocTrimFixer::class); + $services->set(Fixer\Phpdoc\PhpdocTypesFixer::class); + $services->set(Fixer\Phpdoc\PhpdocVarWithoutNameFixer::class); + $services->set(Fixer\FunctionNotation\ReturnTypeDeclarationFixer::class); + $services->set(Fixer\ClassNotation\SelfAccessorFixer::class); + $services->set(Fixer\CastNotation\ShortScalarCastFixer::class); + $services->set(Fixer\StringNotation\SingleQuoteFixer::class); + $services->set(Fixer\Semicolon\SpaceAfterSemicolonFixer::class); + $services->set(Fixer\Operator\StandardizeNotEqualsFixer::class); + $services->set(Fixer\Operator\TernaryOperatorSpacesFixer::class); + $services->set(Fixer\ArrayNotation\TrimArraySpacesFixer::class); + $services->set(Fixer\ArrayNotation\WhitespaceAfterCommaInArrayFixer::class); + + $services->set(Fixer\ClassNotation\ClassDefinitionFixer::class) + ->call('configure', [ + [ + 'single_line' => true, + ] + ]); + + $services->set(Fixer\Casing\MagicConstantCasingFixer::class); + $services->set(Fixer\FunctionNotation\MethodArgumentSpaceFixer::class); + $services->set(Fixer\Alias\NoMixedEchoPrintFixer::class) + ->call('configure', [ + [ + 'use' => 'echo', + ] + ]); + + $services->set(Fixer\Import\NoLeadingImportSlashFixer::class); + $services->set(Fixer\PhpUnit\PhpUnitFqcnAnnotationFixer::class); + $services->set(Fixer\Phpdoc\PhpdocNoAliasTagFixer::class); + $services->set(Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer::class); + $services->set(Fixer\ClassNotation\SingleClassElementPerStatementFixer::class); + + # new since PHP-CS-Fixer 2.6 + $services->set(Fixer\ClassNotation\NoUnneededFinalMethodFixer::class); + $services->set(Fixer\Semicolon\SemicolonAfterInstructionFixer::class); + + # new since 2.11 + $services->set(Fixer\Operator\StandardizeIncrementFixer::class); +}; \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon index 4471fb71..59e4ae61 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,14 +3,10 @@ includes: parameters: reportUnmatchedIgnoredErrors: false symfony: - container_xml_path: %currentWorkingDirectory%/var/cache/test/appTestKernelTestDebugContainer.xml + container_xml_path: %currentWorkingDirectory%/var/cache/test/TestKernelTestDebugContainer.xml + constant_hassers: false ignoreErrors: - # There is no global constants definition file we could include, ignore it: - - '#Constant PIMCORE_[A-Z\\_]+ not found\.#' - # Symfony DI (remove this line with symfony 4.2): - - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#' - # Symfony DI (remove this line after symfony 4 support only): - - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\.#' + - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::end\(\)\.#' # Bundle dependency calls we need to ignore: - '#Class MembersBundle\\Manager\\RestrictionManager not found\.#' - '#Class MembersBundle\\Security\\RestrictionUri not found\.#' diff --git a/src/ToolboxBundle/Builder/BrickConfigBuilder.php b/src/ToolboxBundle/Builder/BrickConfigBuilder.php index 92ba3415..9e301944 100644 --- a/src/ToolboxBundle/Builder/BrickConfigBuilder.php +++ b/src/ToolboxBundle/Builder/BrickConfigBuilder.php @@ -2,459 +2,203 @@ namespace ToolboxBundle\Builder; -use Pimcore\Model\Document\Tag\Area\Info; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Templating\Renderer\TagRenderer; +use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration; +use Pimcore\Model\Document\Editable\Area\Info; +use Pimcore\Model\Document\Editable\Checkbox; use Pimcore\Translation\Translator; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use ToolboxBundle\Registry\StoreProviderRegistryInterface; +use Twig\Environment; -class BrickConfigBuilder +class BrickConfigBuilder implements BrickConfigBuilderInterface { - /** - * @var Translator - */ - protected $translator; - - /** - * @var TagRenderer - */ - protected $tagRenderer; - - /** - * @var EngineInterface - */ - protected $templating; - - /** - * @var string - */ - protected $documentEditableId = ''; - - /** - * @var string - */ - protected $documentEditableName = ''; - - /** - * @var \Pimcore\Model\Document\Tag\Area\Info null - */ - protected $info = null; - - /** - * @var array - */ - protected $themeOptions = []; - - /** - * @var array - */ - protected $configElements = []; - - /** - * @var array - */ - protected $configParameter = []; - - /** - * @var bool - */ - protected $hasAdditionalClassStore = false; - - /** - * @var null|string - */ - protected $configWindowSize = null; - - /** - * @var StoreProviderRegistryInterface - */ - protected $storeProvider = null; - - /** - * @param Translator $translator - * @param TagRenderer $tagRenderer - * @param EngineInterface $templating - * @param StoreProviderRegistryInterface $storeProvider - */ + protected Translator $translator; + protected Environment $templating; + protected StoreProviderRegistryInterface $storeProvider; + public function __construct( Translator $translator, - TagRenderer $tagRenderer, - EngineInterface $templating, + Environment $templating, StoreProviderRegistryInterface $storeProvider ) { $this->translator = $translator; - $this->tagRenderer = $tagRenderer; $this->templating = $templating; $this->storeProvider = $storeProvider; } - /** - * @param string $documentEditableId - * @param string $documentEditableName - * @param Info $info - * @param array $configNode - * @param array $themeOptions - * - * @return string - * - * @throws \Exception - */ - public function buildElementConfig($documentEditableId, $documentEditableName, Info $info, $configNode = [], $themeOptions = []) + public function buildDialogBoxConfiguration(?Info $info, string $brickId, array $configNode = [], array $themeOptions = []): EditableDialogBoxConfiguration { - $fieldSetArgs = $this->buildElementConfigArguments($documentEditableId, $documentEditableName, $info, $configNode, $themeOptions); + $config = new EditableDialogBoxConfiguration(); - if (empty($fieldSetArgs)) { - return ''; - } + $configParameter = $configNode['config_parameter'] ?? []; + $configElements = $configNode['config_elements'] ?? []; + $tabs = $configNode['tabs'] ?? []; - return $this->templating->render('@Toolbox/Admin/AreaConfig/fieldSet.html.twig', $fieldSetArgs); - } + $configWindowSize = $this->getConfigWindowSize($configParameter); - /** - * @param string $documentEditableId - * @param string $documentEditableName - * @param Info $info - * @param array $configNode - * @param array $themeOptions - * - * @return array - * - * @throws \Exception - */ - public function buildElementConfigArguments($documentEditableId, $documentEditableName, Info $info, $configNode = [], $themeOptions = []) - { - $this->reset(); + $config->setHeight($configWindowSize['height']); + $config->setWidth($configWindowSize['width']); - if ($info->getView()->get('editmode') === false) { - return []; - } + $config->setReloadOnClose($configParameter['reload_on_close'] ?? false); - $this->documentEditableId = $documentEditableId; - $this->documentEditableName = $documentEditableName; - $this->info = $info; - $this->themeOptions = $themeOptions; - $this->configElements = isset($configNode['config_elements']) ? $configNode['config_elements'] : []; - $this->configParameter = isset($configNode['config_parameter']) ? $configNode['config_parameter'] : []; - $this->configWindowSize = $this->getConfigWindowSize(); + $items = $this->parseConfigElements($info, $brickId, $themeOptions, $configElements, $tabs); - $defaultFields = []; - $acFields = []; - $configElements = $this->parseConfigElements(); + $config->setItems($items); - foreach ($configElements as $configElement) { - if ($configElement['additional_config']['additional_classes_element'] === true) { - $acFields[] = $configElement; - } else { - $defaultFields[] = $configElement; - } - } - - $fieldSetArgs = [ - 'config_elements' => array_merge($defaultFields, $acFields), - 'document_editable_name' => $this->translator->trans($this->documentEditableName, [], 'admin'), - 'window_size' => $this->configWindowSize, - 'document' => $info->getDocument(), - 'brick_id' => $info->id - ]; - - return $fieldSetArgs; + return $config; } - /** - * @return null|string - */ - private function getConfigWindowSize() + private function getConfigWindowSize(array $configParameter): array { - $configWindowSize = isset($this->configParameter['window_size']) ? (string) $this->configParameter['window_size'] : null; + $configWindowSize = $configParameter['window_size'] ?? null; - return !is_null($configWindowSize) ? $configWindowSize : 'small'; - } + if (is_string($configWindowSize)) { + return [ + 'width' => $configWindowSize === 'small' ? 600 : 800, + 'height' => $configWindowSize === 'small' ? 400 : 600, + ]; + } - /** - * @param string $type - * - * @return bool - */ - private function needStore($type) - { - return in_array($type, ['select', 'multiselect', 'additionalClasses', 'additionalClassesChained']); + if (is_array($configWindowSize)) { + return [ + 'width' => $configWindowSize['width'], + 'height' => $configWindowSize['height'], + ]; + } + + return [ + 'width' => 550, + 'height' => 370, + ]; } - /** - * @param array $parsedConfig - * - * @return bool - */ - private function hasValidStore($parsedConfig) + private function parseConfigElements(?Info $info, string $brickId, array $themeOptions, array $configElements, array $tabs): array { - if (isset($parsedConfig['store']) && is_array($parsedConfig['store']) && count($parsedConfig['store']) > 0) { - return true; - } + $editableNodes = []; - if (isset($parsedConfig['store_provider']) && $this->storeProvider->has($parsedConfig['store_provider'])) { - return true; + if (empty($configElements)) { + return $editableNodes; } - return false; - } + $acStoreProcessed = false; - /** - * @param string $type - * @param array $config - * - * @return array - * - * @throws \Exception - */ - private function buildStore($type, $config) - { - $dataConfig = $config; + foreach ($configElements as $configElementName => $elementData) { + $editableNode = $this->parseConfigElement($info, $configElementName, $elementData, $acStoreProcessed); - unset($dataConfig['store'], $dataConfig['store_provider']); + //if element need's a store and store is empty: skip field + if ($this->needStore($elementData['type']) && $this->hasValidStore($editableNode['config']) === false) { + continue; + } - $storeValues = []; - if (isset($config['store']) && !is_null($config['store'])) { - $storeValues = $config['store']; - } elseif (isset($config['store_provider']) && !is_null($config['store_provider'])) { - $storeProvider = $this->storeProvider->get($config['store_provider']); - $storeValues = $storeProvider->getValues(); - } + $editableNodes[] = $editableNode; - if (count($storeValues) === 0) { - throw new \Exception($type . ' (' . $this->documentEditableId . ') has no valid configured store'); - } + $editableNodes = $this->checkColumnAdjusterField($brickId, $elementData['tab'], $themeOptions, $configElementName, $editableNodes); - $store = []; - foreach ($storeValues as $k => $v) { - if (is_array($v)) { - $v = $v['name']; + if ($elementData['type'] === 'additionalClasses') { + $acStoreProcessed = true; } - $store[] = [$k, $this->translator->trans($v, [], 'admin')]; } - $dataConfig['store'] = $store; + // move additional classes to bottom + $defaultFields = []; + $acFields = []; - return $dataConfig; - } + foreach ($editableNodes as $editableNode) { + if ($editableNode['additional_classes_element'] === true) { + $acFields[] = $editableNode; + } else { + $defaultFields[] = $editableNode; + } + } - /** - * @param string $type - * - * @return bool - */ - private function canHaveDynamicWidth($type) - { - return in_array( - $type, - [ - 'multihref', - 'relations', - 'href', - 'relation', - 'image', - 'input', - 'multiselect', - 'numeric', - 'embed', - 'pdf', - 'renderlet', - 'select', - 'snippet', - 'table', - 'textarea', - 'video', - 'wysiwyg', - 'parallaximage', - 'additionalClasses', - 'additionalClassesChained' - ] - ); - } + $editableNodes = array_merge($defaultFields, $acFields); + + // assign tabs, if configured + if (count($tabs) > 0) { + $tabbedEditableNodes = []; + foreach ($tabs as $tabId => $tabName) { + $tabbedEditableNodes[] = [ + 'type' => 'panel', + 'title' => $this->translator->trans($tabName, [], 'admin'), + 'items' => array_values( + array_filter($editableNodes, static function ($editableNode) use ($tabId) { + return $editableNode['tab'] === $tabId; + }) + ) + ]; + } - /** - * @param string $type - * - * @return bool - */ - private function canHaveDynamicHeight($type) - { - return in_array($type, [ - 'multihref', - 'relations', - 'image', - 'multiselect', - 'embed', - 'pdf', - 'renderlet', - 'snippet', - 'textarea', - 'video', - 'wysiwyg', - 'parallaximage' - ]); - } + return [ + 'type' => 'tabpanel', + 'items' => $tabbedEditableNodes + ]; + } - /** - * Reset class for next element to build. - */ - private function reset() - { - $this->documentEditableId = ''; - $this->documentEditableName = ''; - $this->info = null; - $this->themeOptions = []; - $this->configElements = []; - $this->configParameter = []; - $this->hasAdditionalClassStore = false; - $this->configWindowSize = null; + return $editableNodes; } - /** - * @param string $type - * @param array $config - * @param array $additionalConfig - * - * @return array - * - * @throws \Exception - */ - private function getTagConfig($type, $config, $additionalConfig) + private function parseConfigElement(?Info $info, string $elementName, array $elementData, bool $acStoreProcessed): array { - if (is_null($config)) { - return []; - } - - $parsedConfig = $config; + $editableConfig = $elementData['config']; + $editableType = $elementData['type']; - //override reload - $parsedConfig['reload'] = false; + //set element config data + $parsedNode = $this->parseElementNode($elementName, $elementData, $acStoreProcessed); //set width - if ($this->canHaveDynamicWidth($type)) { - $parsedConfig['width'] = isset($parsedConfig['width']) - ? $parsedConfig['width'] - : (isset($additionalConfig['col_class']) ? '100%' : ($this->configWindowSize === 'large' ? 760 : 560)); + if ($this->canHaveDynamicWidth($editableType)) { + $parsedNode['width'] = $parsedNode['width'] ?? '100%'; } else { - unset($parsedConfig['width']); + unset($parsedNode['width']); } //set height - if ($this->canHaveDynamicHeight($type)) { - $parsedConfig['height'] = isset($parsedConfig['height']) ? $parsedConfig['height'] : 200; + if ($this->canHaveDynamicHeight($editableType)) { + $parsedNode['height'] = $parsedNode['height'] ?? 200; } else { - unset($parsedConfig['height']); - } - - //check store - if ($this->needStore($type) && $this->hasValidStore($parsedConfig)) { - $parsedConfig = $this->buildStore($type, $parsedConfig); - } - - return $parsedConfig; - } - - /** - * types: type, title, description, col_class, conditions. - * - * @param string $configElementName - * @param array $rawConfig - * - * @return array - * - * @throws \Exception - */ - private function getAdditionalConfig($configElementName, $rawConfig) - { - if (is_null($rawConfig)) { - return []; + unset($parsedNode['height']); } - $config = $rawConfig; - $defaultConfigValue = isset($config['config']['default']) ? $config['config']['default'] : null; - - //remove tag area config. - unset($config['config']); - - //set element config data - $parsedConfig = $this->parseElementConfig($configElementName, $config); - - $parsedConfig['edit_reload'] = isset($rawConfig['config']['reload']) ? $rawConfig['config']['reload'] === true : true; - //set default - $parsedConfig = $this->getSelectedValue($parsedConfig, $defaultConfigValue); - - //set conditions to empty array. - if (!isset($parsedConfig['conditions'])) { - $parsedConfig['conditions'] = []; - } elseif (!is_array($parsedConfig['conditions'])) { - throw new \Exception('conditions configuration needs to be an array'); - } - - return $parsedConfig; - } - - /** - * @param array $config - * @param mixed $defaultConfigValue - * - * @return mixed - */ - private function getSelectedValue($config, $defaultConfigValue) - { - /** @var \Pimcore\Model\Document\Tag\TagInterface $el */ - $el = $this->tagRenderer->getTag($this->info->getDocument(), $config['type'], $config['name']); + $parsedNode['config']['defaultValue'] = $this->getSelectedValue($info, $parsedNode, $editableConfig['default'] ?? null); - // force default (only if it returns false) - // checkboxes may return an empty string and are impossible to track into default mode - if (!empty($defaultConfigValue) && (method_exists($el, 'isEmpty') && $el->isEmpty() === true)) { - $el->setDataFromResource($defaultConfigValue); - } - - $value = null; - if ($el instanceof Checkbox) { - $value = $el->isChecked(); - } else { - $value = $el->getData(); + //check store + if ($this->needStore($editableType) && $this->hasValidStore($editableConfig)) { + $parsedNode['config']['store'] = $this->buildStore($editableType, $editableConfig); } - $config['selected_value'] = !empty($value) ? $value : $defaultConfigValue; - - return $config; + return $parsedNode; } - /** - * @param string $configElementName - * @param array $elConf - * - * @return array - * - * @throws \Exception - */ - private function parseElementConfig($configElementName, $elConf) + private function parseElementNode(string $configElementName, array $elementData, bool $acStoreProcessed): array { - $elConf['additional_classes_element'] = false; + $elementNode = [ + 'type' => $elementData['type'], + 'name' => $configElementName, + 'tab' => $elementData['tab'], + 'label' => isset($elementData['title']) && !empty($elementData['title']) ? $elementData['title'] : null, + 'description' => isset($elementData['description']) && !empty($elementData['description']) ? $elementData['description'] : null, + 'config' => $elementData['config'] ?? [], + 'additional_classes_element' => false, + ]; - if ($elConf['type'] === 'additionalClasses') { - if ($this->hasAdditionalClassStore === true) { + if ($elementData['type'] === 'additionalClasses') { + if ($acStoreProcessed === true) { throw new \Exception( sprintf( 'A element of type "additionalClasses" in element "%s" already has been defined. You can only add one field of type "%s" per area. Use "%s" instead.', - $this->documentEditableName, + $configElementName, 'additionalClasses', 'additionalClassesChained' ) ); } - $elConf['type'] = 'select'; - $elConf['title'] = isset($elConf['title']) && !empty($elConf['title']) ? $elConf['title'] : 'Additional'; - $elConf['col_class'] = isset($elConf['col_class']) && !empty($elConf['col_class']) ? $elConf['col_class'] : 't-col-third'; - $elConf['additional_classes_element'] = true; - $elementName = 'add_classes'; - $this->hasAdditionalClassStore = true; - } elseif ($elConf['type'] === 'additionalClassesChained') { - if ($this->hasAdditionalClassStore === false) { + $elementNode['type'] = 'select'; + $elementNode['label'] = isset($elementData['title']) && !empty($elementData['title']) ? $elementData['title'] : 'Additional'; + $elementNode['additional_classes_element'] = true; + $elementNode['name'] = 'add_classes'; + } elseif ($elementData['type'] === 'additionalClassesChained') { + if ($acStoreProcessed === false) { throw new \Exception( sprintf( 'You need to add a element of type "%s" before adding a "%s" element.', @@ -462,7 +206,7 @@ private function parseElementConfig($configElementName, $elConf) 'additionalClassesChained' ) ); - } elseif (substr($configElementName, 0, 25) !== 'additional_classes_chain_') { + } elseif (!str_starts_with($configElementName, 'additional_classes_chain_')) { throw new \Exception( sprintf( 'Chained AC element name needs to start with "%s" followed by a numeric. "%s" given.', @@ -478,192 +222,161 @@ private function parseElementConfig($configElementName, $elConf) throw new \Exception('Chained AC element name must end with an numeric. "' . $chainedIncrementor . '" given.'); } - $elConf['type'] = 'select'; - $elConf['title'] = isset($elConf['title']) && !empty($elConf['title']) ? $elConf['title'] : 'Additional'; - $elConf['col_class'] = isset($elConf['col_class']) && !empty($elConf['col_class']) ? $elConf['col_class'] : 't-col-third'; - $elConf['additional_classes_element'] = true; - $elementName = 'add_cclasses_' . $chainedIncrementor; - } else { - $elementName = $configElementName; + $elementNode['type'] = 'select'; + $elementNode['label'] = isset($elementData['title']) && !empty($elementData['title']) ? $elementData['title'] : 'Additional'; + $elementNode['additional_classes_element'] = true; + $elementNode['name'] = 'add_cclasses_' . $chainedIncrementor; } - //set config element name - $elConf['name'] = $elementName; - - //set editmode hidden to false on initial state - $elConf['editmode_hidden'] = false; - - //translate title - if (!empty($elConf['title'])) { - $elConf['title'] = $this->translator->trans($elConf['title'], [], 'admin'); + // translate title + if (!empty($elementNode['label'])) { + $elementNode['label'] = $this->translator->trans($elementNode['label'], [], 'admin'); } - //translate description - if (!empty($elConf['description'])) { - $elConf['description'] = $this->translator->trans($elConf['description'], [], 'admin'); + // translate description + if (!empty($elementNode['description'])) { + $elementNode['description'] = $this->translator->trans($elementNode['description'], [], 'admin'); } - return $elConf; + return $elementNode; } - /** - * @return array - * - * @throws \Exception - */ - private function parseConfigElements() + private function getSelectedValue(?Info $info, array $config, mixed $defaultConfigValue): mixed { - $parsedConfig = []; - if (empty($this->configElements)) { - return $parsedConfig; + if (!$info instanceof Info) { + return $defaultConfigValue; } - foreach ($this->configElements as $configElementName => $c) { - $tagConfig = $c['config']; - $parsedAdditionalConfig = $this->getAdditionalConfig($configElementName, $c); - $parsedTagConfig = $this->getTagConfig($c['type'], $tagConfig, $parsedAdditionalConfig); + $el = $info->getDocumentElement($config['name'], $config['type']); - //if element need's a store and store is empty: skip field - if ($this->needStore($c['type']) && $this->hasValidStore($parsedTagConfig) === false) { - continue; - } + if ($el === null) { + return $config; + } - $parsedConfig[] = ['tag_config' => $parsedTagConfig, 'additional_config' => $parsedAdditionalConfig]; - $parsedConfig = $this->checkDependingSystemField($configElementName, $parsedConfig); + // force default (only if it returns false) + // checkboxes may return an empty string and are impossible to track into default mode + if (!empty($defaultConfigValue) && (method_exists($el, 'isEmpty') && $el->isEmpty() === true)) { + $el->setDataFromResource($defaultConfigValue); } - //condition needs to applied after all elements has been initialized! - return $this->checkCondition($parsedConfig); + $value = $el instanceof Checkbox ? $el->isChecked() : $el->getData(); + + return !empty($value) ? $value : $defaultConfigValue; } - /** - * Add possible dynamic fields based on current field (like the column adjuster after the "type" field in field "columns". - * - * @param string $configElementName - * @param array $configFields - * - * @return array - */ - private function checkDependingSystemField($configElementName, $configFields) + private function checkColumnAdjusterField(string $brickId, ?string $tab, array $themeOptions, string $configElementName, array $editableNodes): array { - // add column adjuster (only if breakpoints are defined! - if ($this->documentEditableId === 'columns' && $configElementName === 'type') { - if (empty($this->themeOptions['grid']['breakpoints'])) { - return $configFields; - } + if ($brickId !== 'columns') { + return $editableNodes; + } - $parsedTagConfig = ['reload' => false]; - $additionalConfig = [ - 'type' => 'columnadjuster', - 'editmode_hidden' => false, - 'col_class' => '', - 'name' => 'columnadjuster', - 'title' => null, - 'edit_reload' => false, - 'additional_classes_element' => false - ]; + if ($configElementName !== 'type') { + return $editableNodes; + } - $configFields[] = ['tag_config' => $parsedTagConfig, 'additional_config' => $additionalConfig]; + if (empty($themeOptions['grid']['breakpoints'])) { + return $editableNodes; } - return $configFields; + $editableNodes[] = [ + 'type' => 'columnadjuster', + 'name' => 'columnadjuster', + 'tab' => $tab, + 'label' => null, + 'config' => [], + 'additional_classes_element' => false, + ]; + + return $editableNodes; } - /** - * @param array $configElements - * - * @return array - */ - private function checkCondition($configElements) + private function buildStore($type, $config): array { - $filteredData = []; - - if (empty($configElements)) { - return $configElements; + $storeValues = []; + if (isset($config['store']) && !is_null($config['store'])) { + $storeValues = $config['store']; + } elseif (isset($config['store_provider']) && !is_null($config['store_provider'])) { + $storeProvider = $this->storeProvider->get($config['store_provider']); + $storeValues = $storeProvider->getValues(); } - foreach ($configElements as $configElementName => $el) { - //no conditions? add it! - if (empty($el['additional_config']['conditions'])) { - $filteredData[] = $el; - - continue; - } - - $orConditions = $el['additional_config']['conditions']; - - $orGroup = []; - $orState = false; - - foreach ($orConditions as $andConditions) { - $andGroup = []; - $andState = true; - - foreach ($andConditions as $andConditionKey => $andConditionValue) { - $andGroup[] = $this->getElementState($andConditionKey, $configElements) == $andConditionValue; - } - - if (in_array(false, $andGroup, true)) { - $andState = false; - } - - $orGroup[] = $andState; - } - - if (in_array(true, $orGroup, true)) { - $orState = true; - } + if (count($storeValues) === 0) { + throw new \Exception($type . ' has no valid configured store'); + } - if ($orState === true) { - $filteredData[] = $el; - } else { - //we need to reset value, if possible! - $filteredData[] = $this->resetElement($el); + $store = []; + foreach ($storeValues as $k => $v) { + if (is_array($v)) { + $v = $v['name']; } + $store[] = [$k, $this->translator->trans($v, [], 'admin')]; } - return $filteredData; + return $store; } - /** - * @param string $name - * @param array $elements - * - * @return null|string - */ - private function getElementState($name = '', $elements = []) + private function hasValidStore($parsedConfig): bool { - if (empty($elements)) { - return null; + if (isset($parsedConfig['store']) && is_array($parsedConfig['store']) && count($parsedConfig['store']) > 0) { + return true; } - foreach ($elements as $el) { - if ($el['additional_config']['name'] === $name) { - return $el['additional_config']['selected_value']; - } + if (isset($parsedConfig['store_provider']) && $this->storeProvider->has($parsedConfig['store_provider'])) { + return true; } - return null; + return false; } - /** - * @param array $el - * - * @return mixed - */ - private function resetElement($el) + private function needStore($type): bool { - $value = !empty($el['tag_config']['default']) ? $el['tag_config']['default'] : null; - - $this->tagRenderer->getTag( - $this->info->getDocument(), - $el['additional_config']['type'], - $el['additional_config']['name'] - )->setDataFromResource($value); + return in_array($type, ['select', 'multiselect', 'additionalClasses', 'additionalClassesChained']); + } - $el['additional_config']['selected_value'] = $value; - $el['additional_config']['editmode_hidden'] = true; + private function canHaveDynamicWidth($type): bool + { + return in_array( + $type, + [ + 'multihref', + 'relations', + 'href', + 'relation', + 'image', + 'input', + 'multiselect', + 'numeric', + 'embed', + 'pdf', + 'renderlet', + 'select', + 'snippet', + 'table', + 'textarea', + 'video', + 'wysiwyg', + 'parallaximage', + 'additionalClasses', + 'additionalClassesChained' + ] + ); + } - return $el; + private function canHaveDynamicHeight($type): bool + { + return in_array($type, [ + 'multihref', + 'relations', + 'image', + 'multiselect', + 'embed', + 'pdf', + 'renderlet', + 'snippet', + 'textarea', + 'video', + 'wysiwyg', + 'parallaximage' + ]); } } diff --git a/src/ToolboxBundle/Builder/BrickConfigBuilderInterface.php b/src/ToolboxBundle/Builder/BrickConfigBuilderInterface.php new file mode 100644 index 00000000..36d00bbb --- /dev/null +++ b/src/ToolboxBundle/Builder/BrickConfigBuilderInterface.php @@ -0,0 +1,11 @@ +configManager = $configManager; $this->configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL); @@ -25,15 +17,7 @@ public function setConfigManager(ConfigManagerInterface $configManager) return $this; } - /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return array - * - * @throws \Exception - */ - public function calculateColumns($value, $customColumnConfiguration = null) + public function calculateColumns(?string $value, ?array $customColumnConfiguration = null): array { $themeSettings = $this->configManager->getConfig('theme'); $gridSettings = $themeSettings['grid']; @@ -133,15 +117,7 @@ public function calculateColumns($value, $customColumnConfiguration = null) return $columns; } - /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return bool|mixed - * - * @throws \Exception - */ - public function getColumnInfoForAdjuster($value, $customColumnConfiguration = null) + public function getColumnInfoForAdjuster(?string $value, ?array $customColumnConfiguration = null): bool|array { $columnData = $this->calculateColumns($value, $customColumnConfiguration); diff --git a/src/ToolboxBundle/Calculator/Bootstrap3/SlideColumnCalculator.php b/src/ToolboxBundle/Calculator/Bootstrap3/SlideColumnCalculator.php index a2aae64d..8e80dd7b 100644 --- a/src/ToolboxBundle/Calculator/Bootstrap3/SlideColumnCalculator.php +++ b/src/ToolboxBundle/Calculator/Bootstrap3/SlideColumnCalculator.php @@ -6,16 +6,8 @@ class SlideColumnCalculator implements SlideColumnCalculatorInterface { - /** - * @param int $columnType - * @param array $columnConfiguration - * - * @return string - */ - public function calculateSlideColumnClasses($columnType, $columnConfiguration) + public function calculateSlideColumnClasses(int $columnType, array $columnConfiguration): string { - $columnType = (int) $columnType; - $systemClasses = [ 2 => 'col-xs-12 col-sm-6', 3 => 'col-xs-12 col-sm-4', @@ -24,11 +16,11 @@ public function calculateSlideColumnClasses($columnType, $columnConfiguration) ]; if (empty($columnConfiguration)) { - return isset($systemClasses[$columnType]) ? $systemClasses[$columnType] : 'col-xs-12'; + return $systemClasses[$columnType] ?? 'col-xs-12'; } if (!isset($columnConfiguration['column_classes']) || !isset($columnConfiguration['column_classes'][$columnType])) { - return isset($systemClasses[$columnType]) ? $systemClasses[$columnType] : 'col-xs-12'; + return $systemClasses[$columnType] ?? 'col-xs-12'; } return $columnConfiguration['column_classes'][$columnType]; diff --git a/src/ToolboxBundle/Calculator/Bootstrap4/ColumnCalculator.php b/src/ToolboxBundle/Calculator/Bootstrap4/ColumnCalculator.php index 6322a71a..cd86e0a5 100644 --- a/src/ToolboxBundle/Calculator/Bootstrap4/ColumnCalculator.php +++ b/src/ToolboxBundle/Calculator/Bootstrap4/ColumnCalculator.php @@ -7,17 +7,9 @@ class ColumnCalculator implements ColumnCalculatorInterface { - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected ConfigManagerInterface $configManager; - /** - * @param ConfigManagerInterface $configManager - * - * @return $this - */ - public function setConfigManager(ConfigManagerInterface $configManager) + public function setConfigManager(ConfigManagerInterface $configManager): self { $this->configManager = $configManager; $this->configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL); @@ -26,14 +18,9 @@ public function setConfigManager(ConfigManagerInterface $configManager) } /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return array - * * @throws \Exception */ - public function calculateColumns($value, $customColumnConfiguration = null) + public function calculateColumns(?string $value, ?array $customColumnConfiguration = null): array { $themeSettings = $this->configManager->getConfig('theme'); $gridSettings = $themeSettings['grid']; @@ -118,7 +105,7 @@ public function calculateColumns($value, $customColumnConfiguration = null) $columnName = $strictColumnCounter ? 'column_' . $i : 'column_' . $columnCounter; $columns[] = [ - 'columnClass' => join(' ', $bootstrapClassConfig) . ' ' . join(' ', $bootstrapOffsetConfig), + 'columnClass' => implode(' ', $bootstrapClassConfig) . ' ' . join(' ', $bootstrapOffsetConfig), 'columnData' => [ 'grid' => $gridConfig, 'gridOffset' => $gridOffsetConfig @@ -135,15 +122,7 @@ public function calculateColumns($value, $customColumnConfiguration = null) return $columns; } - /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return bool|mixed - * - * @throws \Exception - */ - public function getColumnInfoForAdjuster($value, $customColumnConfiguration = null) + public function getColumnInfoForAdjuster(?string $value, ?array $customColumnConfiguration = null): bool|array { $columnData = $this->calculateColumns($value, $customColumnConfiguration); diff --git a/src/ToolboxBundle/Calculator/Bootstrap4/SlideColumnCalculator.php b/src/ToolboxBundle/Calculator/Bootstrap4/SlideColumnCalculator.php index 99500407..18d6b940 100644 --- a/src/ToolboxBundle/Calculator/Bootstrap4/SlideColumnCalculator.php +++ b/src/ToolboxBundle/Calculator/Bootstrap4/SlideColumnCalculator.php @@ -6,16 +6,8 @@ class SlideColumnCalculator implements SlideColumnCalculatorInterface { - /** - * @param int $columnType - * @param array $columnConfiguration - * - * @return string - */ - public function calculateSlideColumnClasses($columnType, $columnConfiguration) + public function calculateSlideColumnClasses(int $columnType, array $columnConfiguration): string { - $columnType = (int) $columnType; - $systemClasses = [ 2 => 'col-12 col-sm-6', 3 => 'col-12 col-sm-4', @@ -24,11 +16,11 @@ public function calculateSlideColumnClasses($columnType, $columnConfiguration) ]; if (empty($columnConfiguration)) { - return isset($systemClasses[$columnType]) ? $systemClasses[$columnType] : 'col-12'; + return $systemClasses[$columnType] ?? 'col-12'; } if (!isset($columnConfiguration['column_classes']) || !isset($columnConfiguration['column_classes'][$columnType])) { - return isset($systemClasses[$columnType]) ? $systemClasses[$columnType] : 'col-12'; + return $systemClasses[$columnType] ?? 'col-12'; } return $columnConfiguration['column_classes'][$columnType]; diff --git a/src/ToolboxBundle/Calculator/ColumnCalculatorInterface.php b/src/ToolboxBundle/Calculator/ColumnCalculatorInterface.php index 215b6d9d..67af684c 100644 --- a/src/ToolboxBundle/Calculator/ColumnCalculatorInterface.php +++ b/src/ToolboxBundle/Calculator/ColumnCalculatorInterface.php @@ -6,26 +6,15 @@ interface ColumnCalculatorInterface { - /** - * @param ConfigManagerInterface $configManager - * - * @return mixed - */ - public function setConfigManager(ConfigManagerInterface $configManager); + public function setConfigManager(ConfigManagerInterface $configManager): self; /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return array + * @throws \Exception */ - public function calculateColumns($value, $customColumnConfiguration = null); + public function calculateColumns(?string $value, ?array $customColumnConfiguration = null): array; /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return mixed + * @throws \Exception */ - public function getColumnInfoForAdjuster($value, $customColumnConfiguration = null); + public function getColumnInfoForAdjuster(?string $value, ?array $customColumnConfiguration = null): bool|array; } diff --git a/src/ToolboxBundle/Calculator/SlideColumnCalculatorInterface.php b/src/ToolboxBundle/Calculator/SlideColumnCalculatorInterface.php index e9d487b6..258f985d 100644 --- a/src/ToolboxBundle/Calculator/SlideColumnCalculatorInterface.php +++ b/src/ToolboxBundle/Calculator/SlideColumnCalculatorInterface.php @@ -4,11 +4,5 @@ interface SlideColumnCalculatorInterface { - /** - * @param int $columnType - * @param array $columnConfiguration - * - * @return string - */ - public function calculateSlideColumnClasses($columnType, $columnConfiguration); + public function calculateSlideColumnClasses(int $columnType, array $columnConfiguration): string; } diff --git a/src/ToolboxBundle/Calculator/UIkit3/ColumnCalculator.php b/src/ToolboxBundle/Calculator/UIkit3/ColumnCalculator.php index 7f6adedb..4f8c30af 100644 --- a/src/ToolboxBundle/Calculator/UIkit3/ColumnCalculator.php +++ b/src/ToolboxBundle/Calculator/UIkit3/ColumnCalculator.php @@ -2,23 +2,14 @@ namespace ToolboxBundle\Calculator\UIkit3; -use Exception; use ToolboxBundle\Calculator\ColumnCalculatorInterface; use ToolboxBundle\Manager\ConfigManagerInterface; class ColumnCalculator implements ColumnCalculatorInterface { - /** - * @var ConfigManagerInterface - */ - protected $configManager; - - /** - * @param ConfigManagerInterface $configManager - * - * @return $this - */ - public function setConfigManager(ConfigManagerInterface $configManager) + protected ConfigManagerInterface $configManager; + + public function setConfigManager(ConfigManagerInterface $configManager): self { $this->configManager = $configManager; $this->configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL); @@ -26,15 +17,7 @@ public function setConfigManager(ConfigManagerInterface $configManager) return $this; } - /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return array - * - * @throws Exception - */ - public function calculateColumns($value, $customColumnConfiguration = null) + public function calculateColumns(?string $value, ?array $customColumnConfiguration = null): array { $themeSettings = $this->configManager->getConfig('theme'); $gridSettings = $themeSettings['grid']; @@ -52,7 +35,7 @@ public function calculateColumns($value, $customColumnConfiguration = null) } $columns = []; - if (empty($value) || $value === null) { + if (empty($value)) { return $columns; } @@ -108,38 +91,14 @@ public function calculateColumns($value, $customColumnConfiguration = null) 'columnType' => $value, 'name' => $columnName ]; - + $columnCounter++; } return $columns; } - /** - * @param string $numerator - * - * @return string - */ - private function getUIKitCol($numerator): string - { - if (is_numeric($numerator)) { - $split = str_split($numerator); - - return $split[0] . '-' . $split[1]; - } - - return $numerator; - } - - /** - * @param string $value - * @param null|array $customColumnConfiguration - * - * @return bool|mixed - * - * @throws Exception - */ - public function getColumnInfoForAdjuster($value, $customColumnConfiguration = null) + public function getColumnInfoForAdjuster(?string $value, ?array $customColumnConfiguration = null): bool|array { $columnData = $this->calculateColumns($value, $customColumnConfiguration); $themeSettings = $this->configManager->getConfig('theme'); @@ -177,4 +136,15 @@ public function getColumnInfoForAdjuster($value, $customColumnConfiguration = nu return $breakPoints; } + + private function getUIKitCol(mixed $numerator): string + { + if (is_numeric($numerator)) { + $split = str_split($numerator); + + return $split[0] . '-' . $split[1]; + } + + return $numerator; + } } diff --git a/src/ToolboxBundle/Calculator/UIkit3/SlideColumnCalculator.php b/src/ToolboxBundle/Calculator/UIkit3/SlideColumnCalculator.php index aea62840..6b71714a 100644 --- a/src/ToolboxBundle/Calculator/UIkit3/SlideColumnCalculator.php +++ b/src/ToolboxBundle/Calculator/UIkit3/SlideColumnCalculator.php @@ -12,10 +12,8 @@ class SlideColumnCalculator implements SlideColumnCalculatorInterface * * @return string */ - public function calculateSlideColumnClasses($columnType, $columnConfiguration): string + public function calculateSlideColumnClasses(int $columnType, array $columnConfiguration): string { - $columnType = (int) $columnType; - $systemClasses = [ 2 => 'uk-child-width-1-2@s uk-child-width-1-1', 3 => 'uk-child-width-1-3@m uk-child-width-1-2@s uk-child-width-1-1', diff --git a/src/ToolboxBundle/Command/AreaConfigurationCommand.php b/src/ToolboxBundle/Command/AreaConfigurationCommand.php index 7cfa2b85..f2af5d57 100644 --- a/src/ToolboxBundle/Command/AreaConfigurationCommand.php +++ b/src/ToolboxBundle/Command/AreaConfigurationCommand.php @@ -15,28 +15,19 @@ class AreaConfigurationCommand extends Command { - /** - * @var AdaptiveConfigManagerInterface - */ - protected $adaptiveConfigManager; - - /** - * @param AdaptiveConfigManagerInterface $adaptiveConfigManager - */ + protected static $defaultName = 'toolbox:check-config'; + protected static $defaultDescription = 'Check configuration of a given area element.'; + protected AdaptiveConfigManagerInterface $adaptiveConfigManager; + public function __construct(AdaptiveConfigManagerInterface $adaptiveConfigManager) { $this->adaptiveConfigManager = $adaptiveConfigManager; parent::__construct(); } - /** - * {@inheritdoc} - */ - protected function configure() + protected function configure(): void { $this - ->setName('toolbox:check-config') - ->setDescription('Check configuration of a given area element.') ->addOption( 'area', 'a', @@ -51,10 +42,7 @@ protected function configure() ); } - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $brickId = $input->getOption('area'); $contextId = $input->getOption('context'); @@ -67,7 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (empty($brickId)) { $output->writeln('Please provide a valid Area Brick Id.'); - return 0; + return Command::SUCCESS; } $namespace = ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL; @@ -93,14 +81,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(''); } - return 0; + return Command::SUCCESS; } $output->writeln(''); $output->writeln(sprintf('Area Brick with Id "%s" not found.', $brickId)); $output->writeln(''); - return 0; + return Command::SUCCESS; } $configElements = $brickConfig['config_elements']; @@ -111,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('Area Brick with Id "%s" does not have any configuration elements.', $brickId)); $output->writeln(''); - return 0; + return Command::SUCCESS; } $contextHeadline = $hasContext ? ('in Context "' . $contextId . '"') : ''; @@ -128,14 +116,12 @@ protected function execute(InputInterface $input, OutputInterface $output) foreach ($configElements as $configName => $configData) { $elementConfigData = empty($configData['config']) ? '--' : $this->parseArrayForOutput($configData['config']); - $conditionParameter = empty($configData['conditions']) ? '--' : $this->parseArrayForOutput($configData['conditions']); $rows[] = [ $configName, $configData['type'], $configData['title'], $configData['description'], - $conditionParameter, $elementConfigData, ]; @@ -154,21 +140,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $table = new Table($output); $table - ->setHeaders(['name', 'type', 'title', 'description', 'conditions', 'config_elements']) + ->setHeaders(['name', 'type', 'title', 'description', 'config_elements']) ->setRows($rows); $table->render(); - return 0; + return Command::SUCCESS; } - /** - * @param array $array - * @param string $string - * @param int $depth - * - * @return string - */ - private function parseArrayForOutput(array $array = [], $string = '', $depth = 0) + private function parseArrayForOutput(array $array = [], string $string = '', int $depth = 0): string { $depthStr = str_repeat(' ', $depth * 3); foreach ($array as $key => $value) { diff --git a/src/ToolboxBundle/Command/DynamicLinkMigrationCommand.php b/src/ToolboxBundle/Command/DynamicLinkMigrationCommand.php deleted file mode 100644 index acc54555..00000000 --- a/src/ToolboxBundle/Command/DynamicLinkMigrationCommand.php +++ /dev/null @@ -1,95 +0,0 @@ -setName('toolbox:migrate-dynamic-link') - ->setDescription('Migrate Dynamic Link Tag to Pimcore Link Tag'); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $db = \Pimcore\Db::get(); - - $elements = $db->fetchAll('SELECT * FROM documents_elements WHERE type = ?', ['dynamiclink']); - - $documentTagsToClear = []; - - foreach ($elements as $element) { - $data = \Pimcore\Tool\Serialize::unserialize($element['data']); - $newData = $data; - - if (!is_array($data)) { - continue; - } - - $documentTagsToClear[] = $element['documentId']; - - $output->writeln(sprintf('check "%s" for document %s', $element['name'], $element['documentId'])); - - if (strpos($data['path'], '::') !== false) { - $pathFragments = explode('::', $data['path']); - - if (count($pathFragments) === 2) { - $oldPath = $pathFragments[1]; - - $target = Service::getElementByPath('object', $oldPath); - - if ($target) { - $newData['internal'] = true; - $newData['internalId'] = $target->getId(); - $newData['internalType'] = 'object'; - $newData['path'] = $target->getFullPath(); - $newData['linktype'] = 'internal'; - } else { - $newData['internal'] = false; - $newData['internalId'] = null; - $newData['internalType'] = null; - $newData['linktype'] = 'direct'; - $newData['path'] = ''; - } - - unset($newData['type']); - - $output->writeln(sprintf(' -> tranform dynamic path "%s" to "%s"', $oldPath, $newData['path'])); - } - } - - $output->writeln('update dynamic link in db...'); - - $dbData = \Pimcore\Tool\Serialize::serialize($newData); - $db->update('documents_elements', ['type' => 'link', 'data' => $dbData], [ - 'documentId' => $element['documentId'], - 'name' => $element['name'] - ]); - } - - if (count($documentTagsToClear) > 0) { - $output->writeln(''); - $output->writeln(''); - $output->writeln('clear document cache...'); - - foreach (array_unique($documentTagsToClear) as $tag) { - Cache::clearTag('document_' . $tag); - } - } - - return 0; - } -} diff --git a/src/ToolboxBundle/Connector/BundleConnector.php b/src/ToolboxBundle/Connector/BundleConnector.php index b6fbe635..af2defed 100644 --- a/src/ToolboxBundle/Connector/BundleConnector.php +++ b/src/ToolboxBundle/Connector/BundleConnector.php @@ -7,39 +7,20 @@ class BundleConnector { - /** - * @var PimcoreBundleManager - */ - protected $bundleManager; + protected PimcoreBundleManager $bundleManager; + protected array $services = []; - /** - * @var array - */ - protected $services = []; - - /** - * @param PimcoreBundleManager $bundleManager - */ public function __construct(PimcoreBundleManager $bundleManager) { $this->bundleManager = $bundleManager; } - /** - * @param string $serviceId - * @param mixed $service - */ - public function registerBundleService($serviceId, $service) + public function registerBundleService(string $serviceId, mixed $service): void { $this->services[$serviceId] = $service; } - /** - * @param string $serviceId - * - * @return mixed - */ - public function getBundleService($serviceId) + public function getBundleService(string $serviceId): mixed { if (!isset($this->services[$serviceId])) { throw new ServiceNotFoundException(sprintf('BundleConnector Service "%s" not found', $serviceId)); @@ -48,12 +29,7 @@ public function getBundleService($serviceId) return $this->services[$serviceId]; } - /** - * @param string $bundleName - * - * @return bool - */ - public function hasBundle($bundleName = 'ExtensionBundle\ExtensionBundle') + public function hasBundle(string $bundleName = 'ExtensionBundle\ExtensionBundle'): bool { try { $hasExtension = $this->bundleManager->isEnabled($bundleName); diff --git a/src/ToolboxBundle/Controller/Admin/ColumnAdjusterController.php b/src/ToolboxBundle/Controller/Admin/ColumnAdjusterController.php index cb75780f..aec3c91d 100644 --- a/src/ToolboxBundle/Controller/Admin/ColumnAdjusterController.php +++ b/src/ToolboxBundle/Controller/Admin/ColumnAdjusterController.php @@ -10,20 +10,9 @@ class ColumnAdjusterController extends Controller\AdminController { - /** - * @var CalculatorRegistryInterface - */ - private $calculatorRegistry; - - /** - * @var ConfigManagerInterface - */ - private $configManager; + private CalculatorRegistryInterface $calculatorRegistry; + private ConfigManagerInterface $configManager; - /** - * @param ConfigManagerInterface $configManager - * @param CalculatorRegistryInterface $calculatorRegistry - */ public function __construct( ConfigManagerInterface $configManager, CalculatorRegistryInterface $calculatorRegistry @@ -33,13 +22,9 @@ public function __construct( } /** - * @param Request $request - * - * @return JsonResponse - * * @throws \Exception */ - public function getColumnInfoAction(Request $request) + public function getColumnInfoAction(Request $request): JsonResponse { $currentColumn = $request->get('currentColumn'); $customColumnConfigurationData = $request->get('customColumnConfiguration'); @@ -72,14 +57,7 @@ public function getColumnInfoAction(Request $request) ]); } - /** - * @param array $theme - * @param string $node - * @param string $expectedType - * - * @return mixed|null - */ - protected function assertGridConfig(array $theme, string $node, string $expectedType = 'string') + protected function assertGridConfig(array $theme, string $node, string $expectedType = 'string'): mixed { if (!isset($theme['grid'])) { return null; diff --git a/src/ToolboxBundle/Controller/Admin/SettingsController.php b/src/ToolboxBundle/Controller/Admin/SettingsController.php index 3f47122e..bbd5fd31 100644 --- a/src/ToolboxBundle/Controller/Admin/SettingsController.php +++ b/src/ToolboxBundle/Controller/Admin/SettingsController.php @@ -2,50 +2,31 @@ namespace ToolboxBundle\Controller\Admin; +use Exception; use Pimcore\Bundle\AdminBundle\Controller; use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Manager\ConfigManagerInterface; class SettingsController extends Controller\AdminController { - /** - * @var array - */ - protected $globalStyleSets = []; - - /** - * @var array - */ - protected $ckEditorObjectConfig = []; - - /** - * @var array - */ - protected $ckEditorAreaConfig = []; + protected array $globalStyleSets = []; + protected array $ckEditorObjectConfig = []; + protected array $ckEditorAreaConfig = []; + protected ConfigManagerInterface $configManager; - /** - * @var ConfigManagerInterface - */ - protected $configManager; - - /** - * @param ConfigManagerInterface $configManager - */ public function __construct(ConfigManagerInterface $configManager) { $this->configManager = $configManager; } /** - * @return Response - * - * @throws \Exception + * @throws Exception */ - public function ckEditorAreaStyleAction() + public function ckEditorAreaStyleAction(): Response { $this->setData(); - $response = $this->render('@Toolbox/Admin/Settings/ckeditor-area-style.html.twig', [ + $response = $this->render('@Toolbox/admin/settings/ckeditor-area-style.html.twig', [ 'globalStyleSets' => $this->globalStyleSets, 'config' => $this->ckEditorAreaConfig ]); @@ -58,15 +39,13 @@ public function ckEditorAreaStyleAction() } /** - * @return Response - * - * @throws \Exception + * @throws Exception */ - public function ckEditorObjectStyleAction() + public function ckEditorObjectStyleAction(): Response { $this->setData(); - $response = $this->render('@Toolbox/Admin/Settings/ckeditor-object-style.html.twig', [ + $response = $this->render('@Toolbox/admin/settings/ckeditor-object-style.html.twig', [ 'globalStyleSets' => $this->globalStyleSets, 'config' => $this->ckEditorObjectConfig ]); @@ -79,9 +58,9 @@ public function ckEditorObjectStyleAction() } /** - * @throws \Exception + * @throws Exception */ - private function setData() + private function setData(): void { $ckEditorSettings = $this->configManager->getConfig('ckeditor'); @@ -99,7 +78,7 @@ private function setData() $userCkEditorAreaConfig = $ckEditorSettings['area_editor']['config']; } - //global Style Sets config + //global style sets config if (isset($ckEditorSettings['global_style_sets'])) { $this->globalStyleSets = $ckEditorSettings['global_style_sets']; } @@ -108,16 +87,8 @@ private function setData() $this->ckEditorAreaConfig = $this->parseToolbarConfig($ckEditorGlobalConfig, $userCkEditorAreaConfig); } - /** - * @param array $defaultConfig - * @param array $userConfig - * - * @return array - */ - private function parseToolbarConfig($defaultConfig, $userConfig) + private function parseToolbarConfig(array $defaultConfig, array $userConfig): array { - $config = array_replace_recursive($defaultConfig, $userConfig); - - return $config; + return array_replace_recursive($defaultConfig, $userConfig); } } diff --git a/src/ToolboxBundle/Controller/AjaxController.php b/src/ToolboxBundle/Controller/AjaxController.php index 170a5e27..1b9d68b8 100644 --- a/src/ToolboxBundle/Controller/AjaxController.php +++ b/src/ToolboxBundle/Controller/AjaxController.php @@ -11,16 +11,10 @@ class AjaxController extends FrontendController { - /** - * @param Request $request - * @param LayoutManagerInterface $layoutManager - * - * @return Response - */ - public function gmInfoWindowAction(Request $request, LayoutManagerInterface $layoutManager) + public function gmInfoWindowAction(Request $request, LayoutManagerInterface $layoutManager): Response { return $this->render( - $layoutManager->getAreaTemplatePath('googleMap', 'infoWindow'), + $layoutManager->getAreaTemplatePath('googleMap', 'google-map', 'info-window'), [ 'mapParams' => $request->get('mapParams'), 'googleMapsHostUrl' => $this->getParameter('toolbox_google_maps_host_url') @@ -29,14 +23,9 @@ public function gmInfoWindowAction(Request $request, LayoutManagerInterface $lay } /** - * @param Request $request - * @param ConfigManagerInterface $configManager - * - * @return JsonResponse - * * @throws \Exception */ - public function videoGetTypesAction(Request $request, ConfigManagerInterface $configManager) + public function videoGetTypesAction(Request $request, ConfigManagerInterface $configManager): JsonResponse { $videoAreaSettings = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaParameterConfig('video'); diff --git a/src/ToolboxBundle/Controller/SnippetController.php b/src/ToolboxBundle/Controller/SnippetController.php index 9fa0d6bf..40411252 100644 --- a/src/ToolboxBundle/Controller/SnippetController.php +++ b/src/ToolboxBundle/Controller/SnippetController.php @@ -10,21 +10,17 @@ class SnippetController extends FrontendController { /** - * @param Request $request - * @param ConfigManagerInterface $configManager - * - * @return Response - * * @throws \Exception */ - public function teaserAction(Request $request, ConfigManagerInterface $configManager) + public function teaserAction(Request $request, ConfigManagerInterface $configManager): Response { $layoutStore = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaElementConfig('teaser', 'layout'); $addClStore = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaElementConfig('teaser', 'additional_classes'); - $flags = $configManager->getConfig('flags'); - $store = $layoutStore['config']['store']; $layoutExtJsStore = []; + $addClExtJsStore = []; + + $store = $layoutStore['config']['store']; if (is_array($store)) { foreach ($store as $key => $item) { $layoutExtJsStore[] = [$key, $item]; @@ -32,7 +28,6 @@ public function teaserAction(Request $request, ConfigManagerInterface $configMan } $store = $addClStore['config']['store']; - $addClExtJsStore = []; if (is_array($store)) { foreach ($store as $key => $item) { $addClExtJsStore[] = [$key, $item]; @@ -40,9 +35,8 @@ public function teaserAction(Request $request, ConfigManagerInterface $configMan } return $this->renderTemplate( - '@Toolbox/Snippet/Layout/teaser-layout.html.twig', + '@Toolbox/snippet/layout/teaser-layout.html.twig', [ - 'useDynamicLinks' => $flags['use_dynamic_links'], 'mapParams' => $request->get('mapParams'), 'layoutStore' => $layoutExtJsStore, 'additionalClassesStore' => $addClExtJsStore diff --git a/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickAutoloadWatcherPass.php b/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickAutoloadWatcherPass.php new file mode 100644 index 00000000..cf4c57f6 --- /dev/null +++ b/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickAutoloadWatcherPass.php @@ -0,0 +1,61 @@ +getParameter('pimcore.config'); + + if (!$config['documents']['areas']['autoload']) { + return; + } + + $possibleNoPimcoreAwareBricks = []; + + foreach ($container->getDefinitions() as $definitionId => $definition) { + if (!str_contains((string) $definitionId, '.area.brick.')) { + continue; + } + + if (count(array_filter($definition->getTags(), static function ($tag) { + return in_array($tag, ['toolbox.area.brick', 'toolbox.area.simple_brick']); + }, ARRAY_FILTER_USE_KEY)) !== 0) { + continue; + } + + $class = $definition->getClass(); + if (empty($definition->getClass()) && $definition instanceof ChildDefinition) { + $class = $definition->getParent(); + } + + if (empty($class)) { + continue; + } + + $reflector = new \ReflectionClass($class); + if (!$reflector->implementsInterface(AreabrickInterface::class)) { + continue; + } + + $possibleNoPimcoreAwareBricks[] = $definitionId; + } + + if (count($possibleNoPimcoreAwareBricks) === 0) { + return; + } + + throw new InvalidDefinitionException(sprintf( + 'Following classes have been auto-registered by PIMCORE which is not allowed when using the Toolbox Bundle.' . + 'Please disable the area autoload feature (pimcore.documents.areas.autoload = false), remove the classes or register them by using the toolbox.area.brick tag: %s', + implode(', ', $possibleNoPimcoreAwareBricks) + )); + } +} diff --git a/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickRegistryPass.php b/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickRegistryPass.php new file mode 100644 index 00000000..5239bcb9 --- /dev/null +++ b/src/ToolboxBundle/DependencyInjection/Compiler/AreaBrickRegistryPass.php @@ -0,0 +1,165 @@ +setAbstract(true); + $abstractBrickDefinition->addMethodCall('setLayoutManager', [new Reference(LayoutManagerInterface::class)]); + $abstractBrickDefinition->addMethodCall('setConfigManager', [new Reference(ConfigManagerInterface::class)]); + + $container->setDefinition(AbstractBaseAreabrick::class, $abstractBrickDefinition); + + // create abstract brick definition + $abstractConfigurableBrickDefinition = new ChildDefinition(AbstractBaseAreabrick::class); + $abstractConfigurableBrickDefinition->setClass(AbstractAreabrick::class); + $abstractConfigurableBrickDefinition->setAbstract(true); + $abstractConfigurableBrickDefinition->addMethodCall('setBrickConfigBuilder', [new Reference(BrickConfigBuilderInterface::class)]); + + $container->setDefinition(AbstractAreabrick::class, $abstractConfigurableBrickDefinition); + + // check for legacy naming + $pimcoreTaggedServices = $container->findTaggedServiceIds('pimcore.area.brick', true); + foreach ($pimcoreTaggedServices as $legacyId => $legacyTags) { + $legacyBrickDefinition = $container->getDefinition($legacyId); + if ($legacyBrickDefinition instanceof ChildDefinition && $legacyBrickDefinition->getParent() === AbstractAreabrick::class) { + throw new InvalidDefinitionException(sprintf( + 'Please use tag "%s" instead of "%s" to register your brick "%s" as a true toolbox area brick.', + 'toolbox.area.brick', + 'pimcore.area.brick', + $legacyId + )); + } + } + + // register toolbox bricks + $toolboxTaggedServices = $container->findTaggedServiceIds('toolbox.area.brick', true); + foreach ($toolboxTaggedServices as $id => $tags) { + $brickDefinition = $container->getDefinition($id); + + if (!$brickDefinition instanceof ChildDefinition) { + throw new InvalidDefinitionException(sprintf( + 'Areabrick "%s" needs to be a child of "%s"', + $id, + AbstractBaseAreabrick::class + )); + } + + if ($brickDefinition->hasMethodCall('setAreaBrickType')) { + throw new InvalidDefinitionException(sprintf( + 'Please remove methodCall "%s" from your brick "%s". The type declaration will be processed internally.', + 'setAreaBrickType', + $id + )); + } + + foreach ($tags as $attributes) { + $type = AbstractBaseAreabrick::AREABRICK_TYPE_EXTERNAL; + + if (str_starts_with($id, 'ToolboxBundle')) { + $type = AbstractBaseAreabrick::AREABRICK_TYPE_INTERNAL; + } + + if ($type === AbstractBaseAreabrick::AREABRICK_TYPE_EXTERNAL && in_array($attributes['id'], ToolboxConfig::TOOLBOX_TYPES, true)) { + throw new InvalidDefinitionException(sprintf( + 'ID "%s" for AreaBrick "%s is a reserved identifier. Please change the id of your custom AreaBrick. Internal IDs are: %s.', + $attributes['id'], + $id, + implode(', ', ToolboxConfig::TOOLBOX_TYPES) + )); + } + + $brickDefinition->addTag('pimcore.area.brick', ['id' => $attributes['id']]); + $brickDefinition->addMethodCall('setAreaBrickType', [$type]); + + if ($brickDefinition->getParent() === AbstractBaseAreabrick::class) { + $notEditDialogAwareBricks[] = $attributes['id']; + } + } + } + + // register simple toolbox bricks + $toolboxTaggedServices = $container->findTaggedServiceIds('toolbox.area.simple_brick', true); + foreach ($toolboxTaggedServices as $id => $tags) { + $simpleBrickDefinition = $container->getDefinition($id); + + if (!$simpleBrickDefinition instanceof ChildDefinition) { + throw new InvalidDefinitionException(sprintf( + 'Simple Areabrick "%s" needs to be a child of "%s"', + $id, + AbstractBaseAreabrick::class + )); + } + + if ($simpleBrickDefinition->getClass() !== null) { + throw new InvalidDefinitionException(sprintf('Simple Areabrick "%s" must not have a custom class!', $id)); + } + + $simpleBrickDefinition->setClass($simpleBrickDefinition->getParent() === AbstractAreabrick::class ? SimpleAreaBrickConfigurable::class : SimpleAreaBrick::class); + $simpleBrickDefinition->addMethodCall('setAreaBrickType', [AbstractBaseAreabrick::AREABRICK_TYPE_EXTERNAL]); + + foreach ($tags as $attributes) { + if (!isset($attributes['title']) || empty($attributes['title'])) { + throw new InvalidDefinitionException(sprintf('Simple Areabrick "%s" has an invalid title', $attributes['id'])); + } + + $simpleBrickDefinition->addMethodCall('setName', [$attributes['title']]); + + if (isset($attributes['description']) && !empty($attributes['description'])) { + $simpleBrickDefinition->addMethodCall('setDescription', [$attributes['description']]); + } + + if (isset($attributes['template']) && !empty($attributes['template'])) { + $simpleBrickDefinition->addMethodCall('setTemplate', [$attributes['template']]); + } + + if (isset($attributes['icon']) && !empty($attributes['icon'])) { + $simpleBrickDefinition->addMethodCall('setIcon', [$attributes['icon']]); + } + + $simpleBrickDefinition->addTag('pimcore.area.brick', ['id' => $attributes['id']]); + + if ($simpleBrickDefinition->getParent() === AbstractBaseAreabrick::class) { + $notEditDialogAwareBricks[] = $attributes['id']; + } + } + } + + if (count($notEditDialogAwareBricks) > 0 && $container->hasParameter('toolbox.area_brick.dialog_aware_bricks')) { + $requestedEditDialogAwareBricks = $container->getParameter('toolbox.area_brick.dialog_aware_bricks'); + foreach ($requestedEditDialogAwareBricks as $requestedEditDialogAwareBrickId) { + if (in_array($requestedEditDialogAwareBrickId, $notEditDialogAwareBricks, true)) { + throw new InvalidDefinitionException( + sprintf( + 'Areabrick "%s" has some dialog editables but has been registered as a non-configurable brick. Please set "%s" as parent class or remove the config node from custom_areas.%s', + $requestedEditDialogAwareBrickId, + AbstractAreabrick::class, + $requestedEditDialogAwareBrickId + ) + ); + } + } + } + } +} diff --git a/src/ToolboxBundle/DependencyInjection/Compiler/CalculatorRegistryPass.php b/src/ToolboxBundle/DependencyInjection/Compiler/CalculatorRegistryPass.php index fcab060c..5290d835 100644 --- a/src/ToolboxBundle/DependencyInjection/Compiler/CalculatorRegistryPass.php +++ b/src/ToolboxBundle/DependencyInjection/Compiler/CalculatorRegistryPass.php @@ -12,23 +12,8 @@ final class CalculatorRegistryPass implements CompilerPassInterface { use PriorityTaggedServiceTrait; - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { - /* @deprecated since 2.3. gets removed in 4.0 */ - if ($container->hasParameter('toolbox.deprecation.calculator_tags')) { - $preTaggedServices = $container->findTaggedServiceIds('toolbox.calculator', true); - $deprecationTags = $container->getParameter('toolbox.deprecation.calculator_tags'); - foreach ($deprecationTags as $tag) { - if (!in_array($tag[0], array_keys($preTaggedServices)) && $container->hasDefinition($tag[0])) { - $definition = $container->getDefinition($tag[0]); - $definition->addTag('toolbox.calculator', ['type' => $tag[1]]); - } - } - } - $taggedServices = $container->findTaggedServiceIds('toolbox.calculator', true); foreach ($taggedServices as $id => $tags) { $definition = $container->getDefinition(CalculatorRegistry::class); diff --git a/src/ToolboxBundle/DependencyInjection/Compiler/MembersBundlePass.php b/src/ToolboxBundle/DependencyInjection/Compiler/MembersBundlePass.php index 5c1723da..8f5d634e 100644 --- a/src/ToolboxBundle/DependencyInjection/Compiler/MembersBundlePass.php +++ b/src/ToolboxBundle/DependencyInjection/Compiler/MembersBundlePass.php @@ -10,11 +10,9 @@ class MembersBundlePass implements CompilerPassInterface { /** - * @param ContainerBuilder $container - * * @throws \Exception */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { if (!$container->hasDefinition('MembersBundle\Manager\RestrictionManager')) { return; @@ -29,10 +27,7 @@ public function process(ContainerBuilder $container) } } - /** - * @return array - */ - private function getRequiredServices() + private function getRequiredServices(): array { return [ \MembersBundle\Manager\RestrictionManager::class, diff --git a/src/ToolboxBundle/DependencyInjection/Compiler/StoreProviderPass.php b/src/ToolboxBundle/DependencyInjection/Compiler/StoreProviderPass.php index 9746f69a..2fbb4e1d 100644 --- a/src/ToolboxBundle/DependencyInjection/Compiler/StoreProviderPass.php +++ b/src/ToolboxBundle/DependencyInjection/Compiler/StoreProviderPass.php @@ -9,10 +9,7 @@ final class StoreProviderPass implements CompilerPassInterface { - /** - * @param ContainerBuilder $container - */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $definition = $container->getDefinition(StoreProviderRegistry::class); foreach ($container->findTaggedServiceIds('toolbox.editable.store_provider') as $id => $tags) { diff --git a/src/ToolboxBundle/DependencyInjection/Configuration.php b/src/ToolboxBundle/DependencyInjection/Configuration.php index 88d41484..91c16622 100644 --- a/src/ToolboxBundle/DependencyInjection/Configuration.php +++ b/src/ToolboxBundle/DependencyInjection/Configuration.php @@ -3,7 +3,8 @@ namespace ToolboxBundle\DependencyInjection; use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; -use Symfony\Component\Config\Definition\Builder\NodeDefinition; +use Symfony\Component\Config\Definition\Builder\EnumNodeDefinition; +use Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Form\Exception\InvalidConfigurationException; @@ -14,13 +15,10 @@ class Configuration implements ConfigurationInterface { - /** - * @return TreeBuilder - */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('toolbox'); + $treeBuilder = new TreeBuilder('toolbox'); + $rootNode = $treeBuilder->getRootNode(); $this->getConfigNode($rootNode); $this->addContextNode($rootNode); @@ -33,319 +31,384 @@ public function getConfigTreeBuilder() return $treeBuilder; } - /** - * @param ArrayNodeDefinition $rootNode - */ - public function addContextNode(ArrayNodeDefinition $rootNode) + public function addContextNode(ArrayNodeDefinition $rootNode): void { - $node = $rootNode + $rootNode ->children() ->arrayNode('context') ->useAttributeAsKey('name') ->prototype('array') ->children() - ->arrayNode('settings') - ->beforeNormalization() - ->ifTrue(function ($v) { - return $v['merge_with_root'] === false && (!empty($v['disabled_areas'])); - }) - ->then(function ($v) { - @trigger_error('Toolbox context conflict: "merge_with_root" is disabled but there are defined elements in "disabled_areas"', E_USER_ERROR); - - return $v; - }) - ->end() - ->beforeNormalization() - ->ifTrue(function ($v) { - return $v['merge_with_root'] === false && (!empty($v['enabled_areas'])); - }) - ->then(function ($v) { - @trigger_error('Toolbox context conflict: "merge_with_root" is disabled but there are defined elements in "enabled_areas"', E_USER_ERROR); - - return $v; - }) - ->end() - ->isRequired() - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('merge_with_root')->defaultValue(true)->end() - ->variableNode('disabled_areas')->defaultValue([])->end() - ->variableNode('enabled_areas')->defaultValue([])->end() - ->end() - ->end() - ->end(); + ->append($this->buildContextSettingsNode()) + ->append($this->buildFlagsConfiguration()) + ->append($this->buildAreasSection(true)) + ->append($this->buildAreasSection()) + ->append($this->buildCkEditorConfigSection()) + ->append($this->buildImageThumbnailSection()) + ->append($this->buildAreasAppearanceConfiguration('areas_appearance')) + ->append($this->buildAreasAppearanceConfiguration('snippet_areas_appearance')) + ->append($this->buildAreaBlockConfiguration()) + ->append($this->buildThemeConfiguration()) + ->append($this->buildDataAttributeConfiguration()) + ->end() + ->end() + ->end() + ->end(); + } - $this->getConfigNode($node); + public function getConfigNode(ArrayNodeDefinition $rootNode): void + { + $rootNode + ->children() + ->append($this->buildFlagsConfiguration()) + ->append($this->buildAreasSection(true)) + ->append($this->buildAreasSection()) + ->append($this->buildCkEditorConfigSection()) + ->append($this->buildImageThumbnailSection()) + ->append($this->buildAreasAppearanceConfiguration('areas_appearance')) + ->append($this->buildAreasAppearanceConfiguration('snippet_areas_appearance')) + ->append($this->buildAreaBlockConfiguration()) + ->append($this->buildThemeConfiguration()) + ->append($this->buildDataAttributeConfiguration()) + ->end(); + } - $node->end() + protected function buildContextSettingsNode(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('settings'); + + $treeBuilder + ->beforeNormalization() + ->ifTrue(function ($v) { + return $v['merge_with_root'] === false && (!empty($v['disabled_areas'])); + }) + ->then(function ($v) { + @trigger_error('Toolbox context conflict: "merge_with_root" is disabled but there are defined elements in "disabled_areas"', E_USER_ERROR); + }) ->end() - ->end(); + ->beforeNormalization() + ->ifTrue(function ($v) { + return $v['merge_with_root'] === false && (!empty($v['enabled_areas'])); + }) + ->then(function ($v) { + @trigger_error('Toolbox context conflict: "merge_with_root" is disabled but there are defined elements in "enabled_areas"', E_USER_ERROR); + }) + ->end() + ->isRequired() + ->addDefaultsIfNotSet() + ->children() + ->booleanNode('merge_with_root')->defaultValue(true)->end() + ->variableNode('disabled_areas')->defaultValue([])->end() + ->variableNode('enabled_areas')->defaultValue([])->end() + ->end(); + + return $treeBuilder; } - /** - * @param NodeDefinition $rootNode - */ - public function getConfigNode(NodeDefinition $rootNode) + protected function buildFlagsConfiguration(): ArrayNodeDefinition { - //@todo: get them dynamically!! - $allowedTypes = array_merge(ToolboxConfig::CORE_TYPES, ToolboxConfig::CUSTOM_TYPES); + $treeBuilder = new ArrayNodeDefinition('flags'); - $rootNode + $treeBuilder + ->addDefaultsIfNotSet() ->children() - ->arrayNode('flags') - ->addDefaultsIfNotSet() - ->children() - ->booleanNode('strict_column_counter')->defaultValue(false)->end() - ->booleanNode('use_dynamic_links')->defaultValue(false)->end() - ->end() - ->end() - ->arrayNode('areas') - ->validate() - ->ifTrue(function ($v) { - return count(array_diff(array_keys($v), ToolboxConfig::TOOLBOX_TYPES)) > 0; - }) - ->then(function ($v) { - $invalidTags = array_diff(array_keys($v), ToolboxConfig::TOOLBOX_TYPES); + ->booleanNode('strict_column_counter')->defaultValue(false)->end() + ->booleanNode('use_dynamic_links')->defaultValue(false)->end() + ->end(); - throw new InvalidConfigurationException(sprintf( - 'Invalid elements in toolbox "area" configuration: %s. to add custom areas, use the "custom_area" node. allowed tags for "area" are: %s', - implode(', ', $invalidTags), - implode(', ', ToolboxConfig::TOOLBOX_TYPES) - )); - }) - ->end() - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->arrayNode('config_elements') - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->enumNode('type')->isRequired()->values($allowedTypes)->end() - ->scalarNode('title')->defaultValue(null)->end() - ->scalarNode('description')->defaultValue(null)->end() - ->scalarNode('col_class')->defaultValue(null)->end() - ->variableNode('conditions')->defaultValue(null)->end() - ->variableNode('config')->defaultValue([])->end() - ->end() - ->validate() - ->ifTrue(function ($v) { - return $v['enabled'] === false; - }) - ->thenUnset() - ->end() - ->canBeUnset() - ->canBeDisabled() - ->treatnullLike(['enabled' => false]) + return $treeBuilder; + } - ->end() - ->end() - ->variableNode('config_parameter')->end() - ->end() - ->end() - ->end() - ->arrayNode('custom_areas') - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->arrayNode('config_elements') - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->scalarNode('type')->isRequired()->end() - ->scalarNode('title')->defaultValue(null)->end() - ->scalarNode('description')->defaultValue(null)->end() - ->scalarNode('col_class')->defaultValue(null)->end() - ->variableNode('conditions')->defaultValue(null)->end() - ->variableNode('config')->defaultValue([])->end() - ->end() - ->validate() - ->ifTrue(function ($v) { - return $v['enabled'] === false; - }) - ->thenUnset() - ->end() - ->canBeUnset() - ->canBeDisabled() - ->treatnullLike(['enabled' => false]) - ->end() - ->end() - ->variableNode('config_parameter')->end() + protected function buildCkEditorConfigSection(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('ckeditor'); + + $treeBuilder + ->addDefaultsIfNotSet() + ->children() + ->variableNode('config')->defaultValue([])->end() + ->variableNode('global_style_sets')->defaultValue([])->end() + ->arrayNode('area_editor') + ->children() + ->variableNode('config') + ->validate()->ifEmpty()->thenUnset()->end() ->end() ->end() ->end() - ->arrayNode('ckeditor') - ->addDefaultsIfNotSet() + ->arrayNode('object_editor') ->children() - ->variableNode('config')->defaultValue([])->end() - ->variableNode('global_style_sets')->defaultValue([])->end() - ->arrayNode('area_editor') - ->children() - ->variableNode('config') - ->validate()->ifEmpty()->thenUnset()->end() - ->end() - ->end() - ->end() - ->arrayNode('object_editor') - ->children() - ->variableNode('config') - ->validate()->ifEmpty()->thenUnset()->end() - ->end() - ->end() + ->variableNode('config') + ->validate()->ifEmpty()->thenUnset()->end() ->end() ->end() ->end() - ->arrayNode('image_thumbnails') - ->useAttributeAsKey('name') - ->prototype('scalar')->end() - ->end() - // @deprecated: remove with toolbox 4.0 - ->arrayNode('disallowed_subareas') - ->setDeprecated('The "%node%" option key is deprecated since version 2.3 and will be removed in Toolbox 4.0. Use the "areas_appearance" configuration key instead') - ->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->arrayNode('disallowed') - ->isRequired() - ->prototype('scalar')->end() - ->end() - ->end() + ->end(); + + return $treeBuilder; + } + + protected function buildImageThumbnailSection(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('image_thumbnails'); + + $treeBuilder + ->useAttributeAsKey('name') + ->prototype('scalar')->end(); + + return $treeBuilder; + } + + protected function buildAreasAppearanceConfiguration(string $type): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition($type); + + $treeBuilder + ->useAttributeAsKey('name') + ->prototype('array') + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('disallowed') + ->prototype('scalar')->end() + ->end() + ->arrayNode('allowed') + ->prototype('scalar')->end() ->end() ->end() - ->arrayNode('areas_appearance') - ->useAttributeAsKey('name') - ->prototype('array') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('disallowed') - ->prototype('scalar')->end() - ->end() - ->arrayNode('allowed') - ->prototype('scalar')->end() - ->end() - ->end() + ->end(); + + return $treeBuilder; + } + + protected function buildAreaBlockConfiguration(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('area_block_configuration'); + + $treeBuilder + ->addDefaultsIfNotSet() + ->children() + ->arrayNode('toolbar') + ->addDefaultsIfNotSet() + ->children() + ->integerNode('width')->defaultValue(172)->end() + ->integerNode('buttonWidth')->defaultValue(168)->end() + ->integerNode('buttonMaxCharacters')->defaultValue(20)->end() ->end() ->end() - // @deprecated: remove with toolbox 4.0 - ->variableNode('disallowed_content_snippet_areas') - ->setDeprecated('The "%node%" option is deprecated since version 2.3 and will be removed in Toolbox 4.0. Use the "snippet_areas_appearance" configuration key instead') + ->variableNode('groups')->defaultNull()->end() + ->enumNode('controlsAlign')->values(['top', 'right', 'left'])->defaultValue('top')->end() + ->enumNode('controlsTrigger')->values(['hover', 'fixed'])->defaultValue('hover')->end() + ->end(); + + return $treeBuilder; + } + + protected function buildThemeConfiguration(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('theme'); + + $treeBuilder + ->children() + ->scalarNode('layout') + ->cannotBeEmpty() ->end() - ->arrayNode('snippet_areas_appearance') - ->useAttributeAsKey('name') - ->prototype('array') - ->addDefaultsIfNotSet() - ->children() - ->arrayNode('disallowed') - ->prototype('scalar')->end() - ->end() - ->arrayNode('allowed') - ->prototype('scalar')->end() - ->end() - ->end() - ->end() + ->scalarNode('default_layout') + ->defaultValue(false) ->end() - ->arrayNode('area_block_configuration') + ->arrayNode('calculators') ->addDefaultsIfNotSet() ->children() - ->arrayNode('toolbar') - ->children() - ->scalarNode('title')->end() - ->integerNode('width')->end() - ->integerNode('x')->end() - ->integerNode('y')->end() - ->scalarNode('xAlign')->end() - ->scalarNode('xAlign')->end() - ->integerNode('buttonWidth')->end() - ->integerNode('buttonMaxCharacters')->end() - ->end() - ->end() - ->variableNode('groups')->end() + ->scalarNode('column_calculator')->defaultValue(ColumnCalculator::class)->end() + ->scalarNode('slide_calculator')->defaultValue(SlideColumnCalculator::class)->end() ->end() ->end() - ->arrayNode('theme') + ->arrayNode('grid') + ->addDefaultsIfNotSet() ->children() - ->scalarNode('layout') - ->cannotBeEmpty() - ->end() - ->scalarNode('default_layout') - ->defaultValue(false) - ->end() - ->arrayNode('calculators') - ->addDefaultsIfNotSet() - ->children() - ->scalarNode('column_calculator')->defaultValue(ColumnCalculator::class)->end() - ->scalarNode('ToolboxBundle\Calculator\ColumnCalculator')->defaultValue(ColumnCalculator::class) - ->setDeprecated('The "%node%" option is deprecated since version 2.3 and will be removed in Toolbox 4.0. Use "column_calculator" instead.') - ->end() - ->scalarNode('slide_calculator')->defaultValue(SlideColumnCalculator::class)->end() - ->scalarNode('ToolboxBundle\Calculator\SlideColumnCalculator')->defaultValue(SlideColumnCalculator::class) - ->setDeprecated('The "%node%" option is deprecated since version 2.3 and will be removed in Toolbox 4.0. Use "slide_calculator" instead.') - ->end() - ->end() - ->end() - ->arrayNode('grid') - ->addDefaultsIfNotSet() - ->children() - ->integerNode('grid_size')->min(0)->defaultValue(12)->end() - ->arrayNode('column_store') - ->useAttributeAsKey('name') - ->prototype('scalar')->end() - ->end() - ->arrayNode('breakpoints') - ->performNoDeepMerging() - ->prototype('array') - ->children() - ->scalarNode('identifier')->isRequired()->end() - ->scalarNode('name')->defaultValue(null)->end() - ->scalarNode('description')->defaultValue(null)->end() - ->end() - ->end() - ->end() - ->end() - ->end() - ->arrayNode('wrapper') + ->integerNode('grid_size')->min(0)->defaultValue(12)->end() + ->arrayNode('column_store') ->useAttributeAsKey('name') - ->prototype('array') + ->prototype('scalar')->end() + ->end() + ->arrayNode('breakpoints') ->performNoDeepMerging() - ->beforeNormalization() - ->ifTrue(function ($v) { - return is_array($v) && !isset($v['wrapper_classes']); - }) - ->then(function ($v) { - return array('wrapper_classes' => $v); - }) - ->end() + ->prototype('array') ->children() - ->arrayNode('wrapper_classes') - ->prototype('array') - ->children() - ->scalarNode('tag')->end() - ->scalarNode('class')->end() - ->scalarNode('attr')->end() - ->end() - ->end() - ->end() + ->scalarNode('identifier')->isRequired()->end() + ->scalarNode('name')->defaultValue(null)->end() + ->scalarNode('description')->defaultValue(null)->end() ->end() ->end() ->end() ->end() ->end() - ->arrayNode('data_attributes') + ->arrayNode('wrapper') ->useAttributeAsKey('name') - ->prototype('array') - ->beforeNormalization() - ->ifTrue(function ($v) { - return is_array($v) && !isset($v['values']); - }) - ->then(function ($v) { - return array('values' => $v); - }) - ->end() + ->prototype('array') + ->performNoDeepMerging() + ->beforeNormalization() + ->ifTrue(function ($v) { + return is_array($v) && !isset($v['wrapper_classes']); + }) + ->then(function ($v) { + return array('wrapper_classes' => $v); + }) + ->end() ->children() - ->variableNode('values')->end() + ->arrayNode('wrapper_classes') + ->prototype('array') + ->children() + ->scalarNode('tag')->end() + ->scalarNode('class')->end() + ->scalarNode('attr')->end() + ->end() + ->end() + ->end() ->end() ->end() ->end() ->end(); + + return $treeBuilder; + } + + protected function buildDataAttributeConfiguration(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('data_attributes'); + + $treeBuilder + ->useAttributeAsKey('name') + ->prototype('array') + ->beforeNormalization() + ->ifTrue(function ($v) { + return is_array($v) && !isset($v['values']); + }) + ->then(function ($v) { + return array('values' => $v); + }) + ->end() + ->children() + ->variableNode('values')->end() + ->end() + ->end(); + + return $treeBuilder; + } + + protected function buildAreasSection(bool $internalTypes = false): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition($internalTypes ? 'areas' : 'custom_areas'); + + $treeBuilder + ->validate() + ->ifTrue(function ($v) use ($internalTypes) { + if ($internalTypes === false) { + return false; + } + + return count(array_diff(array_keys($v), ToolboxConfig::TOOLBOX_TYPES)) > 0; + }) + ->then(function ($v) { + $invalidTags = array_diff(array_keys($v), ToolboxConfig::TOOLBOX_TYPES); + + throw new InvalidConfigurationException(sprintf( + 'Invalid elements in toolbox "area" configuration: %s. to add custom areas, use the "custom_area" node. allowed tags for "area" are: %s', + implode(', ', $invalidTags), + implode(', ', ToolboxConfig::TOOLBOX_TYPES) + )); + }) + ->end() + ->useAttributeAsKey('name') + ->prototype('array') + ->validate() + ->ifTrue(function ($v) { + $tabs = $v['tabs']; + + return count($tabs) > 0 && count(array_filter($v['config_elements'], function($configElement) use ($tabs) { + return !array_key_exists($configElement['tab'], $tabs); + })) > 0; + }) + ->then(function ($v) { + @trigger_error( + sprintf('Missing or wrong area tab definition in config_elements. Available tabs are: %s', implode(', ', array_keys($v['tabs']))), + E_USER_ERROR + ); + }) + ->end() + ->validate() + ->ifTrue(function ($v) { + $tabs = $v['tabs']; + + return count($tabs) === 0 && count(array_filter($v['config_elements'], function($configElement) { + return $configElement['tab'] !== null; + })) > 0; + }) + ->then(function ($v) { + @trigger_error('Unknown configured area tabs in config_elements. No tabs have been defined', E_USER_ERROR); + }) + ->end() + ->children() + ->append($this->buildConfigElementsTabSection()) + ->append($this->buildConfigElementsSection($internalTypes)) + ->variableNode('config_parameter')->end() + ->end() + ->end() + ; + + return $treeBuilder; + } + + protected function buildConfigElementsTabSection(): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('tabs'); + + $treeBuilder + ->useAttributeAsKey('name') + ->prototype('scalar') + ->validate() + ->ifNull()->thenEmptyArray() + ->end() + ->end(); + + return $treeBuilder; + } + + protected function buildConfigElementsSection(bool $internalTypes = false): ArrayNodeDefinition + { + $treeBuilder = new ArrayNodeDefinition('config_elements'); + + if ($internalTypes === true) { + //@todo: get them dynamically!! + $allowedTypes = array_merge(ToolboxConfig::CORE_TYPES, ToolboxConfig::CUSTOM_TYPES); + + $typeNode = new EnumNodeDefinition('type'); + $typeNode->isRequired()->values($allowedTypes)->end(); + } else { + $typeNode = new ScalarNodeDefinition('type'); + $typeNode->isRequired()->end(); + } + + $treeBuilder + ->useAttributeAsKey('name') + ->prototype('array') + ->addDefaultsIfNotSet() + ->children() + ->append($typeNode) + ->scalarNode('title')->defaultValue(null)->end() + ->scalarNode('description')->defaultValue(null)->end() + ->scalarNode('tab')->defaultValue(null)->end() + ->variableNode('config')->defaultValue([])->end() + ->end() + ->validate() + ->ifTrue(function ($v) { + return $v['enabled'] === false; + }) + ->thenUnset() + ->end() + ->canBeUnset() + ->canBeDisabled() + ->treatnullLike(['enabled' => false]) + ->end(); + + return $treeBuilder; } } diff --git a/src/ToolboxBundle/DependencyInjection/ToolboxExtension.php b/src/ToolboxBundle/DependencyInjection/ToolboxExtension.php index 6a4b5650..4b9ea277 100644 --- a/src/ToolboxBundle/DependencyInjection/ToolboxExtension.php +++ b/src/ToolboxBundle/DependencyInjection/ToolboxExtension.php @@ -12,20 +12,10 @@ class ToolboxExtension extends Extension implements PrependExtensionInterface { - /** - * @var array - */ - protected $contextMergeData = []; - - /** - * @var array - */ - protected $contextConfigData = []; - - /** - * @param ContainerBuilder $container - */ - public function prepend(ContainerBuilder $container) + protected array $contextMergeData = []; + protected array $contextConfigData = []; + + public function prepend(ContainerBuilder $container): void { $selfConfigs = $container->getExtensionConfig($this->getAlias()); @@ -81,13 +71,7 @@ public function prepend(ContainerBuilder $container) $this->contextMergeData = $data; } - /** - * @param array $configs - * @param ContainerBuilder $container - * - * @throws \Exception - */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { //append merge data foreach ($this->contextMergeData as $append) { @@ -109,7 +93,6 @@ public function load(array $configs, ContainerBuilder $container) $config = $this->processConfiguration($configuration, $configs); $this->validateToolboxContextConfig($config); - $this->allocateGoogleMapsApiKey($container); $contextResolver = $config['context_resolver']; @@ -119,41 +102,57 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('services.yml'); $configManagerDefinition = $container->getDefinition(ConfigManager::class); - $configManagerDefinition->setPublic(true); - - $config = $this->handleCalculatorDeprecation($config, $container); - $configManagerDefinition->addMethodCall('setConfig', [$config]); + $container->setParameter('toolbox.area_brick.dialog_aware_bricks', $this->determinateConfigDialogAwareBricks($config)); + //context resolver $definition = $container->getDefinition(ContextResolver::class); $definition->setClass($contextResolver); } - /** - * @param ContainerBuilder $container - */ - private function allocateGoogleMapsApiKey(ContainerBuilder $container) + private function determinateConfigDialogAwareBricks(array $config): array + { + $configDialogAwareBricks = []; + + foreach ($config['custom_areas'] as $areaId => $areaSection) { + if (isset($areaSection['config_elements']) && count($areaSection['config_elements']) > 0) { + $configDialogAwareBricks[] = $areaId; + } + } + + foreach ($config['context'] as $context) { + foreach ($context['custom_areas'] as $areaId => $areaSection) { + if (isset($areaSection['config_elements']) && count($areaSection['config_elements']) > 0) { + $configDialogAwareBricks[] = $areaId; + } + } + } + + return array_unique($configDialogAwareBricks); + } + + private function allocateGoogleMapsApiKey(ContainerBuilder $container): void { $googleBrowserApiKey = null; $googleSimpleApiKey = null; $pimcoreCoreConfig = $container->hasParameter('pimcore.config') ? $container->getParameter('pimcore.config') : []; - $pimcoreGoogleServiceConfig = isset($pimcoreCoreConfig['services']) && isset($pimcoreCoreConfig['services']['google']) ? $pimcoreCoreConfig['services']['google'] : []; + $pimcoreGoogleServiceConfig = isset($pimcoreCoreConfig['services'], $pimcoreCoreConfig['services']['google']) ? $pimcoreCoreConfig['services']['google'] : []; // browser api key - if ($container->hasParameter('pimcore_system_config.services.google.browserapikey') === true) { + if ($container->hasParameter('pimcore_system_config.services.google.browserapikey')) { $googleBrowserApiKey = $container->getParameter('pimcore_system_config.services.google.browserapikey'); - } elseif ($container->hasParameter('toolbox_google_service_browser_api_key') === true) { + } elseif ($container->hasParameter('toolbox_google_service_browser_api_key')) { $googleBrowserApiKey = $container->getParameter('toolbox_google_service_browser_api_key'); } elseif (isset($pimcoreGoogleServiceConfig['browser_api_key'])) { $googleBrowserApiKey = $pimcoreGoogleServiceConfig['browser_api_key']; } //simple api key - if ($container->hasParameter('pimcore_system_config.services.google.simpleapikey') === true) { + if ($container->hasParameter('pimcore_system_config.services.google.simpleapikey')) { $googleSimpleApiKey = $container->getParameter('pimcore_system_config.services.google.simpleapikey'); - } elseif ($container->hasParameter('toolbox_google_service_simple_api_key') === true) { + } elseif ($container->hasParameter('toolbox_google_service_simple_api_key')) { $googleSimpleApiKey = $container->getParameter('toolbox_google_service_simple_api_key'); } elseif (isset($pimcoreGoogleServiceConfig['simple_api_key'])) { $googleSimpleApiKey = $pimcoreGoogleServiceConfig['simple_api_key']; @@ -163,10 +162,7 @@ private function allocateGoogleMapsApiKey(ContainerBuilder $container) $container->setParameter('toolbox.google_maps.simple_api_key', $googleSimpleApiKey); } - /** - * @param array $config - */ - private function validateToolboxContextConfig($config) + private function validateToolboxContextConfig(array $config): void { foreach ($config['context'] as $contextId => $contextConfig) { //check if theme is same since it's not possible to merge different themes @@ -180,48 +176,4 @@ private function validateToolboxContextConfig($config) } } } - - /** - * @param array $config - * @param ContainerBuilder $container - * - * @return mixed - * - * @deprecated since 2.3. gets removed in 4.0 - */ - private function handleCalculatorDeprecation($config, ContainerBuilder $container) - { - $taggedCalculator = $container->findTaggedServiceIds('toolbox.calculator', true); - - $defaultColumnCalc = 'ToolboxBundle\Calculator\Bootstrap4\ColumnCalculator'; - $defaultSlideColumnCalc = 'ToolboxBundle\Calculator\Bootstrap4\SlideColumnCalculator'; - - $calculators = $config['theme']['calculators']; - $missingTags = []; - foreach ($calculators as $confName => $confValue) { - if ($confName === 'ToolboxBundle\Calculator\ColumnCalculator') { - if ($calculators['column_calculator'] !== $confValue && $confValue !== $defaultColumnCalc) { - $calculators['column_calculator'] = $confValue; - } - if (!in_array($confValue, array_keys($taggedCalculator))) { - $missingTags[] = [$confValue, 'column']; - } - } elseif ($confName === 'ToolboxBundle\Calculator\SlideColumnCalculator') { - if ($calculators['slide_calculator'] !== $confValue && $confValue !== $defaultSlideColumnCalc) { - $calculators['slide_calculator'] = $confValue; - } - if (!in_array($confValue, array_keys($taggedCalculator))) { - $missingTags[] = [$confValue, 'slide_column']; - } - } - } - - $config['theme']['calculators'] = $calculators; - - if (!empty($missingTags)) { - $container->setParameter('toolbox.deprecation.calculator_tags', $missingTags); - } - - return $config; - } } diff --git a/src/ToolboxBundle/Document/Areabrick/AbstractAreabrick.php b/src/ToolboxBundle/Document/Areabrick/AbstractAreabrick.php index 9ba7b0ec..1297f9bb 100644 --- a/src/ToolboxBundle/Document/Areabrick/AbstractAreabrick.php +++ b/src/ToolboxBundle/Document/Areabrick/AbstractAreabrick.php @@ -2,224 +2,25 @@ namespace ToolboxBundle\Document\Areabrick; -use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick; -use Pimcore\Model\Document\Tag; -use ToolboxBundle\Builder\BrickConfigBuilder; -use ToolboxBundle\Manager\ConfigManagerInterface; -use ToolboxBundle\Manager\LayoutManager; -use ToolboxBundle\ToolboxConfig; +use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration; +use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface; +use Pimcore\Model\Document; +use ToolboxBundle\Builder\BrickConfigBuilderInterface; -abstract class AbstractAreabrick extends AbstractTemplateAreabrick +abstract class AbstractAreabrick extends AbstractBaseAreabrick implements EditableDialogBoxInterface { - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected BrickConfigBuilderInterface $brickConfigBuilder; - /** - * @var BrickConfigBuilder - */ - protected $brickConfigBuilder; - - /** - * @var LayoutManager - */ - protected $layoutManager; - - /** - * @var string - */ - public $areaBrickType = 'internal'; - - const AREABRICK_TYPE_INTERNAL = 'internal'; - - const AREABRICK_TYPE_EXTERNAL = 'external'; - - /** - * @param string $type - */ - public function setAreaBrickType($type = self::AREABRICK_TYPE_INTERNAL) - { - $this->areaBrickType = $type; - } - - /** - * @return string - */ - public function getAreaBrickType() - { - return $this->areaBrickType; - } - - /** - * @param ConfigManagerInterface $configManager - */ - public function setConfigManager(ConfigManagerInterface $configManager) - { - $this->configManager = $configManager; - } - - /** - * @return \ToolboxBundle\Manager\ConfigManagerInterface object - */ - public function getConfigManager() - { - $space = $this->getAreaBrickType() === self::AREABRICK_TYPE_INTERNAL - ? ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL - : ConfigManagerInterface::AREABRICK_NAMESPACE_EXTERNAL; - - return $this->configManager->setAreaNameSpace($space); - } - - /** - * @param BrickConfigBuilder $brickConfigBuilder - */ - public function setBrickConfigBuilder(BrickConfigBuilder $brickConfigBuilder) + public function setBrickConfigBuilder(BrickConfigBuilderInterface $brickConfigBuilder): void { $this->brickConfigBuilder = $brickConfigBuilder; } - /** - * @return BrickConfigBuilder - */ - public function getBrickConfigBuilder() - { - return $this->brickConfigBuilder; - } - - /** - * @param LayoutManager $layoutManager - */ - public function setLayoutManager(LayoutManager $layoutManager) + public function getEditableDialogBoxConfiguration(Document\Editable $area, ?Document\Editable\Area\Info $info): EditableDialogBoxConfiguration { - $this->layoutManager = $layoutManager; - } - - /** - * {@inheritdoc} - */ - public function action(Tag\Area\Info $info) - { - if (!$this->getConfigManager() instanceof ConfigManagerInterface) { - throw new \Exception('Please register your AreaBrick "' . $info->getId() . '" as a service and set "toolbox.area.brick.base_brick" as parent.'); - } elseif ($this->getAreaBrickType() == self::AREABRICK_TYPE_INTERNAL && !in_array($info->getId(), ToolboxConfig::TOOLBOX_TYPES)) { - throw new \Exception('The "' . $info->getId() . '" AreaBrick has a invalid AreaBrickType. Please set type to "' . self::AREABRICK_TYPE_EXTERNAL . '".'); - } elseif ($this->getAreaBrickType() == self::AREABRICK_TYPE_EXTERNAL && in_array($info->getId(), ToolboxConfig::TOOLBOX_TYPES)) { - throw new \Exception('The "' . $info->getId() . '" AreaBrick is using a reserved id. Please change the id of your custom AreaBrick.'); - } - $configNode = $this->getConfigManager()->getAreaConfig($this->getId()); $themeOptions = $this->getConfigManager()->getConfig('theme'); - $configWindowData = $this->getBrickConfigBuilder()->buildElementConfig($this->getId(), $this->getName(), $info, $configNode, $themeOptions); - - $layoutDir = null; - - $view = $info->getView(); - $view->getParameters()->add([ - 'elementConfigBar' => $configWindowData, - 'additionalClassesData' => $this->configureAdditionalClasses($info, $configNode), - 'elementThemeConfig' => $this->layoutManager->getAreaThemeConfig($this->getId()), - 'areaId' => $this->getId() - ]); - return null; - } - - /** - * @param Tag\Area\Info $info - * @param array $configNode - * - * @return array - */ - private function configureAdditionalClasses(Tag\Area\Info $info, $configNode) - { - $classesArray = []; - - if (!isset($configNode['config_elements'])) { - return $classesArray; - } - - foreach ($configNode['config_elements'] as $name => $configElement) { - if (!isset($configElement['type'])) { - continue; - } - - if ($configElement['type'] === 'additionalClasses') { - $addClassField = $this->getDocumentTag($info->getDocument(), 'select', 'add_classes'); - if ($addClassField instanceof Tag\Select && !empty($addClassField->getValue())) { - $classesArray[] = (string) $addClassField->getValue(); - } - } elseif ($configElement['type'] === 'additionalClassesChained') { - $chainedElementName = explode('_', $name); - $chainedIncrementor = end($chainedElementName); - $addChainedClassField = $this->getDocumentTag($info->getDocument(), 'select', 'add_cclasses_' . $chainedIncrementor); - if ($addChainedClassField instanceof Tag\Select && !empty($addChainedClassField->getValue())) { - $classesArray[] = (string) $addChainedClassField->getValue(); - } - } - } - - return $classesArray; - } - - /** - * Internal Areas: load from Bundle - * External Areas: defined in AppBundle with a view in /app/Resources/views/Areas/*. - * - * {@inheritdoc} - */ - public function getTemplateLocation() - { - if ($this->getAreaBrickType() === self::AREABRICK_TYPE_INTERNAL) { - return static::TEMPLATE_LOCATION_BUNDLE; - } - - return static::TEMPLATE_LOCATION_GLOBAL; - } - - /** - * @param string $viewName - * - * @return string - */ - public function getTemplatePath($viewName = 'view') - { - return $this->layoutManager->getAreaTemplatePath($this->getId(), $viewName); - } - - /** - * {@inheritdoc} - */ - public function getTemplateSuffix() - { - return static::TEMPLATE_SUFFIX_TWIG; - } - - /** - * {@inheritdoc} - */ - public function getIcon() - { - if ($this->getAreaBrickType() == self::AREABRICK_TYPE_EXTERNAL) { - return null; - } - - return '/bundles/toolbox/areas/' . $this->getId() . '/icon.svg'; - } - - /** - * {@inheritdoc} - */ - public function getHtmlTagOpen(Tag\Area\Info $info) - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function getHtmlTagClose(Tag\Area\Info $info) - { - return ''; + return $this->brickConfigBuilder->buildDialogBoxConfiguration($info, $this->getId(), $configNode, $themeOptions); } } diff --git a/src/ToolboxBundle/Document/Areabrick/AbstractBaseAreabrick.php b/src/ToolboxBundle/Document/Areabrick/AbstractBaseAreabrick.php new file mode 100644 index 00000000..b3addfa4 --- /dev/null +++ b/src/ToolboxBundle/Document/Areabrick/AbstractBaseAreabrick.php @@ -0,0 +1,140 @@ +areaBrickType = $type; + } + + public function getAreaBrickType(): string + { + return $this->areaBrickType; + } + + public function setConfigManager(ConfigManagerInterface $configManager): void + { + $this->configManager = $configManager; + } + + public function getConfigManager(): ConfigManagerInterface + { + $space = $this->getAreaBrickType() === self::AREABRICK_TYPE_INTERNAL + ? ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL + : ConfigManagerInterface::AREABRICK_NAMESPACE_EXTERNAL; + + return $this->configManager->setAreaNameSpace($space); + } + + public function setLayoutManager(LayoutManager $layoutManager): void + { + $this->layoutManager = $layoutManager; + } + + public function action(Document\Editable\Area\Info $info): ?Response + { + $configNode = $this->getConfigManager()->getAreaConfig($this->getId()); + + $info->setParams(array_merge($info->getParams(), [ + 'additionalClassesData' => $this->configureAdditionalClasses($info, $configNode), + 'elementThemeConfig' => $this->layoutManager->getAreaThemeConfig($this->getId()), + 'areaId' => $this->getId(), + 'areaTemplateDirectory' => $this->getTemplateDirectoryName(), + ])); + + return null; + } + + private function configureAdditionalClasses(Document\Editable\Area\Info $info, array $configNode): array + { + $classesArray = []; + + if (!isset($configNode['config_elements'])) { + return $classesArray; + } + + foreach ($configNode['config_elements'] as $name => $configElement) { + if (!isset($configElement['type'])) { + continue; + } + + if ($configElement['type'] === 'additionalClasses') { + $addClassField = $this->getDocumentEditable($info->getDocument(), 'select', 'add_classes'); + if ($addClassField instanceof Document\Editable\Select && !empty($addClassField->getValue())) { + $classesArray[] = (string) $addClassField->getValue(); + } + } elseif ($configElement['type'] === 'additionalClassesChained') { + $chainedElementName = explode('_', $name); + $chainedIncrementor = end($chainedElementName); + $addChainedClassField = $this->getDocumentEditable($info->getDocument(), 'select', 'add_cclasses_' . $chainedIncrementor); + if ($addChainedClassField instanceof Document\Editable\Select && !empty($addChainedClassField->getValue())) { + $classesArray[] = (string) $addChainedClassField->getValue(); + } + } + } + + return $classesArray; + } + + public function getTemplateDirectoryName(): string + { + return $this->getId(); + } + + public function getTemplatePath(string $viewName = 'view'): string + { + return $this->layoutManager->getAreaTemplatePath($this->getId(), $this->getTemplateDirectoryName(), $viewName); + } + + public function getTemplateLocation(): string + { + if ($this->getAreaBrickType() === self::AREABRICK_TYPE_INTERNAL) { + return static::TEMPLATE_LOCATION_BUNDLE; + } + + return static::TEMPLATE_LOCATION_GLOBAL; + } + + public function getTemplate() + { + return null; + } + + public function getTemplateSuffix() + { + return static::TEMPLATE_SUFFIX_TWIG; + } + + public function getIcon(): ?string + { + if ($this->getAreaBrickType() === self::AREABRICK_TYPE_EXTERNAL) { + return null; + } + + return '/bundles/toolbox/areas/' . $this->getTemplateDirectoryName() . '/icon.svg'; + } + + public function getHtmlTagOpen(Document\Editable\Area\Info $info): string + { + return ''; + } + + public function getHtmlTagClose(Document\Editable\Area\Info $info): string + { + return ''; + } +} diff --git a/src/ToolboxBundle/Document/Areabrick/Accordion/Accordion.php b/src/ToolboxBundle/Document/Areabrick/Accordion/Accordion.php index 90a9f47c..afd32cb6 100644 --- a/src/ToolboxBundle/Document/Areabrick/Accordion/Accordion.php +++ b/src/ToolboxBundle/Document/Areabrick/Accordion/Accordion.php @@ -2,15 +2,16 @@ namespace ToolboxBundle\Document\Areabrick\Accordion; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Accordion extends AbstractAreabrick { /** * {@inheritdoc} */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); @@ -18,10 +19,10 @@ public function action(Info $info) if (isset($infoParams['toolboxAccordionId'])) { $id = $infoParams['toolboxAccordionId']; } else { - $id = uniqid('accordion-'); + $id = uniqid('accordion-', true); } - $info->getView()->getParameters()->add(['id' => $id]); + $info->setParam('id', $id); return null; } diff --git a/src/ToolboxBundle/Document/Areabrick/Anchor/Anchor.php b/src/ToolboxBundle/Document/Areabrick/Anchor/Anchor.php index dd7482f2..455e5312 100644 --- a/src/ToolboxBundle/Document/Areabrick/Anchor/Anchor.php +++ b/src/ToolboxBundle/Document/Areabrick/Anchor/Anchor.php @@ -2,15 +2,16 @@ namespace ToolboxBundle\Document\Areabrick\Anchor; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Anchor extends AbstractAreabrick { /** * {@inheritdoc} */ - public function action(Info $info) + public function action(Info $info): ?Response { return parent::action($info); } diff --git a/src/ToolboxBundle/Document/Areabrick/Columns/Columns.php b/src/ToolboxBundle/Document/Areabrick/Columns/Columns.php index 548737eb..58964597 100644 --- a/src/ToolboxBundle/Document/Areabrick/Columns/Columns.php +++ b/src/ToolboxBundle/Document/Areabrick/Columns/Columns.php @@ -2,43 +2,36 @@ namespace ToolboxBundle\Document\Areabrick\Columns; +use Pimcore\Model\Document\Editable\Checkbox; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Templating\EngineInterface; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; use ToolboxBundle\Registry\CalculatorRegistryInterface; class Columns extends AbstractAreabrick { - /** - * @var CalculatorRegistryInterface - */ - private $calculatorRegistry; - - /** - * @param CalculatorRegistryInterface $calculatorRegistry - */ - public function __construct(CalculatorRegistryInterface $calculatorRegistry) - { + private CalculatorRegistryInterface $calculatorRegistry; + private EngineInterface $templating; + + public function __construct( + CalculatorRegistryInterface $calculatorRegistry, + EngineInterface $templating + ) { $this->calculatorRegistry = $calculatorRegistry; + $this->templating = $templating; } - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); - $view = $info->getView(); - $editMode = $view->get('editmode'); + $editMode = $info->getParam('editmode'); - /** @var \Pimcore\Model\Document\Tag\Checkbox $equalHeightElement */ - $equalHeightElement = $this->getDocumentTag($info->getDocument(), 'checkbox', 'equal_height'); - $typeElement = $this->getDocumentTag($info->getDocument(), 'select', 'type'); - $gridAdjustment = $this->getDocumentTag($info->getDocument(), 'columnadjuster', 'columnadjuster')->getData(); + /** @var Checkbox $equalHeightElement */ + $equalHeightElement = $this->getDocumentEditable($info->getDocument(), 'checkbox', 'equal_height'); + $typeElement = $this->getDocumentEditable($info->getDocument(), 'select', 'type'); + $gridAdjustment = $this->getDocumentEditable($info->getDocument(), 'columnadjuster', 'columnadjuster')->getData(); $equalHeight = $equalHeightElement->isChecked() && $editMode === false; $type = $typeElement->getData(); @@ -46,7 +39,7 @@ public function action(Info $info) $partialName = ''; $customColumnConfiguration = null; - if ($gridAdjustment !== false) { + if (is_array($gridAdjustment) && count($gridAdjustment) > 0) { $customColumnConfiguration = [$type => $gridAdjustment]; } @@ -56,7 +49,7 @@ public function action(Info $info) ->calculateColumns($type, $customColumnConfiguration); if (!empty($columns)) { - if ($this->container->get('templating')->exists($this->getTemplatePath($type))) { + if ($this->templating->exists($this->getTemplatePath($type))) { $partialName = $type; } else { $t = explode('_', $type); @@ -68,12 +61,14 @@ public function action(Info $info) } } - $view->getParameters()->add([ - 'type' => $type . ($gridAdjustment !== false ? '-grid-adjuster' : ''), + $info->setParams(array_merge($info->getParams(), [ + 'type' => $type . ($customColumnConfiguration !== null ? '-grid-adjuster' : ''), 'columns' => $columns, 'partialName' => $partialName, 'equalHeight' => $equalHeight - ]); + ])); + + return null; } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/Container/Container.php b/src/ToolboxBundle/Document/Areabrick/Container/Container.php index 6461bf1b..401e645e 100644 --- a/src/ToolboxBundle/Document/Areabrick/Container/Container.php +++ b/src/ToolboxBundle/Document/Areabrick/Container/Container.php @@ -2,15 +2,16 @@ namespace ToolboxBundle\Document\Areabrick\Container; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Container extends AbstractAreabrick { /** * {@inheritdoc} */ - public function action(Info $info) + public function action(Info $info): ?Response { return parent::action($info); } diff --git a/src/ToolboxBundle/Document/Areabrick/Content/Content.php b/src/ToolboxBundle/Document/Areabrick/Content/Content.php index 54623f2f..f71af261 100644 --- a/src/ToolboxBundle/Document/Areabrick/Content/Content.php +++ b/src/ToolboxBundle/Document/Areabrick/Content/Content.php @@ -2,15 +2,16 @@ namespace ToolboxBundle\Document\Areabrick\Content; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Content extends AbstractAreabrick { /** * {@inheritdoc} */ - public function action(Info $info) + public function action(Info $info): ?Response { return parent::action($info); } diff --git a/src/ToolboxBundle/Document/Areabrick/Download/Download.php b/src/ToolboxBundle/Document/Areabrick/Download/Download.php index be3321ba..624f5eed 100644 --- a/src/ToolboxBundle/Document/Areabrick/Download/Download.php +++ b/src/ToolboxBundle/Document/Areabrick/Download/Download.php @@ -2,37 +2,28 @@ namespace ToolboxBundle\Document\Areabrick\Download; -use Pimcore\Db\ZendCompatibility\QueryBuilder; -use Pimcore\Model\Document\Tag\Relations; +use Pimcore\Model\Document\Editable\Relations; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Connector\BundleConnector; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; use Pimcore\Model\Asset; class Download extends AbstractAreabrick { - /** - * @var BundleConnector - */ - protected $bundleConnector; - - /** - * @param BundleConnector $bundleConnector - */ + protected BundleConnector $bundleConnector; + public function __construct(BundleConnector $bundleConnector) { $this->bundleConnector = $bundleConnector; } - /** - * {@inheritdoc} - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); /** @var Relations $downloadField */ - $downloadField = $this->getDocumentTag($info->getDocument(), 'relations', 'downloads'); + $downloadField = $this->getDocumentEditable($info->getDocument(), 'relations', 'downloads'); $assets = []; if (!$downloadField->isEmpty()) { @@ -46,19 +37,12 @@ public function action(Info $info) } } - $info->getView()->getParameters()->add([ - 'downloads' => $assets - ]); + $info->setParam('downloads', $assets); return null; } - /** - * @param Asset $node - * - * @return Asset[] - */ - protected function getByFile(Asset $node) + protected function getByFile(Asset $node): array { if (!$this->hasMembersBundle()) { return [$node]; @@ -73,12 +57,7 @@ protected function getByFile(Asset $node) return []; } - /** - * @param Asset\Folder $node - * - * @return Asset[] - */ - protected function getByFolder(Asset\Folder $node) + protected function getByFolder(Asset\Folder $node): array { $assetListing = new Asset\Listing(); $fullPath = rtrim($node->getFullPath(), '/') . '/'; @@ -86,7 +65,7 @@ protected function getByFolder(Asset\Folder $node) $assetListing->addConditionParam('type != ?', 'folder'); if ($this->hasMembersBundle()) { - $assetListing->onCreateQuery(function (QueryBuilder $query) use ($assetListing) { + $assetListing->onCreateQueryBuilder(function (\Doctrine\DBAL\Query\QueryBuilder $query) use ($assetListing) { $this->bundleConnector->getBundleService(\MembersBundle\Security\RestrictionQuery::class) ->addRestrictionInjection($query, $assetListing, 'assets.id'); }); @@ -98,26 +77,17 @@ protected function getByFolder(Asset\Folder $node) return $assetListing->getAssets(); } - /** - * @return bool - */ - protected function hasMembersBundle() + protected function hasMembersBundle(): bool { return $this->bundleConnector->hasBundle('MembersBundle\MembersBundle'); } - /** - * @return string - */ - public function getName() + public function getName(): string { return 'Downloads'; } - /** - * @return string - */ - public function getDescription() + public function getDescription(): string { return 'Toolbox Downloads'; } diff --git a/src/ToolboxBundle/Document/Areabrick/Gallery/Gallery.php b/src/ToolboxBundle/Document/Areabrick/Gallery/Gallery.php index ce86ad78..41194f97 100644 --- a/src/ToolboxBundle/Document/Areabrick/Gallery/Gallery.php +++ b/src/ToolboxBundle/Document/Areabrick/Gallery/Gallery.php @@ -2,61 +2,43 @@ namespace ToolboxBundle\Document\Areabrick\Gallery; +use Pimcore\Model\Document\Editable\Relations; use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; +use Pimcore\Model\Asset; class Gallery extends AbstractAreabrick { - /** - * @param Info $info - * - * @return Response|void|null - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); $infoParams = $info->getParams(); - if (isset($infoParams['toolboxGalleryId'])) { - $id = $infoParams['toolboxGalleryId']; - } else { - $id = uniqid('gallery-'); - } + $id = $infoParams['toolboxGalleryId'] ?? uniqid('gallery-', true); - /** @var \Pimcore\Model\Document\Tag\Relations $imagesField */ - $imagesField = $this->getDocumentTag($info->getDocument(), 'relations', 'images'); + /** @var Relations $imagesField */ + $imagesField = $this->getDocumentEditable($info->getDocument(), 'relations', 'images'); - $info->getView()->getParameters()->add([ + $info->setParams(array_merge($info->getParams(), [ 'galleryId' => $id, 'images' => $this->getAssetArray($imagesField->getElements()) - ]); + ])); + + return null; } - /** - * @return string - */ - public function getName() + public function getName(): string { return 'Gallery'; } - /** - * @return string - */ - public function getDescription() + public function getDescription(): string { return 'Toolbox Gallery'; } - /** - * @param array $data - * - * @return array - */ - public function getAssetArray($data) + public function getAssetArray(array $data): array { if (empty($data)) { return []; @@ -65,11 +47,11 @@ public function getAssetArray($data) $assets = []; foreach ($data as $element) { - if ($element instanceof \Pimcore\Model\Asset\Image) { + if ($element instanceof Asset\Image) { $assets[] = $element; - } elseif ($element instanceof \Pimcore\Model\Asset\Folder) { + } elseif ($element instanceof Asset\Folder) { foreach ($element->getChildren() as $child) { - if ($child instanceof \Pimcore\Model\Asset\Image) { + if ($child instanceof Asset\Image) { $assets[] = $child; } } diff --git a/src/ToolboxBundle/Document/Areabrick/GoogleMap/GoogleMap.php b/src/ToolboxBundle/Document/Areabrick/GoogleMap/GoogleMap.php index ddf00e1d..a4d4a022 100644 --- a/src/ToolboxBundle/Document/Areabrick/GoogleMap/GoogleMap.php +++ b/src/ToolboxBundle/Document/Areabrick/GoogleMap/GoogleMap.php @@ -2,52 +2,44 @@ namespace ToolboxBundle\Document\Areabrick\GoogleMap; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class GoogleMap extends AbstractAreabrick { - /** - * string. - */ - protected $googleMapsHostUrl; - - /** - * GoogleMap constructor. - * - * @param string $googleMapsHostUrl - */ - public function __construct($googleMapsHostUrl = '') + protected string $googleMapsHostUrl; + + public function __construct(string $googleMapsHostUrl = '') { $this->googleMapsHostUrl = $googleMapsHostUrl; } - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); - $info->getView()->getParameters()->add(['googleMapsHostUrl' => $this->googleMapsHostUrl]); + $info->setParam('googleMapsHostUrl', $this->googleMapsHostUrl); + + return null; + } + + public function getTemplateDirectoryName(): string + { + return 'google-map'; + } + + public function getTemplate(): string + { + return sprintf('@Toolbox/areas/%s/view.%s', $this->getTemplateDirectoryName(), $this->getTemplateSuffix()); } - /** - * @return string - */ - public function getName() + public function getName(): string { return 'Google Map'; } - /** - * @return string - */ - public function getDescription() + public function getDescription(): string { return 'Toolbox Google Map'; } diff --git a/src/ToolboxBundle/Document/Areabrick/Headline/Headline.php b/src/ToolboxBundle/Document/Areabrick/Headline/Headline.php index b233b76e..6af8a2cd 100644 --- a/src/ToolboxBundle/Document/Areabrick/Headline/Headline.php +++ b/src/ToolboxBundle/Document/Areabrick/Headline/Headline.php @@ -2,31 +2,29 @@ namespace ToolboxBundle\Document\Areabrick\Headline; +use Pimcore\File; +use Pimcore\Model\Document\Editable\Input; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Headline extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); $anchorName = null; - /** @var \Pimcore\Model\Document\Tag\Input $anchorNameElement */ - $anchorNameElement = $this->getDocumentTag($info->getDocument(), 'input', 'anchor_name'); + /** @var Input $anchorNameElement */ + $anchorNameElement = $this->getDocumentEditable($info->getDocument(), 'input', 'anchor_name'); if (!$anchorNameElement->isEmpty()) { - $anchorName = \Pimcore\File::getValidFilename($anchorNameElement->getData()); + $anchorName = File::getValidFilename($anchorNameElement->getData()); } - $info->getView()->getParameters()->add(['anchorName' => $anchorName]); + $info->setParam('anchorName', $anchorName); + + return null; } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/IFrame/IFrame.php b/src/ToolboxBundle/Document/Areabrick/IFrame/IFrame.php index 7ae60865..ff0e5a44 100644 --- a/src/ToolboxBundle/Document/Areabrick/IFrame/IFrame.php +++ b/src/ToolboxBundle/Document/Areabrick/IFrame/IFrame.php @@ -4,29 +4,22 @@ use GuzzleHttp\Client; use GuzzleHttp\Exception\RequestException; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class IFrame extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); - $view = $info->getView(); - $iFrameUrl = $this->getDocumentTag($info->getDocument(), 'input', 'url')->getData(); - $initialHeight = $this->getDocumentTag($info->getDocument(), 'numeric', 'iheight')->getData(); + $iFrameUrl = $this->getDocumentEditable($info->getDocument(), 'input', 'url')->getData(); + $initialHeight = $this->getDocumentEditable($info->getDocument(), 'numeric', 'iheight')->getData(); $isValid = true; $errorMessage = null; - if (!empty($iFrameUrl) && $view->get('editmode') === true) { + if (!empty($iFrameUrl) && $info->getParam('editmode') === true) { $response = $this->checkIfUrlIsEmbeddable($iFrameUrl); if ($response !== true) { $isValid = false; @@ -34,20 +27,17 @@ public function action(Info $info) } } - $view->getParameters()->add([ + $info->setParams(array_merge($info->getParams(), [ 'isValid' => $isValid, 'errorMessage' => $errorMessage, 'initialHeight' => is_numeric($initialHeight) ? (int) $initialHeight : null, 'iFrameUrl' => $iFrameUrl - ]); + ])); + + return null; } - /** - * @param string $iFrameUrl - * - * @return bool|string - */ - private function checkIfUrlIsEmbeddable($iFrameUrl) + private function checkIfUrlIsEmbeddable($iFrameUrl): bool|string { $client = new Client(); @@ -72,12 +62,22 @@ private function checkIfUrlIsEmbeddable($iFrameUrl) return true; } - public function getName() + public function getTemplateDirectoryName(): string + { + return 'iframe'; + } + + public function getTemplate(): string + { + return sprintf('@Toolbox/areas/%s/view.%s', $this->getTemplateDirectoryName(), $this->getTemplateSuffix()); + } + + public function getName(): string { return 'iFrame'; } - public function getDescription() + public function getDescription(): string { return 'Toolbox iFrame'; } diff --git a/src/ToolboxBundle/Document/Areabrick/Image/Image.php b/src/ToolboxBundle/Document/Areabrick/Image/Image.php index f31edc52..9f48e294 100644 --- a/src/ToolboxBundle/Document/Areabrick/Image/Image.php +++ b/src/ToolboxBundle/Document/Areabrick/Image/Image.php @@ -2,21 +2,15 @@ namespace ToolboxBundle\Document\Areabrick\Image; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Image extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { - parent::action($info); + return parent::action($info); } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/LinkList/LinkList.php b/src/ToolboxBundle/Document/Areabrick/LinkList/LinkList.php index f386239b..43a065d6 100644 --- a/src/ToolboxBundle/Document/Areabrick/LinkList/LinkList.php +++ b/src/ToolboxBundle/Document/Areabrick/LinkList/LinkList.php @@ -3,38 +3,25 @@ namespace ToolboxBundle\Document\Areabrick\LinkList; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; class LinkList extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function getTemplateDirectoryName(): string { - parent::action($info); - - $flags = $this->configManager->getConfig('flags'); - $useDynamicLinks = $flags['use_dynamic_links']; - - $info->getView()->getParameters()->add(['useDynamicLinks' => $useDynamicLinks]); + return 'link-list'; } - public function getViewTemplate() + public function getTemplate(): string { - return 'ToolboxBundle:Areas/linkList:view.' . $this->getTemplateSuffix(); + return sprintf('@Toolbox/areas/%s/view.%s', $this->getTemplateDirectoryName(), $this->getTemplateSuffix()); } - public function getName() + public function getName(): string { return 'Link List'; } - public function getDescription() + public function getDescription(): string { return 'Toolbox Link List'; } diff --git a/src/ToolboxBundle/Document/Areabrick/ParallaxContainer/ParallaxContainer.php b/src/ToolboxBundle/Document/Areabrick/ParallaxContainer/ParallaxContainer.php index 8eb71500..5ce1acd5 100644 --- a/src/ToolboxBundle/Document/Areabrick/ParallaxContainer/ParallaxContainer.php +++ b/src/ToolboxBundle/Document/Areabrick/ParallaxContainer/ParallaxContainer.php @@ -2,36 +2,38 @@ namespace ToolboxBundle\Document\Areabrick\ParallaxContainer; +use Pimcore\Translation\Translator; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Templating\EngineInterface; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag; +use Pimcore\Model\Document\Editable; use Pimcore\Model\Asset; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; -use Symfony\Component\Translation\TranslatorInterface; class ParallaxContainer extends AbstractAreabrick { - /** - * @param Tag\Area\Info $info - * - * @return null|Response|void - * - * @throws \Exception - */ - public function action(Tag\Area\Info $info) + private Translator $translator; + private EngineInterface $templating; + + public function __construct(Translator $translator, EngineInterface $templating) + { + $this->translator = $translator; + $this->templating = $templating; + } + + public function action(Editable\Area\Info $info): ?Response { parent::action($info); $config = $this->getConfigManager()->getAreaParameterConfig('parallaxContainer'); - /** @var Tag\Relation $parallaxBackgroundElement */ - $parallaxBackgroundElement = $this->getDocumentTag($info->getDocument(), 'relation', 'background_image'); + /** @var Editable\Relation $parallaxBackgroundElement */ + $parallaxBackgroundElement = $this->getDocumentEditable($info->getDocument(), 'relation', 'background_image'); $parallaxBackground = $parallaxBackgroundElement->getElement(); - $parallaxBackgroundColor = $this->getDocumentTag($info->getDocument(), 'select', 'background_color')->getData(); + $parallaxBackgroundColor = $this->getDocumentEditable($info->getDocument(), 'select', 'background_color')->getData(); - $parallaxTemplate = $this->getDocumentTag($info->getDocument(), 'select', 'template')->getData(); - $parallaxBehind = $this->getDocumentTag($info->getDocument(), 'parallaximage', 'image_behind'); - $parallaxFront = $this->getDocumentTag($info->getDocument(), 'parallaximage', 'image_front'); + $parallaxTemplate = $this->getDocumentEditable($info->getDocument(), 'select', 'template')->getData(); + $parallaxBehind = $this->getDocumentEditable($info->getDocument(), 'parallaximage', 'image_behind'); + $parallaxFront = $this->getDocumentEditable($info->getDocument(), 'parallaximage', 'image_front'); $backgroundMode = isset($config['background_mode']) ? $config['background_mode'] : 'wrap'; $backgroundImageMode = isset($config['background_image_mode']) ? $config['background_image_mode'] : 'data'; @@ -39,83 +41,75 @@ public function action(Tag\Area\Info $info) $backgroundTags = $this->getBackgroundTags($parallaxBackground, $parallaxBackgroundColor, $config, 'section'); $backgroundColorClass = $this->getBackgroundColorClass($parallaxBackgroundColor, $config, 'section'); - /** @var EngineInterface $templating */ - $templating = $this->container->get('templating'); - /** @var TranslatorInterface $translator */ - $translator = $this->container->get('pimcore.translator'); - $behindElements = !empty($parallaxBehind) - ? $templating->render( - $this->getTemplatePath('Partial/behind-front-elements'), + ? $this->templating->render( + $this->getTemplatePath('partial/behind-front-elements'), ['elements' => $parallaxBehind, 'backgroundImageMode' => $backgroundImageMode, 'document' => $info->getDocument()] ) : null; $frontElements = !empty($parallaxFront) - ? $templating->render( - $this->getTemplatePath('Partial/behind-front-elements'), + ? $this->templating->render( + $this->getTemplatePath('partial/behind-front-elements'), ['elements' => $parallaxFront, 'backgroundImageMode' => $backgroundImageMode, 'document' => $info->getDocument()] ) : null; - $info->getView()->getParameters()->add([ + $info->setParams(array_merge($info->getParams(), [ 'parallaxTemplate' => $parallaxTemplate, 'backgroundMode' => $backgroundMode, 'backgroundTags' => $backgroundTags, 'backgroundColorClass' => $backgroundColorClass, 'behindElements' => $behindElements, 'frontElements' => $frontElements, - 'sectionContent' => $this->_buildSectionContent($info, $templating, $translator) - ]); + 'sectionContent' => $this->_buildSectionContent($info) + ])); + + return null; } /** - * @param Tag\Area\Info $info - * @param EngineInterface $templating - * @param TranslatorInterface $translator + * @param Editable\Area\Info $info * * @return string * * @throws \Exception */ - private function _buildSectionContent(Tag\Area\Info $info, $templating, $translator) + private function _buildSectionContent(Editable\Area\Info $info) { ob_start(); $config = $this->getConfigManager()->getAreaParameterConfig('parallaxContainerSection'); - /** @var Tag\Areablock $sectionBlock */ - $sectionBlock = $this->getDocumentTag($info->getDocument(), 'block', 'pcB', ['default' => 1]); + /** @var Editable\Areablock $sectionBlock */ + $sectionBlock = $this->getDocumentEditable($info->getDocument(), 'block', 'pcB', ['default' => 1]); $loopIndex = 1; while ($sectionBlock->loop()) { $sectionConfig = ''; - /** @var Tag\Relation $parallaxBackgroundElement */ - $parallaxBackgroundElement = $this->getDocumentTag($info->getDocument(), 'relation', 'background_image'); + /** @var Editable\Relation $parallaxBackgroundElement */ + $parallaxBackgroundElement = $this->getDocumentEditable($info->getDocument(), 'relation', 'background_image'); $parallaxBackground = $parallaxBackgroundElement->getElement(); - $parallaxBackgroundColor = $this->getDocumentTag($info->getDocument(), 'select', 'background_color')->getData(); + $parallaxBackgroundColor = $this->getDocumentEditable($info->getDocument(), 'select', 'background_color')->getData(); $backgroundTags = $this->getBackgroundTags($parallaxBackground, $parallaxBackgroundColor, $config, 'section'); $backgroundColorClass = $this->getBackgroundColorClass($parallaxBackgroundColor, $config, 'section'); - $template = $this->getDocumentTag($info->getDocument(), 'select', 'template')->getData(); - $containerWrapper = $this->getDocumentTag($info->getDocument(), 'select', 'container_type')->getData(); + $template = $this->getDocumentEditable($info->getDocument(), 'select', 'template')->getData(); + $containerWrapper = $this->getDocumentEditable($info->getDocument(), 'select', 'container_type')->getData(); $areaArgs = ['name' => 'pcs', 'type' => 'parallaxContainer', 'document' => $info->getDocument()]; - $areaBlock = $templating->render('@Toolbox/Helper/areablock.' . $this->getTemplateSuffix(), $areaArgs); + $areaBlock = $this->templating->render('@Toolbox/helper/areablock.' . $this->getTemplateSuffix(), $areaArgs); if ($containerWrapper !== 'none') { $wrapperArgs = ['containerWrapperClass' => $containerWrapper, 'document' => $info->getDocument()]; - $wrapContent = $templating->render($this->getTemplatePath('Wrapper/container-wrapper'), $wrapperArgs); + $wrapContent = $this->templating->render($this->getTemplatePath('wrapper/container-wrapper'), $wrapperArgs); $areaBlock = sprintf($wrapContent, $areaBlock); } - if ($info->getView()->get('editmode') === true) { - $configNode = $this->getConfigManager()->getAreaConfig('parallaxContainerSection'); - $sectionConfig = $this->getBrickConfigBuilder()->buildElementConfig('parallaxContainerSection', 'Parallax Container Section', $info, $configNode); - - if ($containerWrapper === 'none' && strpos($areaBlock, 'toolbox-columns') !== false) { - $message = $translator->trans('You\'re using columns without a valid container wrapper.', [], 'admin'); - $messageWrap = $templating->render('@Toolbox/Helper/field-alert.' . $this->getTemplateSuffix(), [ + if ($info->getParam('editmode') === true) { + if ($containerWrapper === 'none' && str_contains($areaBlock, 'toolbox-columns')) { + $message = $this->translator->trans('You\'re using columns without a valid container wrapper.', [], 'admin'); + $messageWrap = $this->templating->render('@Toolbox/helper/field-alert.' . $this->getTemplateSuffix(), [ 'type' => 'danger', 'message' => $message, 'document' => $info->getDocument() @@ -136,13 +130,10 @@ private function _buildSectionContent(Tag\Area\Info $info, $templating, $transla $loopIndex++; - echo $sectionConfig; - echo $templating->render($this->getTemplatePath('section'), $sectionArgs); + echo $this->templating->render($this->getTemplatePath('section'), $sectionArgs); } - $string = ob_get_clean(); - - return $string; + return ob_get_clean(); } /** @@ -157,8 +148,8 @@ private function _buildSectionContent(Tag\Area\Info $info, $templating, $transla */ private function getBackgroundTags($backgroundImage, $backgroundColor, $config = [], $type = 'parallax') { - $backgroundImageMode = isset($config['background_image_mode']) ? $config['background_image_mode'] : 'data'; - $backgroundColorMode = isset($config['background_color_mode']) ? $config['background_color_mode'] : 'data'; + $backgroundImageMode = $config['background_image_mode'] ?? 'data'; + $backgroundColorMode = $config['background_color_mode'] ?? 'data'; $thumbnail = $type === 'parallax' ? $this->configManager->getImageThumbnailFromConfig('parallax_background') : $this->configManager->getImageThumbnailFromConfig('parallax_section_background'); @@ -187,14 +178,14 @@ private function getBackgroundTags($backgroundImage, $backgroundColor, $config = if (count($styles) > 0) { $str .= 'style="'; - $str .= join(' ', array_map(function ($key) use ($styles) { + $str .= implode(' ', array_map(static function ($key) use ($styles) { return $key . ':' . $styles[$key] . ';'; }, array_keys($styles))); $str .= '"'; } if (count($data) > 0) { - $str .= join(' ', array_map(function ($key) use ($data) { + $str .= implode(' ', array_map(static function ($key) use ($data) { return 'data-' . $key . '="' . $data[$key] . '"'; }, array_keys($data))); } @@ -211,7 +202,7 @@ private function getBackgroundTags($backgroundImage, $backgroundColor, $config = */ private function getBackgroundColorClass($backgroundColor, $config = [], $type = 'parallax') { - $mode = isset($config['background_color_mode']) ? $config['background_color_mode'] : 'data'; + $mode = $config['background_color_mode'] ?? 'data'; if ($backgroundColor === 'no-background-color' || empty($backgroundColor) || $mode !== 'class') { return ''; } @@ -219,10 +210,20 @@ private function getBackgroundColorClass($backgroundColor, $config = [], $type = return $backgroundColor; } + public function getTemplateDirectoryName(): string + { + return 'parallax-container'; + } + + public function getTemplate(): string + { + return sprintf('@Toolbox/areas/%s/view.%s', $this->getTemplateDirectoryName(), $this->getTemplateSuffix()); + } + /** * @return string */ - public function getName() + public function getName(): string { return 'Parallax Container'; } @@ -230,7 +231,7 @@ public function getName() /** * @return string */ - public function getDescription() + public function getDescription(): string { return 'Toolbox Parallax Container'; } diff --git a/src/ToolboxBundle/Document/Areabrick/Separator/Separator.php b/src/ToolboxBundle/Document/Areabrick/Separator/Separator.php index 08aebd3b..85d122ea 100644 --- a/src/ToolboxBundle/Document/Areabrick/Separator/Separator.php +++ b/src/ToolboxBundle/Document/Areabrick/Separator/Separator.php @@ -2,21 +2,15 @@ namespace ToolboxBundle\Document\Areabrick\Separator; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Separator extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { - parent::action($info); + return parent::action($info); } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/SlideColumns/SlideColumns.php b/src/ToolboxBundle/Document/Areabrick/SlideColumns/SlideColumns.php index eb1ae4c0..f5ae077d 100644 --- a/src/ToolboxBundle/Document/Areabrick/SlideColumns/SlideColumns.php +++ b/src/ToolboxBundle/Document/Areabrick/SlideColumns/SlideColumns.php @@ -2,41 +2,33 @@ namespace ToolboxBundle\Document\Areabrick\SlideColumns; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Checkbox; +use Pimcore\Model\Document\Editable\Area\Info; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; use ToolboxBundle\Registry\CalculatorRegistryInterface; class SlideColumns extends AbstractAreabrick { - /** - * @var CalculatorRegistryInterface - */ - private $calculatorRegistry; - - /** - * @param CalculatorRegistryInterface $calculatorRegistry - */ + private CalculatorRegistryInterface $calculatorRegistry; + public function __construct(CalculatorRegistryInterface $calculatorRegistry) { $this->calculatorRegistry = $calculatorRegistry; } - /** - * {@inheritdoc} - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); /** @var Checkbox $equalHeightElement */ - $equalHeightElement = $this->getDocumentTag($info->getDocument(), 'checkbox', 'equal_height'); - $equalHeight = $equalHeightElement->isChecked() && !$info->getView()->get('editmode'); + $equalHeightElement = $this->getDocumentEditable($info->getDocument(), 'checkbox', 'equal_height'); + $equalHeight = $equalHeightElement->isChecked() && !$info->getParam('editmode'); $id = sprintf('%s-%s', $info->getId(), $info->getIndex()); - $slidesPerView = (int) $this->getDocumentTag($info->getDocument(), 'select', 'slides_per_view')->getData(); - $slideElements = $this->getDocumentTag($info->getDocument(), 'block', 'slideCols', ['default' => $slidesPerView]); + $slidesPerView = (int) $this->getDocumentEditable($info->getDocument(), 'select', 'slides_per_view')->getData(); + $slideElements = $this->getDocumentEditable($info->getDocument(), 'block', 'slideCols', ['default' => $slidesPerView]); $theme = $this->configManager->getConfig('theme'); $calculator = $this->calculatorRegistry->getSlideColumnCalculator($theme['calculators']['slide_calculator']); @@ -45,54 +37,47 @@ public function action(Info $info) $slidesPerViewClass = $calculator->calculateSlideColumnClasses($slidesPerView, $slideColumnConfig); $breakpoints = $this->calculateSlideColumnBreakpoints($slidesPerView); - $info->getView()->getParameters()->add([ + $info->setParams(array_merge($info->getParams(), [ 'id' => $id, 'slideElements' => $slideElements, 'slidesPerView' => $slidesPerView, 'slidesPerViewClasses' => $slidesPerViewClass, 'breakpoints' => $breakpoints, 'equalHeight' => $equalHeight - ]); + ])); return null; } - /** - * @return string - */ - public function getName() + private function calculateSlideColumnBreakpoints(int $columnType): array { - return 'Slide Columns'; + $configInfo = $this->getConfigManager()->getAreaParameterConfig('slideColumns'); + + $breakpoints = []; + if (!empty($configInfo) && isset($configInfo['breakpoints'], $configInfo['breakpoints'][$columnType])) { + $breakpoints = $configInfo['breakpoints'][$columnType]; + } + + return $breakpoints; } - /** - * @return string - */ - public function getDescription() + public function getTemplateDirectoryName(): string { - return 'Toolbox Slide Columns'; + return 'slide-columns'; } - /** - * @param int $columnType - * - * @return array - * - * @throws \Exception - */ - private function calculateSlideColumnBreakpoints($columnType) + public function getTemplate(): string { - $columnType = (int) $columnType; - $configInfo = $this->getConfigManager()->getAreaParameterConfig('slideColumns'); - - $breakpoints = []; + return sprintf('@Toolbox/areas/%s/view.%s', $this->getTemplateDirectoryName(), $this->getTemplateSuffix()); + } - if (!empty($configInfo)) { - if (isset($configInfo['breakpoints']) && isset($configInfo['breakpoints'][$columnType])) { - $breakpoints = $configInfo['breakpoints'][$columnType]; - } - } + public function getName(): string + { + return 'Slide Columns'; + } - return $breakpoints; + public function getDescription(): string + { + return 'Toolbox Slide Columns'; } } diff --git a/src/ToolboxBundle/Document/Areabrick/Snippet/Snippet.php b/src/ToolboxBundle/Document/Areabrick/Snippet/Snippet.php index c3f7238b..84bd7f43 100644 --- a/src/ToolboxBundle/Document/Areabrick/Snippet/Snippet.php +++ b/src/ToolboxBundle/Document/Areabrick/Snippet/Snippet.php @@ -2,21 +2,15 @@ namespace ToolboxBundle\Document\Areabrick\Snippet; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Snippet extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { - parent::action($info); + return parent::action($info); } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/Spacer/Spacer.php b/src/ToolboxBundle/Document/Areabrick/Spacer/Spacer.php index ab7addd8..a0ef1b42 100644 --- a/src/ToolboxBundle/Document/Areabrick/Spacer/Spacer.php +++ b/src/ToolboxBundle/Document/Areabrick/Spacer/Spacer.php @@ -2,21 +2,15 @@ namespace ToolboxBundle\Document\Areabrick\Spacer; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Spacer extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { - parent::action($info); + return parent::action($info); } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/Teaser/Teaser.php b/src/ToolboxBundle/Document/Areabrick/Teaser/Teaser.php index caa56c79..e9a4df5e 100644 --- a/src/ToolboxBundle/Document/Areabrick/Teaser/Teaser.php +++ b/src/ToolboxBundle/Document/Areabrick/Teaser/Teaser.php @@ -2,26 +2,15 @@ namespace ToolboxBundle\Document\Areabrick\Teaser; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; class Teaser extends AbstractAreabrick { - /** - * @param Info $info - * - * @return null|\Symfony\Component\HttpFoundation\Response|void - * - * @throws \Exception - */ - public function action(Info $info) + public function action(Info $info): ?Response { - parent::action($info); - - $flags = $this->configManager->getConfig('flags'); - $useDynamicLinks = $flags['use_dynamic_links']; - - $info->getView()->getParameters()->add(['useDynamicLinks' => $useDynamicLinks]); + return parent::action($info); } public function getName() diff --git a/src/ToolboxBundle/Document/Areabrick/Video/Video.php b/src/ToolboxBundle/Document/Areabrick/Video/Video.php index 5437d49b..78feb0cf 100644 --- a/src/ToolboxBundle/Document/Areabrick/Video/Video.php +++ b/src/ToolboxBundle/Document/Areabrick/Video/Video.php @@ -2,49 +2,45 @@ namespace ToolboxBundle\Document\Areabrick\Video; +use Pimcore\Model\Document\Editable\Checkbox; +use Symfony\Component\HttpFoundation\Response; use ToolboxBundle\Document\Areabrick\AbstractAreabrick; -use Pimcore\Model\Document\Tag\Area\Info; +use Pimcore\Model\Document\Editable\Area\Info; use Pimcore\Model\Asset; +use ToolboxBundle\Model\Document\Editable\Vhs; class Video extends AbstractAreabrick { - /** - * {@inheritdoc} - */ - public function action(Info $info) + public function action(Info $info): ?Response { parent::action($info); - $view = $info->getView(); - - /** @var \ToolboxBundle\Model\Document\Tag\Vhs $videoTag */ - $videoTag = $this->getDocumentTag($info->getDocument(), 'vhs', 'video'); + /** @var Vhs $videoTag */ + $videoTag = $this->getDocumentEditable($info->getDocument(), 'vhs', 'video'); $videoParameter = $videoTag->getVideoParameter(); $playInLightBox = $videoTag->getShowAsLightBox() === true ? 'true' : 'false'; - /** @var \Pimcore\Model\Document\Tag\Checkbox $autoPlayElement */ - $autoPlayElement = $this->getDocumentTag($info->getDocument(), 'checkbox', 'autoplay'); - $autoPlay = $autoPlayElement->isChecked() === true && !$view->get('editmode'); + /** @var Checkbox $autoPlayElement */ + $autoPlayElement = $this->getDocumentEditable($info->getDocument(), 'checkbox', 'autoplay'); + $autoPlay = $autoPlayElement->isChecked() === true && !$info->getParam('editmode'); $videoType = $videoTag->getVideoType(); $posterPath = null; - $imageThumbnail = null; $poster = $videoTag->getPosterAsset(); - $videoId = $videoTag->id; if ($poster instanceof Asset\Image) { $imageThumbnail = $this->getConfigManager()->getImageThumbnailFromConfig('video_poster'); $posterPath = $poster->getThumbnail($imageThumbnail); } - $view->getParameters()->add([ + $info->setParams(array_merge($info->getParams(), [ 'autoPlay' => $autoPlay, 'posterPath' => $posterPath, 'videoType' => $videoType, 'playInLightbox' => $playInLightBox, 'videoParameter' => $videoParameter, - 'videoId' => $videoId - ]); + 'videoId' => $videoTag->getId() + ])); return null; } diff --git a/src/ToolboxBundle/Document/SimpleAreabrick/SimpleAreaBrick.php b/src/ToolboxBundle/Document/SimpleAreabrick/SimpleAreaBrick.php new file mode 100644 index 00000000..2ba97c31 --- /dev/null +++ b/src/ToolboxBundle/Document/SimpleAreabrick/SimpleAreaBrick.php @@ -0,0 +1,10 @@ +name = $name; + } + + public function getName(): string + { + return $this->name; + } + + public function setDescription(string $description): void + { + $this->description = $description; + } + + public function setTemplate(string $templatePath): void + { + $this->templatePath = $templatePath; + } + + public function getTemplate(): ?string + { + return $this->templatePath; + } + + public function setIcon(string $icon): void + { + $this->icon = $icon; + } + + public function getIcon(): ?string + { + return $this->icon; + } +} diff --git a/src/ToolboxBundle/EventListener/Frontend/FrontendJsListener.php b/src/ToolboxBundle/EventListener/Frontend/FrontendJsListener.php index 0d8ecd42..93c4d7dd 100644 --- a/src/ToolboxBundle/EventListener/Frontend/FrontendJsListener.php +++ b/src/ToolboxBundle/EventListener/Frontend/FrontendJsListener.php @@ -7,8 +7,7 @@ use Pimcore\Bundle\CoreBundle\EventListener\Traits\PimcoreContextAwareTrait; use Pimcore\Bundle\CoreBundle\EventListener\Traits\ResponseInjectionTrait; use Pimcore\Http\Request\Resolver\PimcoreContextResolver; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpKernel\Event\FilterResponseEvent; +use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\Templating\EngineInterface; class FrontendJsListener @@ -16,35 +15,14 @@ class FrontendJsListener use EnabledTrait; use ResponseInjectionTrait; use PimcoreContextAwareTrait; + private EngineInterface $templatingEngine; - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; - - /** - * @var EngineInterface - */ - private $templatingEngine; - - /** - * FrontendJsTranslationsListener constructor. - * - * @param EventDispatcherInterface $eventDispatcher - * @param EngineInterface $templatingEngine - */ - public function __construct( - EventDispatcherInterface $eventDispatcher, - EngineInterface $templatingEngine - ) { - $this->eventDispatcher = $eventDispatcher; + public function __construct(EngineInterface $templatingEngine) + { $this->templatingEngine = $templatingEngine; } - /** - * @param FilterResponseEvent $event - */ - public function onKernelResponse(FilterResponseEvent $event) + public function onKernelResponse(ResponseEvent $event): void { if (!$this->isEnabled()) { return; @@ -76,7 +54,7 @@ public function onKernelResponse(FilterResponseEvent $event) $optOutCookie = $request->cookies->get('tb-google-opt-out-link'); $codeHead = $this->renderTemplate( - '@Toolbox/Admin/Javascript/frontend.html.twig', + '@Toolbox/admin/javascript/frontend.html.twig', [ 'translations' => [ 'toolbox.goptout_already_opt_out', @@ -99,12 +77,6 @@ public function onKernelResponse(FilterResponseEvent $event) $response->setContent($content); } - /** - * @param string $template - * @param array $data - * - * @return string - */ private function renderTemplate(string $template, array $data): string { $code = $this->templatingEngine->render( diff --git a/src/ToolboxBundle/EventListener/PermissionListener.php b/src/ToolboxBundle/EventListener/PermissionListener.php new file mode 100644 index 00000000..4f511a03 --- /dev/null +++ b/src/ToolboxBundle/EventListener/PermissionListener.php @@ -0,0 +1,40 @@ +permissionManager = $permissionManager; + } + + public static function getSubscribedEvents(): array + { + return [ + ConsoleEvents::COMMAND => 'onConsoleCommand' + ]; + } + + public function onConsoleCommand(ConsoleCommandEvent $event): void + { + $command = $event->getCommand(); + + if ($command === null) { + return; + } + + if ($command->getName() !== 'cache:clear') { + return; + } + + $this->permissionManager->synchroniseEditablePermissions(); + } +} diff --git a/src/ToolboxBundle/Manager/AdaptiveConfigManager.php b/src/ToolboxBundle/Manager/AdaptiveConfigManager.php index 9fdc6ca4..13acec54 100644 --- a/src/ToolboxBundle/Manager/AdaptiveConfigManager.php +++ b/src/ToolboxBundle/Manager/AdaptiveConfigManager.php @@ -4,27 +4,14 @@ class AdaptiveConfigManager extends ConfigManager implements AdaptiveConfigManagerInterface { - /** - * @var null - */ - protected $adaptiveContextId = null; + protected ?string $adaptiveContextId; - /** - * {@inheritdoc} - */ - public function setContextNameSpace($id) + public function setContextNameSpace(?string $id = null): void { - if (empty($id)) { - $id = false; - } - $this->adaptiveContextId = $id; } - /** - * @return string|null - */ - public function getContextIdentifier() + public function getContextIdentifier(): ?string { return $this->adaptiveContextId; } diff --git a/src/ToolboxBundle/Manager/AdaptiveConfigManagerInterface.php b/src/ToolboxBundle/Manager/AdaptiveConfigManagerInterface.php index 0bfe2f2e..9be92d98 100644 --- a/src/ToolboxBundle/Manager/AdaptiveConfigManagerInterface.php +++ b/src/ToolboxBundle/Manager/AdaptiveConfigManagerInterface.php @@ -4,8 +4,5 @@ interface AdaptiveConfigManagerInterface extends ConfigManagerInterface { - /** - * @param string $id - */ - public function setContextNameSpace($id); + public function setContextNameSpace(?string $id = null): void; } diff --git a/src/ToolboxBundle/Manager/AreaManager.php b/src/ToolboxBundle/Manager/AreaManager.php index a8af82be..d0a8a512 100644 --- a/src/ToolboxBundle/Manager/AreaManager.php +++ b/src/ToolboxBundle/Manager/AreaManager.php @@ -2,36 +2,26 @@ namespace ToolboxBundle\Manager; +use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick; use Pimcore\Extension\Document\Areabrick\AreabrickManager; class AreaManager implements AreaManagerInterface { - /** - * @var ConfigManagerInterface - */ - public $configManager; - - /** - * @var AreabrickManager - */ - public $brickManager; - - /** - * @param ConfigManagerInterface $configManager - * @param AreabrickManager $brickManager - */ - public function __construct(ConfigManagerInterface $configManager, AreabrickManager $brickManager) - { + public ConfigManagerInterface $configManager; + public AreabrickManager $brickManager; + public PermissionManagerInterface $permissionManager; + + public function __construct( + ConfigManagerInterface $configManager, + AreabrickManager $brickManager, + PermissionManagerInterface $permissionManager + ) { $this->configManager = $configManager; $this->brickManager = $brickManager; + $this->permissionManager = $permissionManager; } - /** - * @param null $type - * - * @return string - */ - public function getAreaBlockName($type = null) + public function getAreaBlockName(?string $type = null): string { if ($type === 'parallaxContainerSection') { return 'Parallax Container Section'; @@ -40,15 +30,7 @@ public function getAreaBlockName($type = null) return $this->brickManager->getBrick($type)->getName(); } - /** - * @param null $type - * @param bool $fromSnippet - * - * @return array - * - * @throws \Exception - */ - public function getAreaBlockConfiguration($type = null, $fromSnippet = false) + public function getAreaBlockConfiguration(?string $type, bool $fromSnippet = false, bool $editMode = false): array { if ($fromSnippet === true) { $availableBricks = $this->getAvailableBricksForSnippets($type); @@ -85,7 +67,7 @@ public function getAreaBlockConfiguration($type = null, $fromSnippet = false) $cleanedGroup = []; foreach ($groupData['elements'] as $element) { - if (in_array($element, $availableBricks['allowed'])) { + if (in_array($element, $availableBricks['allowed'], true)) { $cleanedGroup[] = $element; } } @@ -104,28 +86,28 @@ public function getAreaBlockConfiguration($type = null, $fromSnippet = false) $configuration['group'] = $cleanedGroups; } - if (isset($areaBlockConfigurationArray['toolbar']) && is_array($areaBlockConfigurationArray['toolbar'])) { - $configuration['areablock_toolbar'] = $areaBlockConfigurationArray['toolbar']; - } + $configuration['controlsAlign'] = $areaBlockConfigurationArray['controlsAlign']; + $configuration['controlsTrigger'] = $areaBlockConfigurationArray['controlsTrigger']; + $configuration['areablock_toolbar'] = $areaBlockConfigurationArray['toolbar']; + + $configuration['toolbox_permissions'] = [ + 'disallowed' => $editMode ? $this->permissionManager->getDisallowedEditables($configuration['allowed']) : [] + ]; return $configuration; } /** - * @param bool $arrayKeys - * - * @return array - * * @throws \Exception */ - private function getActiveBricks($arrayKeys = true) + private function getActiveBricks(bool $arrayKeys = true): array { $areaElements = $this->brickManager->getBricks(); //sort area elements by key => area name ksort($areaElements); - /** @var \Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick $areaElementData */ + /** @var AbstractTemplateAreabrick $areaElementData */ foreach ($areaElements as $areaElementName => $areaElementData) { if (!$this->brickManager->isEnabled($areaElementName)) { unset($areaElements[$areaElementName]); @@ -139,13 +121,13 @@ private function getActiveBricks($arrayKeys = true) if ($contextConfiguration['merge_with_root'] === true) { if (!empty($contextConfiguration['enabled_areas'])) { foreach ($areaElements as $areaElementName => $areaElementData) { - if (!in_array($areaElementName, $contextConfiguration['enabled_areas'])) { + if (!in_array($areaElementName, $contextConfiguration['enabled_areas'], true)) { unset($areaElements[$areaElementName]); } } } elseif (!empty($contextConfiguration['disabled_areas'])) { foreach ($areaElements as $areaElementName => $areaElementData) { - if (in_array($areaElementName, $contextConfiguration['disabled_areas'])) { + if (in_array($areaElementName, $contextConfiguration['disabled_areas'], true)) { unset($areaElements[$areaElementName]); } } @@ -154,8 +136,8 @@ private function getActiveBricks($arrayKeys = true) foreach ($areaElements as $areaElementName => $areaElementData) { $coreAreas = $this->configManager->getConfig('areas'); $customAreas = $this->configManager->getConfig('custom_areas'); - if (!in_array($areaElementName, array_keys($coreAreas)) && - !in_array($areaElementName, array_keys($customAreas))) { + if (!array_key_exists($areaElementName, $coreAreas) && + !array_key_exists($areaElementName, $customAreas)) { unset($areaElements[$areaElementName]); } } @@ -170,26 +152,12 @@ private function getActiveBricks($arrayKeys = true) } /** - * @param string $type - * - * @return array - * * @throws \Exception */ - private function getAvailableBricks($type = null) + private function getAvailableBricks(string $type): array { $areaElements = $this->getActiveBricks(); - try { - // @deprecated: remove in 4.0 - $disallowedSubAreas = $this->configManager->getConfig('disallowed_subareas'); - } catch (\Exception $e) { - // skip notice exceptions: this node is allowed to be missed! - $disallowedSubAreas = []; - } - - $depElementDisallowed = isset($disallowedSubAreas[$type]) ? $disallowedSubAreas[$type]['disallowed'] : []; - $areaAppearance = $this->configManager->getConfig('areas_appearance'); $elementAllowed = isset($areaAppearance[$type]) ? $areaAppearance[$type]['allowed'] : []; $elementDisallowed = isset($areaAppearance[$type]) ? $areaAppearance[$type]['disallowed'] : []; @@ -197,96 +165,62 @@ private function getAvailableBricks($type = null) // strict fill means: only add defined elements. $strictFill = !empty($elementAllowed); - // merge disallowed with deprecated disallowed - $elementDisallowed = array_merge($elementDisallowed, $depElementDisallowed); - $bricks = []; foreach ($areaElements as $a) { // allowed rule comes first! if ($strictFill === true) { - if (in_array($a, $elementAllowed)) { + if (in_array($a, $elementAllowed, true)) { $bricks[] = $a; } } else { - if (!in_array($a, $elementDisallowed)) { + if (!in_array($a, $elementDisallowed, true)) { $bricks[] = $a; } } } - $params = []; - foreach ($bricks as $brick) { - $params[$brick] = [ - 'forceEditInView' => true - ]; - } - - return ['allowed' => $bricks, 'params' => $params]; + return ['allowed' => $bricks, 'params' => []]; } /** - * @param string $type - * - * @return array - * * @throws \Exception */ - private function getAvailableBricksForSnippets($type) + private function getAvailableBricksForSnippets(string $type): array { $areaElements = $this->getActiveBricks(); - try { - // @deprecated: remove in 4.0 - $disallowedSubAreas = $this->configManager->getConfig('disallowed_content_snippet_areas'); - } catch (\Exception $e) { - // skip notice exceptions: this node is allowed to be missed! - $disallowedSubAreas = []; - } - $areaAppearance = $this->configManager->getConfig('snippet_areas_appearance'); $elementAllowed = isset($areaAppearance[$type]) ? $areaAppearance[$type]['allowed'] : []; $elementDisallowed = isset($areaAppearance[$type]) ? $areaAppearance[$type]['disallowed'] : []; - // merge disallowed with deprecated disallowed - $elementDisallowed = array_merge($elementDisallowed, is_array($disallowedSubAreas) ? $disallowedSubAreas : []); - $bricks = []; foreach ($areaElements as $a) { // allowed rule comes first! if (!empty($elementAllowed)) { - if (in_array($a, $elementAllowed)) { + if (in_array($a, $elementAllowed, true)) { $bricks[] = $a; } } else { - if (!in_array($a, $elementDisallowed)) { + if (!in_array($a, $elementDisallowed, true)) { $bricks[] = $a; } } } - $params = []; - foreach ($bricks as $brick) { - $params[$brick] = [ - 'forceEditInView' => true - ]; - } - - return ['allowed' => $bricks, 'params' => $params]; + return ['allowed' => $bricks, 'params' => []]; } /** - * @return array - * * @throws \Exception */ - private function getToolboxBricks() + private function getToolboxBricks(): array { $areaElements = $this->getActiveBricks(false); $toolboxBricks = []; - /** @var \Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick $areaElementData */ + /** @var AbstractTemplateAreabrick $areaElementData */ foreach ($areaElements as $areaElementName => $areaElementData) { - if (substr($areaElementData->getDescription(), 0, 7) === 'Toolbox') { + if (str_starts_with($areaElementData->getDescription(), 'Toolbox')) { $toolboxBricks[$areaElementName] = $areaElementData; } } diff --git a/src/ToolboxBundle/Manager/AreaManagerInterface.php b/src/ToolboxBundle/Manager/AreaManagerInterface.php index a8899dd4..84a6a9cd 100644 --- a/src/ToolboxBundle/Manager/AreaManagerInterface.php +++ b/src/ToolboxBundle/Manager/AreaManagerInterface.php @@ -4,15 +4,10 @@ interface AreaManagerInterface { - public function getAreaBlockName($type = null); + public function getAreaBlockName(?string $type = null): string; /** - * @param null $type - * @param bool $fromSnippet - * - * @return array - * * @throws \Exception */ - public function getAreaBlockConfiguration($type = null, $fromSnippet = false); + public function getAreaBlockConfiguration(?string $type, bool $fromSnippet = false, bool $editMode = false): array; } diff --git a/src/ToolboxBundle/Manager/ConfigManager.php b/src/ToolboxBundle/Manager/ConfigManager.php index 85604ca7..ab9d4fa7 100644 --- a/src/ToolboxBundle/Manager/ConfigManager.php +++ b/src/ToolboxBundle/Manager/ConfigManager.php @@ -6,139 +6,65 @@ class ConfigManager implements ConfigManagerInterface { - /** - * @var ContextResolverInterface - */ - private $contextResolver; - - /** - * @var bool - */ - private $contextResolved = false; - - /** - * @var array - */ - protected $config; - - /** - * @var array - */ - protected $context = []; - - /** - * @var array - */ - protected $contextSettings = []; - - /** - * @var null|string - */ - protected $currentContextId = null; - - /** - * @var string - */ - private $areaNamespace = null; + private ContextResolverInterface $contextResolver; + private bool $contextResolved = false; + protected array $config; + protected array $context = []; + protected array $contextSettings = []; + protected ?string $currentContextId = null; + private ?string $areaNamespace = null; - /** - * ConfigManager constructor. - * - * @param ContextResolverInterface $contextResolver - */ public function __construct(ContextResolverInterface $contextResolver) { $this->contextResolver = $contextResolver; } - /** - * @param array $config - * - * @throws \Exception - */ - public function setConfig($config = []) + public function setConfig(array $config = []): void { $this->config = $config; } - /** - * @param string $namespace - * - * @return $this - */ - public function setAreaNameSpace($namespace = ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL) + public function setAreaNameSpace(string $namespace = ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL): self { $this->areaNamespace = $namespace; return $this; } - /** - * @param string $section - * - * @return mixed - * - * @throws \Exception - */ - public function getConfig($section) + public function getConfig(string $section): mixed { $this->ensureCoreConfig(); return $this->config[$section]; } - /** - * @throws \Exception - * - * @return bool - */ - public function isContextConfig() + public function isContextConfig(): bool { $this->ensureCoreConfig(); - return $this->currentContextId != null; + return $this->currentContextId !== null; } - /** - * @return false|array - * - * @throws \Exception - */ - public function getCurrentContextSettings() + public function getCurrentContextSettings(): array { $this->ensureCoreConfig(); if ($this->currentContextId === null) { - return false; + return []; } return $this->contextSettings[$this->currentContextId]; } - /** - * @param string $areaName - * - * @return mixed - * - * @throws \Exception - */ - public function getAreaConfig($areaName = '') + public function getAreaConfig(string $areaName): mixed { $this->ensureCoreConfig(); $this->ensureConfigNamespace(); - return $this->config[$this->areaNamespace][$areaName]; + return $this->config[$this->areaNamespace][$areaName] ?? []; } - /** - * @param string $areaName - * @param string $configElementName - * - * @return mixed - * - * @throws \Exception - */ - public function getAreaElementConfig($areaName = '', $configElementName = '') + public function getAreaElementConfig(string $areaName, string $configElementName): mixed { $this->ensureCoreConfig(); $this->ensureConfigNamespace(); @@ -146,14 +72,7 @@ public function getAreaElementConfig($areaName = '', $configElementName = '') return $this->config[$this->areaNamespace][$areaName]['config_elements'][$configElementName]; } - /** - * @param string $areaName - * - * @return mixed - * - * @throws \Exception - */ - public function getAreaParameterConfig($areaName = '') + public function getAreaParameterConfig(string $areaName): mixed { $this->ensureCoreConfig(); $this->ensureConfigNamespace(); @@ -161,24 +80,14 @@ public function getAreaParameterConfig($areaName = '') return $this->config[$this->areaNamespace][$areaName]['config_parameter']; } - /** - * @param string $thumbnailName - * - * @return mixed - * - * @throws \Exception - */ - public function getImageThumbnailFromConfig($thumbnailName = '') + public function getImageThumbnailFromConfig(string $thumbnailName = ''): ?string { $this->ensureCoreConfig(); - return $this->config['image_thumbnails'][$thumbnailName]; + return $this->config['image_thumbnails'][$thumbnailName] ?? null; } - /** - * @return string|null|false - */ - public function getContextIdentifier() + public function getContextIdentifier(): ?string { return $this->contextResolver->getCurrentContextIdentifier(); } @@ -186,11 +95,11 @@ public function getContextIdentifier() /** * @throws \Exception */ - private function ensureCoreConfig() + private function ensureCoreConfig(): void { $contextIdentifierId = $this->getContextIdentifier(); - if ($contextIdentifierId === false) { + if ($contextIdentifierId === null) { $this->contextResolved = true; return; @@ -200,12 +109,10 @@ private function ensureCoreConfig() return; } - if ($contextIdentifierId !== null) { - $contextData = $this->parseContextConfig($contextIdentifierId); - $this->config = $contextData['config']; - $this->contextSettings[$contextIdentifierId] = $contextData['settings']; - $this->currentContextId = $contextIdentifierId; - } + $contextData = $this->parseContextConfig($contextIdentifierId); + $this->config = $contextData['config']; + $this->contextSettings[$contextIdentifierId] = $contextData['settings']; + $this->currentContextId = $contextIdentifierId; $this->contextResolved = true; } @@ -213,7 +120,7 @@ private function ensureCoreConfig() /** * @throws \Exception */ - private function ensureConfigNamespace() + private function ensureConfigNamespace(): void { if (is_null($this->areaNamespace)) { throw new \Exception('ConfigManager has no defined namespace.'); @@ -221,19 +128,15 @@ private function ensureConfigNamespace() } /** - * @param string $currentContextId - * - * @return array - * * @throws \Exception */ - private function parseContextConfig($currentContextId) + private function parseContextConfig(string $currentContextId): array { - if (!is_string($currentContextId) || !isset($this->config['context'][$currentContextId])) { - @trigger_error(sprintf( + if (!isset($this->config['context'][$currentContextId])) { + throw new \Exception(sprintf( 'toolbox context conflict: context with identifier "%s" is not configured.', $currentContextId - ), E_USER_ERROR); + )); } $contextData = $this->config['context'][$currentContextId]; diff --git a/src/ToolboxBundle/Manager/ConfigManagerInterface.php b/src/ToolboxBundle/Manager/ConfigManagerInterface.php index f9b3d058..43398cf8 100644 --- a/src/ToolboxBundle/Manager/ConfigManagerInterface.php +++ b/src/ToolboxBundle/Manager/ConfigManagerInterface.php @@ -4,86 +4,47 @@ interface ConfigManagerInterface { - const AREABRICK_NAMESPACE_INTERNAL = 'areas'; + public const AREABRICK_NAMESPACE_INTERNAL = 'areas'; + public const AREABRICK_NAMESPACE_EXTERNAL = 'custom_areas'; - const AREABRICK_NAMESPACE_EXTERNAL = 'custom_areas'; + public function setConfig(array $config = []): void; - /** - * @param array $config - * - * @throws \Exception - */ - public function setConfig($config = []); - - /** - * @param string $namespace - * - * @return $this - */ - public function setAreaNameSpace($namespace = self::AREABRICK_NAMESPACE_INTERNAL); + public function setAreaNameSpace(string $namespace = self::AREABRICK_NAMESPACE_INTERNAL): self; /** - * @param string $section - * - * @return mixed - * * @throws \Exception */ - public function getConfig($section); + public function getConfig(string $section): mixed; /** * @throws \Exception - * - * @return bool */ - public function isContextConfig(); + public function isContextConfig(): bool; /** - * @return false|array - * * @throws \Exception */ - public function getCurrentContextSettings(); + public function getCurrentContextSettings(): array; /** - * @param string $areaName - * - * @return mixed - * * @throws \Exception */ - public function getAreaConfig($areaName = ''); + public function getAreaConfig(string $areaName): mixed; /** - * @param string $areaName - * @param string $configElementName - * - * @return mixed - * * @throws \Exception */ - public function getAreaElementConfig($areaName = '', $configElementName = ''); + public function getAreaElementConfig(string $areaName, string $configElementName): mixed; /** - * @param string $areaName - * - * @return mixed - * * @throws \Exception */ - public function getAreaParameterConfig($areaName = ''); + public function getAreaParameterConfig(string $areaName): mixed; /** - * @param string $thumbnailName - * - * @return mixed - * * @throws \Exception */ - public function getImageThumbnailFromConfig($thumbnailName = ''); + public function getImageThumbnailFromConfig(string $thumbnailName): ?string; - /** - * @return string|null|false - */ - public function getContextIdentifier(); + public function getContextIdentifier(): ?string; } diff --git a/src/ToolboxBundle/Manager/LayoutManager.php b/src/ToolboxBundle/Manager/LayoutManager.php index bd9c2566..adf123fa 100644 --- a/src/ToolboxBundle/Manager/LayoutManager.php +++ b/src/ToolboxBundle/Manager/LayoutManager.php @@ -6,55 +6,29 @@ class LayoutManager implements LayoutManagerInterface { - /** - * @var ConfigManager - */ - protected $configManager; - - /** - * @var EngineInterface - */ - protected $templating; - - /** - * @param ConfigManager $configManager - */ + protected ConfigManager $configManager; + protected EngineInterface $templating; + public function __construct(ConfigManager $configManager) { $this->configManager = $configManager; } - /** - * @param EngineInterface $templating - * - * @return $this - */ - public function setTemplating(EngineInterface $templating) + public function setTemplating(EngineInterface $templating): void { $this->templating = $templating; - - return $this; } - /** - * @param null $areaId - * @param string $viewName - * @param string $extension - * - * @return string - * - * @throws \Exception - */ - public function getAreaTemplateDir($areaId = null, $viewName = 'view', $extension = 'html.twig') + public function getAreaTemplateDir(string $areaId, string $areaTemplateDir, string $viewName = 'view', string $extension = 'html.twig'): string { $elementThemeConfig = $this->getAreaThemeConfig($areaId); - $pathStructure = '@Toolbox/Toolbox/%s/%s'; + $pathStructure = '@Toolbox/toolbox/%s/%s'; $defaultDir = sprintf( $pathStructure, - $elementThemeConfig['layout'], - ucfirst($areaId) + strtolower($elementThemeConfig['layout']), + $areaTemplateDir ); //no fallback layout defined. return default. @@ -70,32 +44,16 @@ public function getAreaTemplateDir($areaId = null, $viewName = 'view', $extensio return sprintf( $pathStructure, $elementThemeConfig['default_layout'], - ucfirst($areaId) + $areaTemplateDir ); } - /** - * @param null $areaId - * @param string $viewName - * @param string $extension - * - * @return string - * - * @throws \Exception - */ - public function getAreaTemplatePath($areaId = null, $viewName = 'view', $extension = 'html.twig') + public function getAreaTemplatePath($areaId, string $areaTemplateDir, string $viewName = 'view', string $extension = 'html.twig'): string { - return $this->getAreaTemplateDir($areaId, $viewName) . DIRECTORY_SEPARATOR . $viewName . '.' . $extension; + return $this->getAreaTemplateDir($areaId, $areaTemplateDir, $viewName) . DIRECTORY_SEPARATOR . $viewName . '.' . $extension; } - /** - * @param string $areaName - * - * @return array - * - * @throws \Exception - */ - public function getAreaThemeConfig($areaName = '') + public function getAreaThemeConfig(string $areaName): array { $layoutConfiguration = $this->configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getConfig('theme'); diff --git a/src/ToolboxBundle/Manager/LayoutManagerInterface.php b/src/ToolboxBundle/Manager/LayoutManagerInterface.php index 226ee449..edbc48aa 100644 --- a/src/ToolboxBundle/Manager/LayoutManagerInterface.php +++ b/src/ToolboxBundle/Manager/LayoutManagerInterface.php @@ -6,32 +6,20 @@ interface LayoutManagerInterface { - public function setTemplating(EngineInterface $templating); + public function setTemplating(EngineInterface $templating): void; /** - * @param null $areaId - * @param string $viewName - * @param string $extension - * - * @return string + * @throws \Exception */ - public function getAreaTemplateDir($areaId = null, $viewName = 'view', $extension = 'html.twig'); + public function getAreaTemplateDir(string $areaId, string $areaTemplateDir, string $viewName = 'view', string $extension = 'html.twig'): string; /** - * @param null $areaId - * @param string $viewName - * @param string $extension - * - * @return string + * @throws \Exception */ - public function getAreaTemplatePath($areaId = null, $viewName = 'view', $extension = 'html.twig'); + public function getAreaTemplatePath(string $areaId, string $areaTemplateDir, string $viewName = 'view', string $extension = 'html.twig'): string; /** - * @param string $areaName - * - * @return array - * * @throws \Exception */ - public function getAreaThemeConfig($areaName = ''); + public function getAreaThemeConfig(string $areaName): array; } diff --git a/src/ToolboxBundle/Manager/PermissionManager.php b/src/ToolboxBundle/Manager/PermissionManager.php new file mode 100644 index 00000000..667ae654 --- /dev/null +++ b/src/ToolboxBundle/Manager/PermissionManager.php @@ -0,0 +1,108 @@ +brickManager = $brickManager; + $this->userLoader = $userLoader; + } + + public function synchroniseEditablePermissions(): void + { + $category = [ + 'key' => 'toolbox.permission.editable.category_name', + 'translations' => [ + 'de' => 'Toolbox Editables', + 'en' => 'Toolbox Editables' + ] + ]; + + if (Translation::getByKey('toolbox.permission.editable.category_name', Translation::DOMAIN_ADMIN) === null) { + $t = new Translation(); + $t->setDomain(Translation::DOMAIN_ADMIN); + $t->setKey($category['key']); + $t->setCreationDate(time()); + $t->setModificationDate(time()); + foreach ($category['translations'] as $locale => $translation) { + $t->addTranslation($locale, $translation); + } + $t->save(); + } + + /** + * @var string $editableId + * @var AreabrickInterface $areaBrick + */ + foreach ($this->brickManager->getBricks() as $editableId => $areaBrick) { + $permission = $this->generatePermissionName($editableId); + $definition = User\Permission\Definition::getByKey($permission); + + if ($definition) { + continue; + } + + $permissionDefinition = new User\Permission\Definition(); + $permissionDefinition->setKey($permission); + $permissionDefinition->setCategory($category['key']); + $permissionDefinition->save(); + } + } + + public function getDisallowedEditables(array $editables): array + { + $allowedElements = []; + + foreach ($editables as $editableId) { + if ($this->isAllowedEditable($editableId)) { + continue; + } + + $allowedElements[] = $editableId; + } + + return $allowedElements; + } + + protected function isAllowedEditable(string $editableId): bool + { + $user = $this->getUser(); + + if ($user === null) { + return false; + } + + $permission = $this->generatePermissionName($editableId); + + return $user->isAllowed($permission); + } + + protected function getUser(): ?User + { + $user = $this->userLoader->getUser(); + + if (!$user instanceof User) { + return null; + } + + return $user; + } + + protected function generatePermissionName(string $editableId): string + { + return sprintf('toolbox_editable_%s', strtolower(str_replace(['-'], ['_'], $editableId))); + } +} diff --git a/src/ToolboxBundle/Manager/PermissionManagerInterface.php b/src/ToolboxBundle/Manager/PermissionManagerInterface.php new file mode 100644 index 00000000..99ec05a8 --- /dev/null +++ b/src/ToolboxBundle/Manager/PermissionManagerInterface.php @@ -0,0 +1,10 @@ +exists(Install::SYSTEM_CONFIG_DIR_PATH . '/config.yml')) { - $fileSystem->remove(Install::SYSTEM_CONFIG_DIR_PATH . '/config.yml'); - } - } - - /** - * @param Schema $schema - */ - public function down(Schema $schema) - { - // nothing to do. - } -} diff --git a/src/ToolboxBundle/Model/Document/Editable/ColumnAdjuster.php b/src/ToolboxBundle/Model/Document/Editable/ColumnAdjuster.php new file mode 100644 index 00000000..3dada4a1 --- /dev/null +++ b/src/ToolboxBundle/Model/Document/Editable/ColumnAdjuster.php @@ -0,0 +1,55 @@ +data; + } + + public function frontend(): void + { + // nothing to do. + } + + public function isEmpty(): bool + { + return empty($this->data); + } + + public function setDataFromResource($data): self + { + $data = Serialize::unserialize($data); + + if (!is_array($data)) { + $data = []; + } + + $this->data = $data; + + return $this; + } + + public function setDataFromEditmode(mixed $data): self + { + if (!is_array($data)) { + $data = []; + } + + $this->data = $data; + + return $this; + } +} diff --git a/src/ToolboxBundle/Model/Document/Editable/GoogleMap.php b/src/ToolboxBundle/Model/Document/Editable/GoogleMap.php new file mode 100644 index 00000000..78780bc2 --- /dev/null +++ b/src/ToolboxBundle/Model/Document/Editable/GoogleMap.php @@ -0,0 +1,293 @@ +detectKey(); + + return [ + 'locations' => $this->getData(), + 'hasValidKey' => $key !== null, + 'id' => $this->getId(), + 'attributes' => $this->buildMapAttributes() + ]; + } + + public function getData(): ?array + { + return $this->data; + } + + public function frontend(): string + { + $attributes = $this->buildMapAttributes(); + + $dataAttrString = implode(' ', array_map( + static function ($v, $k) { + return sprintf('%s="%s"', $k, $v); + }, + $attributes, + array_keys($attributes) + )); + + return '
'; + } + + public function isEmpty(): bool + { + return empty($this->data); + } + + /** + * {@inheritdoc} + */ + public function admin() + { + $html = parent::admin(); + + // get frontend code for preview + // put the video code inside the generic code + return str_replace('', $this->frontend() . '', $html); + } + + public function setDataFromResource(mixed $data): self + { + $this->setId(uniqid('map-', true)); + + $parsedLocations = Serialize::unserialize($data); + + if (!is_array($parsedLocations)) { + $parsedLocations = []; + } + + $this->data = $parsedLocations; + + return $this; + } + + /** + * @throws \Exception + */ + public function setDataFromEditmode(mixed $data): self + { + $this->setId(uniqid('map-', true)); + + if (!is_array($data)) { + $data = []; + } + + $parsedLocations = []; + $key = $this->detectKey(); + + if (count($data) > 0) { + foreach ($data as $i => $location) { + $parsedLocations[$i] = $this->geocodeLocation($location, $key); + } + } + + $this->data = $parsedLocations; + + return $this; + } + + public function googleLookUpIsDisabled(): bool + { + return $this->disableGoogleLookUp; + } + + public function disableGoogleLookup(): void + { + $this->disableGoogleLookUp = true; + } + + public function enableGoogleLookup(): void + { + $this->disableGoogleLookUp = false; + } + + public function setId(string $mapId): void + { + if ($this->mapId !== null) { + return; + } + + $this->mapId = $mapId; + } + + public function getId(): ?string + { + return $this->mapId; + } + + protected function buildMapAttributes(): array + { + if (!is_array($this->config)) { + $this->config = []; + } + + $dataAttr = []; + $dataAttr['data-locations'] = htmlspecialchars(json_encode($this->validateLocationValues($this->data)), ENT_QUOTES, 'UTF-8'); + $dataAttr['data-show-info-window-on-load'] = $this->config['iwOnInit'] ?? true; + + $dataAttr['data-mapoption-zoom'] = $this->config['mapZoom'] ?? 5; + $dataAttr['data-mapoption-map-type-id'] = $this->config['mapType'] ?? 'roadmap'; + + /** @var ConfigManager $configManager */ + $configManager = \Pimcore::getContainer()->get(ConfigManager::class); + $configNode = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaParameterConfig('googleMap'); + + if (!empty($configNode)) { + $mapOptions = $configNode['map_options']; + $mapStyleUrl = $configNode['map_style_url']; + $markerIcon = $configNode['marker_icon']; + + if (is_array($mapOptions) && count($mapOptions) > 0) { + foreach ($mapOptions as $name => $value) { + $value = is_bool($value) ? ($value === true ? 'true' : 'false') : (string) $value; + // convert camelCase to camel-case, because we will read these property with $el.data(), which converts them back to camelCase + $name = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '-\\1', $name)); + $dataAttr['data-mapoption-' . $name] = $value; + } + } + + if (!empty($mapStyleUrl)) { + $dataAttr['data-mapstyleurl'] = $mapStyleUrl; + } + + if (!empty($markerIcon)) { + $dataAttr['data-markericon'] = $markerIcon; + } + } + + return $dataAttr; + } + + protected function geocodeLocation(array $location, ?string $key): array + { + if ($key === null || $this->googleLookUpIsDisabled()) { + return array_merge($location, ['lat' => null, 'lng' => null, 'status' => 'Look-Up has been disabled or Google API Key is empty.']); + } + + $address = $location['street'] . '+' . $location['zip'] . '+' . $location['city'] . '+' . $location['country']; + $address = urlencode($address); + + $checksum = $location['checksum'] ?? null; + $newChecksum = md5($address); + + // we don't need to call api again, nothing have been changed + if ($checksum === $newChecksum) { + return $location; + } + + $keyParam = sprintf('&key=%s', $key); + $url = sprintf('https://maps.google.com/maps/api/geocode/json?address=%s%s', $address, $keyParam); + + $c = curl_init(); + curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($c, CURLOPT_URL, $url); + $response = curl_exec($c); + curl_close($c); + + try { + $result = json_decode($response, true, 512, JSON_THROW_ON_ERROR); + } catch (\Throwable $e) { + return array_merge($location, ['lat' => null, 'lng' => null, 'status' => $e->getMessage()]); + } + + $location['status'] = null; + + if ($result['status'] === 'OK') { + $responseLocation = $result['results'][0]['geometry']['location']; + $location['lat'] = $responseLocation['lat']; + $location['lng'] = $responseLocation['lng']; + $location['checksum'] = md5($address); + } else { + $location['status'] = $result['error_message'] ?? $result['status']; + } + + return $location; + } + + protected function detectKey(): ?string + { + /** @var ConfigManager $configManager */ + $configManager = \Pimcore::getContainer()->get(ConfigManager::class); + $configNode = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaParameterConfig('googleMap'); + + $fallbackSimpleKey = \Pimcore::getContainer()->getParameter('toolbox.google_maps.simple_api_key'); + $fallbackBrowserKey = \Pimcore::getContainer()->getParameter('toolbox.google_maps.browser_api_key'); + + // first try to get server-api-key + if (!empty($configNode) && isset($configNode['simple_api_key']) && !empty($configNode['simple_api_key'])) { + return $configNode['simple_api_key']; + } + + if (!empty($fallbackSimpleKey)) { + return $fallbackSimpleKey; + } + + if (!empty($configNode) && isset($configNode['map_api_key']) && !empty($configNode['map_api_key'])) { + return $configNode['map_api_key']; + } + + if (!empty($fallbackBrowserKey)) { + return $fallbackBrowserKey; + } + + return null; + } + + protected function validateLocationValues(array $locations): array + { + $forbiddenFields = [ + 'status', + 'checksum' + ]; + + $filteredLocations = []; + foreach ($locations as $location) { + $newLocation = array_filter($location, static function ($data) use ($forbiddenFields) { + return !in_array($data, $forbiddenFields, true); + }, ARRAY_FILTER_USE_KEY); + + if (isset($newLocation['lat']) && is_numeric($newLocation['lat'])) { + $newLocation['lat'] = (float) $newLocation['lat']; + } + if (isset($newLocation['lng']) && is_numeric($newLocation['lng'])) { + $newLocation['lng'] = (float) $newLocation['lng']; + } + + $filteredLocations[] = $newLocation; + } + + return $filteredLocations; + } + + public function __sleep() + { + $parentVars = parent::__sleep(); + + if (!in_array('data', $parentVars, true)) { + $parentVars[] = 'data'; + } + + return $parentVars; + } +} diff --git a/src/ToolboxBundle/Model/Document/Tag/ParallaxImage.php b/src/ToolboxBundle/Model/Document/Editable/ParallaxImage.php similarity index 85% rename from src/ToolboxBundle/Model/Document/Tag/ParallaxImage.php rename to src/ToolboxBundle/Model/Document/Editable/ParallaxImage.php index 03fef1da..fa6fa9e9 100644 --- a/src/ToolboxBundle/Model/Document/Tag/ParallaxImage.php +++ b/src/ToolboxBundle/Model/Document/Editable/ParallaxImage.php @@ -1,6 +1,6 @@ elements)) { $this->elements = []; @@ -42,12 +34,7 @@ public function setElements() return $this; } - /** - * Converts the data so it's suitable for the editmode. - * - * @return mixed - */ - public function getDataEditmode() + public function getDataEditmode(): array { $this->setElements(); $return = []; @@ -98,12 +85,7 @@ public function getDataEditmode() return $return; } - /** - * @see Document\Tag\TagInterface::frontend - * - * @return string - */ - public function frontend() + public function frontend(): string { $this->setElements(); $return = ''; @@ -117,10 +99,7 @@ public function frontend() return $return; } - /** - * @return array - */ - public function resolveDependencies() + public function resolveDependencies(): array { $this->setElements(); $dependencies = []; diff --git a/src/ToolboxBundle/Model/Document/Editable/Vhs.php b/src/ToolboxBundle/Model/Document/Editable/Vhs.php new file mode 100644 index 00000000..ceac0118 --- /dev/null +++ b/src/ToolboxBundle/Model/Document/Editable/Vhs.php @@ -0,0 +1,85 @@ +showAsLightBox; + } + + public function getVideoParameter(): array + { + if (!is_array($this->videoParameter)) { + return []; + } + + $parsedParameter = []; + foreach ($this->videoParameter as $parameter) { + $parsedParameter[$parameter['key']] = $parameter['value']; + } + + return $parsedParameter; + } + + public function getData(): array + { + $data = parent::getData(); + + $data['showAsLightbox'] = $this->showAsLightBox; + $data['videoParameter'] = $this->videoParameter; + + return $data; + } + + public function getDataForResource(): array + { + $data = parent::getDataForResource(); + + $data['showAsLightbox'] = $this->showAsLightBox; + $data['videoParameter'] = $this->videoParameter; + + return $data; + } + + public function setDataFromResource(mixed $data): self + { + parent::setDataFromResource($data); + + if (!empty($data)) { + $data = Serialize::unserialize($data); + } + + $this->showAsLightBox = $data['showAsLightbox'] ?? false; + $this->videoParameter = $data['videoParameter'] ?? null; + + return $this; + } + + public function setDataFromEditmode($data): self + { + parent::setDataFromEditmode($data); + + if (isset($data['showAsLightbox'])) { + $this->showAsLightBox = $data['showAsLightbox']; + } + + if (isset($data['videoParameter'])) { + $this->videoParameter = $data['videoParameter']; + } + + return $this; + } +} diff --git a/src/ToolboxBundle/Model/Document/Tag/ColumnAdjuster.php b/src/ToolboxBundle/Model/Document/Tag/ColumnAdjuster.php deleted file mode 100644 index d9efbd72..00000000 --- a/src/ToolboxBundle/Model/Document/Tag/ColumnAdjuster.php +++ /dev/null @@ -1,97 +0,0 @@ -data; - } - - /** - * No frontend available. - */ - public function frontend() - { - return null; - } - - /** - * @return string - * - * @see Document\Tag\TagInterface::admin - */ - public function admin() - { - $html = parent::admin(); - - return $html; - } - - /** - * @return bool - */ - public function isEmpty() - { - return $this->data === false || empty($this->data); - } - - /** - * @param mixed $data - * - * @return string - */ - public function setDataFromResource($data) - { - $this->data = \Pimcore\Tool\Serialize::unserialize($data); - - if (!is_array($this->data)) { - $this->data = false; - } - - return $this; - } - - /** - * @param mixed $data - * - * @return $this - * - * @see Document\Tag\TagInterface::setDataFromEditmode - */ - public function setDataFromEditmode($data) - { - if (!is_array($data)) { - $data = false; - } - - $this->data = $data; - - return $this; - } -} diff --git a/src/ToolboxBundle/Model/Document/Tag/DynamicLink.php b/src/ToolboxBundle/Model/Document/Tag/DynamicLink.php deleted file mode 100644 index e38862f3..00000000 --- a/src/ToolboxBundle/Model/Document/Tag/DynamicLink.php +++ /dev/null @@ -1,99 +0,0 @@ -data['path']; - - if (strpos($url, '::') === false) { - return parent::getHref(); - } - - $objectInfo = explode('::', $url); - if (count($objectInfo) !== 2) { - return parent::getHref(); - } - - if (!\Pimcore\Tool::isFrontend()) { - return parent::getHref(); - } - - $event = new GenericEvent($this, [ - 'className' => $objectInfo[0], - 'path' => $objectInfo[1], - 'objectFrontendUrl' => $url - ]); - - \Pimcore::getEventDispatcher()->dispatch( - 'toolbox.dynamiclink.object.url', - $event - ); - - return $event->getArgument('objectFrontendUrl'); - } - - /** - * @return bool - */ - public function checkValidity() - { - if (strpos($this->data['path'], '::') === false) { - return parent::checkValidity(); - } - - return true; - } - - /** - * @param bool $realPath - * @param bool $editmode - */ - protected function updatePathFromInternal($realPath = false, $editmode = false) - { - if (is_null($this->data['internalId']) && strpos($this->data['path'], '::') !== false) { - return; - } - - parent::updatePathFromInternal($realPath, $editmode); - } - - /** - * @param mixed $data - * - * @return $this - */ - public function setDataFromEditmode($data) - { - if (strpos($data['path'], '::') === false) { - parent::setDataFromEditmode($data); - - return $this; - } - - $data['internal'] = true; - $data['internalType'] = 'object'; - - $this->data = $data; - - return $this; - } -} diff --git a/src/ToolboxBundle/Model/Document/Tag/GoogleMap.php b/src/ToolboxBundle/Model/Document/Tag/GoogleMap.php deleted file mode 100644 index a8a64c40..00000000 --- a/src/ToolboxBundle/Model/Document/Tag/GoogleMap.php +++ /dev/null @@ -1,272 +0,0 @@ -data; - } - - /** - * Return the data for direct output to the frontend, can also contain HTML code! - * - * @return string - * - * @throws \Exception - */ - public function frontend() - { - // @todo: remove with toolbox 4.0 - $configData = property_exists($this, 'config') ? $this->config : $this->options; - - $dataAttr = []; - $dataAttr['data-locations'] = json_encode($this->data, JSON_HEX_QUOT | JSON_HEX_APOS); - $dataAttr['data-show-info-window-on-load'] = $configData['iwOnInit']; - - $dataAttr['data-mapoption-zoom'] = $configData['mapZoom']; - $dataAttr['data-mapoption-map-type-id'] = $configData['mapType']; - - /** @var ConfigManager $configManager */ - $configManager = \Pimcore::getContainer()->get(ConfigManager::class); - $configNode = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaParameterConfig('googleMap'); - - if (!empty($configNode)) { - $mapOptions = $configNode['map_options']; - $mapStyleUrl = $configNode['map_style_url']; - $markerIcon = $configNode['marker_icon']; - - if (is_array($mapOptions) && count($mapOptions) > 0) { - foreach ($mapOptions as $name => $value) { - $value = is_bool($value) ? ($value === true ? 'true' : 'false') : (string) $value; - // convert camelCase to camel-case, because we will read these property with $el.data(), which converts them back to camelCase - $name = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '-\\1', $name)); - $dataAttr['data-mapoption-' . $name] = $value; - } - } - - if (!empty($mapStyleUrl)) { - $dataAttr['data-mapstyleurl'] = $mapStyleUrl; - } - - if (!empty($markerIcon)) { - $dataAttr['data-markericon'] = $markerIcon; - } - } - - $dataAttrString = implode(' ', array_map( - function ($v, $k) { - return $k . "='" . $v . "'"; - }, - $dataAttr, - array_keys($dataAttr) - )); - - if (empty($this->getId())) { - $this->mapId = uniqid('map-'); - } - - $html = '
'; - - return $html; - } - - /** - * @see Document\Tag\TagInterface::admin - * - * @return mixed|string - * - * @throws \Exception - */ - public function admin() - { - $html = parent::admin(); - - // get frontendcode for preview - // put the video code inside the generic code - $html = str_replace('', $this->frontend() . '', $html); - - return $html; - } - - /** - * @return bool - */ - public function isEmpty() - { - return $this->data === false || empty($this->data); - } - - /** - * Receives the data from the resource, an convert to the internal data in the object eg. image-id to Asset\Image. - * - * @param mixed $data - * - * @return string - */ - public function setDataFromResource($data) - { - $this->data = \Pimcore\Tool\Serialize::unserialize($data); - if (!is_array($this->data)) { - $this->data = []; - } - - return $this; - } - - /** - * @see Document\Tag\TagInterface::setDataFromEditmode - * - * @param mixed $data - * - * @return $this - * - * @throws \Exception - */ - public function setDataFromEditmode($data) - { - if (!is_array($data)) { - $data = []; - } - - if (count($data) > 0) { - foreach ($data as $i => $location) { - $data[$i] = $this->geocodeLocation($location); - } - } - - $this->data = $data; - - return $this; - } - - /** - * @return bool - */ - public function googleLookUpIsDisabled() - { - return $this->disableGoogleLookUp; - } - - public function disableGoogleLookup() - { - $this->disableGoogleLookUp = true; - } - - public function enableGoogleLookup() - { - $this->disableGoogleLookUp = false; - } - - /** - * @param string $mapId - */ - public function setId($mapId) - { - $this->mapId = $mapId; - } - - /** - * @return null|string - */ - public function getId() - { - return $this->mapId; - } - - /** - * @param array $location - * - * @return mixed - * - * @throws \Exception - */ - protected function geocodeLocation($location) - { - if ($this->googleLookUpIsDisabled()) { - return $location; - } - - /** @var ConfigManager $configManager */ - $configManager = \Pimcore::getContainer()->get(ConfigManager::class); - $configNode = $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL)->getAreaParameterConfig('googleMap'); - - $address = $location['street'] . '+' . $location['zip'] . '+' . $location['city'] . '+' . $location['country']; - $address = urlencode($address); - - $key = null; - $keyParam = ''; - - $fallbackSimpleKey = \Pimcore::getContainer()->getParameter('toolbox.google_maps.simple_api_key'); - $fallbackBrowserKey = \Pimcore::getContainer()->getParameter('toolbox.google_maps.browser_api_key'); - - // first try to get server-api-key - if (!empty($configNode) && isset($configNode['simple_api_key']) && !empty($configNode['simple_api_key'])) { - $key = $configNode['simple_api_key']; - } elseif (!empty($fallbackSimpleKey)) { - $key = $fallbackSimpleKey; - } elseif (!empty($configNode) && isset($configNode['map_api_key']) && !empty($configNode['map_api_key'])) { - $key = $configNode['map_api_key']; - } elseif (!empty($fallbackBrowserKey)) { - $key = $fallbackBrowserKey; - } - - if ($key !== null) { - $keyParam = sprintf('&key=%s', $key); - } - - $url = sprintf('https://maps.google.com/maps/api/geocode/json?address=%s%s', $address, $keyParam); - - $c = curl_init(); - curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($c, CURLOPT_URL, $url); - $response = curl_exec($c); - curl_close($c); - - $result = json_decode($response, false); - - if ($result->status === 'OK') { - $location['lat'] = $result->results[0]->geometry->location->lat; - $location['lng'] = $result->results[0]->geometry->location->lng; - } - - return $location; - } -} diff --git a/src/ToolboxBundle/Model/Document/Tag/Vhs.php b/src/ToolboxBundle/Model/Document/Tag/Vhs.php deleted file mode 100644 index e16e6d75..00000000 --- a/src/ToolboxBundle/Model/Document/Tag/Vhs.php +++ /dev/null @@ -1,130 +0,0 @@ -showAsLightBox; - } - - /** - * @return array - */ - public function getVideoParameter() - { - if (!is_array($this->videoParameter)) { - return []; - } - - $parsedParameter = []; - foreach ($this->videoParameter as $parameter) { - $parsedParameter[$parameter['key']] = $parameter['value']; - } - - return $parsedParameter; - } - - /** - * @see Document\Tag\TagInterface::getData - * - * @return array - */ - public function getData() - { - $data = parent::getData(); - $data['showAsLightbox'] = $this->showAsLightBox; - $data['videoParameter'] = $this->videoParameter; - - return $data; - } - - /** - * @return array - */ - public function getDataForResource() - { - $data = parent::getDataForResource(); - $data['showAsLightbox'] = $this->showAsLightBox; - $data['videoParameter'] = $this->videoParameter; - - return $data; - } - - /** - * @see Document\Tag\TagInterface::setDataFromResource - * - * @param mixed $data - * - * @return $this - */ - public function setDataFromResource($data) - { - parent::setDataFromResource($data); - - if (!empty($data)) { - $data = \Pimcore\Tool\Serialize::unserialize($data); - } - - $this->showAsLightBox = $data['showAsLightbox']; - $this->videoParameter = $data['videoParameter']; - - return $this; - } - - /** - * @see Document\Tag\TagInterface::setDataFromEditmode - * - * @param mixed $data - * - * @return $this - */ - public function setDataFromEditmode($data) - { - parent::setDataFromEditmode($data); - - if ($data['showAsLightbox']) { - $this->showAsLightBox = $data['showAsLightbox']; - } - - if ($data['videoParameter']) { - $this->videoParameter = $data['videoParameter']; - } - - return $this; - } -} diff --git a/src/ToolboxBundle/Provider/StoreProviderInterface.php b/src/ToolboxBundle/Provider/StoreProviderInterface.php index 0667ab6d..8a1e9ffb 100644 --- a/src/ToolboxBundle/Provider/StoreProviderInterface.php +++ b/src/ToolboxBundle/Provider/StoreProviderInterface.php @@ -4,8 +4,5 @@ interface StoreProviderInterface { - /** - * @return mixed - */ - public function getValues(); + public function getValues(): array; } diff --git a/src/ToolboxBundle/Registry/CalculatorRegistry.php b/src/ToolboxBundle/Registry/CalculatorRegistry.php index f506d8a5..e9f7dc60 100644 --- a/src/ToolboxBundle/Registry/CalculatorRegistry.php +++ b/src/ToolboxBundle/Registry/CalculatorRegistry.php @@ -2,42 +2,27 @@ namespace ToolboxBundle\Registry; +use ToolboxBundle\Calculator\ColumnCalculatorInterface; +use ToolboxBundle\Calculator\SlideColumnCalculatorInterface; + class CalculatorRegistry implements CalculatorRegistryInterface { - /** - * @var array - */ - protected $adapter = [ + protected array $adapter = [ 'column' => [], 'slide_column' => [] ]; + private string $columnInterface; + private string $slideColumnInterface; - /** - * @var string - */ - private $columnInterface; - - /** - * @var string - */ - private $slideColumnInterface; - - /** - * @param string $columnInterface - * @param string $slideColumnInterface - */ - public function __construct($columnInterface, $slideColumnInterface) + public function __construct(string $columnInterface, string $slideColumnInterface) { $this->columnInterface = $columnInterface; $this->slideColumnInterface = $slideColumnInterface; } - /** - * {@inheritdoc} - */ - public function register($id, $service, $type) + public function register(string $id, mixed $service, string $type): void { - $interface = $type == 'column' ? $this->columnInterface : $this->slideColumnInterface; + $interface = $type === 'column' ? $this->columnInterface : $this->slideColumnInterface; if (!in_array($interface, class_implements($service), true)) { throw new \InvalidArgumentException( @@ -48,18 +33,12 @@ public function register($id, $service, $type) $this->adapter[$type][$id] = $service; } - /** - * {@inheritdoc} - */ - public function has($alias, $type) + public function has(string $alias, string $type): bool { return isset($this->adapter[$type][$alias]); } - /** - * {@inheritdoc} - */ - public function getColumnCalculator($alias) + public function getColumnCalculator($alias): ColumnCalculatorInterface { if (!$this->has($alias, 'column')) { throw new \Exception('"' . $alias . '" Column Calculator Identifier does not exist'); @@ -68,10 +47,7 @@ public function getColumnCalculator($alias) return $this->get($alias, 'column'); } - /** - * {@inheritdoc} - */ - public function getSlideColumnCalculator($alias) + public function getSlideColumnCalculator($alias): SlideColumnCalculatorInterface { if (!$this->has($alias, 'slide_column')) { throw new \Exception('"' . $alias . '" Slide Column Calculator Identifier does not exist'); @@ -80,10 +56,7 @@ public function getSlideColumnCalculator($alias) return $this->get($alias, 'slide_column'); } - /** - * {@inheritdoc} - */ - public function get($alias, $type) + public function get($alias, $type): SlideColumnCalculatorInterface|ColumnCalculatorInterface { if (!$this->has($alias, $type)) { throw new \Exception('"' . $alias . '" Calculator Identifier does not exist'); diff --git a/src/ToolboxBundle/Registry/CalculatorRegistryInterface.php b/src/ToolboxBundle/Registry/CalculatorRegistryInterface.php index d87d4898..93e04d9f 100644 --- a/src/ToolboxBundle/Registry/CalculatorRegistryInterface.php +++ b/src/ToolboxBundle/Registry/CalculatorRegistryInterface.php @@ -7,42 +7,16 @@ interface CalculatorRegistryInterface { - /** - * @param string $id - * @param string $service - * @param string $type - */ - public function register($id, $service, $type); + public function register(string $id, mixed $service, string $type): void; - /** - * @param string $alias - * - * @return SlideColumnCalculatorInterface - */ - public function getSlideColumnCalculator($alias); + public function getSlideColumnCalculator(string $alias): SlideColumnCalculatorInterface; - /** - * @param string $alias - * - * @return ColumnCalculatorInterface - */ - public function getColumnCalculator($alias); + public function getColumnCalculator(string $alias): ColumnCalculatorInterface; - /** - * @param string $alias - * @param string $type - * - * @return bool - */ - public function has($alias, $type); + public function has(string $alias, string $type): bool; /** - * @param string $alias - * @param string $type - * * @throws \Exception - * - * @return SlideColumnCalculatorInterface|ColumnCalculatorInterface */ - public function get($alias, $type); + public function get(string $alias, string $type): SlideColumnCalculatorInterface|ColumnCalculatorInterface; } diff --git a/src/ToolboxBundle/Registry/StoreProviderRegistry.php b/src/ToolboxBundle/Registry/StoreProviderRegistry.php index 29b8f9ad..b831c37b 100644 --- a/src/ToolboxBundle/Registry/StoreProviderRegistry.php +++ b/src/ToolboxBundle/Registry/StoreProviderRegistry.php @@ -6,15 +6,9 @@ class StoreProviderRegistry implements StoreProviderRegistryInterface { - /** - * @var array - */ - protected $services = []; - - /** - * {@inheritdoc} - */ - public function register($identifier, $service) + protected array $services = []; + + public function register(string $identifier, mixed $service): void { if (!in_array(StoreProviderInterface::class, class_implements($service), true)) { throw new \InvalidArgumentException( @@ -25,18 +19,12 @@ public function register($identifier, $service) $this->services[$identifier] = $service; } - /** - * {@inheritdoc} - */ - public function has($identifier) + public function has(string $identifier): bool { return isset($this->services[$identifier]); } - /** - * {@inheritdoc} - */ - public function get($identifier) + public function get(string $identifier): StoreProviderInterface { if (!$this->has($identifier)) { throw new \Exception('"' . $identifier . '" Store provider does not exist.'); diff --git a/src/ToolboxBundle/Registry/StoreProviderRegistryInterface.php b/src/ToolboxBundle/Registry/StoreProviderRegistryInterface.php index 58187a41..dce3468d 100644 --- a/src/ToolboxBundle/Registry/StoreProviderRegistryInterface.php +++ b/src/ToolboxBundle/Registry/StoreProviderRegistryInterface.php @@ -6,25 +6,12 @@ interface StoreProviderRegistryInterface { - /** - * @param string $identifier - * @param StoreProviderInterface $service - */ - public function register($identifier, $service); + public function register(string $identifier, mixed $service): void; - /** - * @param string $identifier - * - * @return bool - */ - public function has($identifier); + public function has(string $identifier): bool; /** - * @param string $identifier - * - * @return StoreProviderInterface - * * @throws \Exception */ - public function get($identifier); + public function get(string $identifier): StoreProviderInterface; } diff --git a/src/ToolboxBundle/Resolver/ContextResolver.php b/src/ToolboxBundle/Resolver/ContextResolver.php index 6d13387c..be191542 100644 --- a/src/ToolboxBundle/Resolver/ContextResolver.php +++ b/src/ToolboxBundle/Resolver/ContextResolver.php @@ -4,10 +4,7 @@ class ContextResolver implements ContextResolverInterface { - /** - * {@inheritdoc} - */ - public function getCurrentContextIdentifier() + public function getCurrentContextIdentifier(): ?string { return null; } diff --git a/src/ToolboxBundle/Resolver/ContextResolverInterface.php b/src/ToolboxBundle/Resolver/ContextResolverInterface.php index 2da38d21..c4ac36bf 100644 --- a/src/ToolboxBundle/Resolver/ContextResolverInterface.php +++ b/src/ToolboxBundle/Resolver/ContextResolverInterface.php @@ -4,8 +4,5 @@ interface ContextResolverInterface { - /** - * @return null|string - */ - public function getCurrentContextIdentifier(); + public function getCurrentContextIdentifier(): ?string; } diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/accordion.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/accordion.yml index 008fd999..0acebd96 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/accordion.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/accordion.yml @@ -2,10 +2,12 @@ services: ToolboxBundle\Document\Areabrick\Accordion\Accordion: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: accordion } + - { name: toolbox.area.brick, id: accordion } toolbox: areas: accordion: + config_parameter: + reload_on_close: true config_elements: type: type: select @@ -19,8 +21,6 @@ toolbox: type: select title: 'Component' description: ~ - col_class: ~ - conditions: ~ config: store: accordion: 'Accordion' diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/anchor.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/anchor.yml index 1a8e0c51..4d1e2984 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/anchor.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/anchor.yml @@ -1,9 +1,8 @@ services: ToolboxBundle\Document\Areabrick\Anchor\Anchor: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick - autowire: true tags: - - { name: pimcore.area.brick, id: anchor } + - { name: toolbox.area.brick, id: anchor } toolbox: areas: anchor: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/columns.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/columns.yml index 94f8b770..6c908d6d 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/columns.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/columns.yml @@ -3,10 +3,12 @@ services: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick autowire: true tags: - - { name: pimcore.area.brick, id: columns } + - { name: toolbox.area.brick, id: columns } toolbox: areas: columns: + config_parameter: + reload_on_close: true config_elements: type: type: select @@ -24,8 +26,7 @@ toolbox: equal_height: type: checkbox title: 'Equal heights?' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/container.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/container.yml index c20bfe6d..3cc636dc 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/container.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/container.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Container\Container: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: container } + - { name: toolbox.area.brick, id: container } toolbox: areas: container: @@ -10,8 +10,7 @@ toolbox: full_width_container: type: checkbox title: 'Fluid Container (Full Width)' - config: - reload: true + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/content.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/content.yml index 78f8bacd..f6acfaa0 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/content.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/content.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Content\Content: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: content } + - { name: toolbox.area.brick, id: content } toolbox: areas: content: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/download.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/download.yml index 8f5fbe40..de2ba03f 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/download.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/download.yml @@ -3,7 +3,7 @@ services: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick autowire: true tags: - - { name: pimcore.area.brick, id: download } + - { name: toolbox.area.brick, id: download } toolbox: areas: download: @@ -11,18 +11,15 @@ toolbox: downloads: type: relations title: 'Files' - config: - reload: true + config: ~ show_preview_images: type: checkbox title: 'Show preview images' - config: - reload: false + config: ~ show_file_info: type: checkbox title: 'Show file info' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/gallery.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/gallery.yml index af4e776b..ebf81cfe 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/gallery.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/gallery.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Gallery\Gallery: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: gallery } + - { name: toolbox.area.brick, id: gallery } toolbox: areas: gallery: @@ -10,18 +10,15 @@ toolbox: images: type: relations title: 'Images or Folder' - config: - reload: true + config: ~ use_light_box: type: checkbox title: 'Use Lightbox' - config: - reload: false + config: ~ use_thumbnails: type: checkbox title: 'Use Thumbnails' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/googleMap.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/googleMap.yml index fe15baa9..ba00fe22 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/googleMap.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/googleMap.yml @@ -7,7 +7,7 @@ services: arguments: $googleMapsHostUrl: '%toolbox_google_maps_host_url%' tags: - - { name: pimcore.area.brick, id: googleMap } + - { name: toolbox.area.brick, id: googleMap } toolbox: areas: googleMap: @@ -21,12 +21,10 @@ toolbox: maxValue: 19 decimalPrecision: 0 default: 12 - reload: false map_type: type: select title: 'Map type' config: - reload: true store: roadmap: ROADMAP satellite: SATELLITE @@ -36,8 +34,7 @@ toolbox: iw_on_init: type: checkbox title: 'Open Info Window by Default' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/headline.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/headline.yml index 083a39b8..c242d891 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/headline.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/headline.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Headline\Headline: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: headline } + - { name: toolbox.area.brick, id: headline } toolbox: areas: headline: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/iframe.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/iframe.yml index 851bcadd..3ce5901d 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/iframe.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/iframe.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\IFrame\IFrame: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: iFrame } + - { name: toolbox.area.brick, id: iFrame } toolbox: areas: iFrame: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/image.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/image.yml index 61ab1d19..8cd545d8 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/image.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/image.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Image\Image: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: image } + - { name: toolbox.area.brick, id: image } toolbox: areas: image: @@ -10,20 +10,15 @@ toolbox: image_link: type: link title: 'Link' - config: - reload: true + config: ~ use_light_box: type: checkbox title: 'Use Lightbox' - col_class: t-col-half - config: - reload: false + config: ~ show_caption: type: checkbox title: 'Display Caption' - col_class: t-col-half - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/linkList.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/linkList.yml index 70370693..fa2c842e 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/linkList.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/linkList.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\LinkList\LinkList: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: linkList } + - { name: toolbox.area.brick, id: linkList } toolbox: areas: linkList: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainer.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainer.yml index 96422671..f931eba7 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainer.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainer.yml @@ -1,8 +1,11 @@ services: ToolboxBundle\Document\Areabrick\ParallaxContainer\ParallaxContainer: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick + arguments: + - '@translator' + - '@pimcore.templating.engine.delegating' tags: - - { name: pimcore.area.brick, id: parallaxContainer } + - { name: toolbox.area.brick, id: parallaxContainer } toolbox: areas: parallaxContainer: @@ -11,7 +14,6 @@ toolbox: type: select title: 'Parallax Template' config: - reload: true store: no-template: 'No Template' default: no-template @@ -25,12 +27,10 @@ toolbox: asset: - image - video - reload: true background_color: type: select title: Background Color config: - reload: true store: no-background-color: 'No Background Color' default: no-background-color @@ -52,7 +52,6 @@ toolbox: half-window-width: 'Half Window Width' third-window-width: 'Third Window Width' quarter-window-width: 'Quarter Window Width' - reload: true image_behind: type: parallaximage title: 'Images Behind Main Container' @@ -71,7 +70,6 @@ toolbox: half-window-width: 'Half Window Width' third-window-width: 'Third Window Width' quarter-window-width: 'Quarter Window Width' - reload: true additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainerSection.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainerSection.yml index 941106c9..e7aa20ec 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainerSection.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/parallaxContainerSection.yml @@ -6,7 +6,6 @@ toolbox: type: select title: 'Section Template' config: - reload: true store: no-template: 'No Template' default: no-template @@ -14,7 +13,6 @@ toolbox: type: select title: 'Section Wrapper Type' config: - reload: true description: 'If you need to add some content columns, apply a default or fluid container as wrapper.' store: none: 'No Section Wrapper' @@ -25,7 +23,6 @@ toolbox: type: relation title: 'Background Image' config: - reload: true types: - asset subtypes: @@ -36,7 +33,6 @@ toolbox: type: select title: 'Background Color' config: - reload: true store: no-background-color: 'No Background Color' default: no-background-color diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/separator.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/separator.yml index 76c6fe74..3a248291 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/separator.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/separator.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Separator\Separator: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: separator } + - { name: toolbox.area.brick, id: separator } toolbox: areas: separator: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/slideColumns.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/slideColumns.yml index 42f8057d..19478b94 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/slideColumns.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/slideColumns.yml @@ -3,7 +3,7 @@ services: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick autowire: true tags: - - { name: pimcore.area.brick, id: slideColumns } + - { name: toolbox.area.brick, id: slideColumns } toolbox: areas: slideColumns: @@ -21,8 +21,7 @@ toolbox: equal_height: type: checkbox title: 'Equal heights?' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/snippet.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/snippet.yml index 795788fb..728ac7c4 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/snippet.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/snippet.yml @@ -2,4 +2,4 @@ services: ToolboxBundle\Document\Areabrick\Snippet\Snippet: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: snippet } \ No newline at end of file + - { name: toolbox.area.brick, id: snippet } \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/spacer.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/spacer.yml index 292a4f77..8f3f3a68 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/spacer.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/spacer.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Spacer\Spacer: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: spacer } + - { name: toolbox.area.brick, id: spacer } toolbox: areas: spacer: @@ -11,7 +11,6 @@ toolbox: type: select title: 'Space Class' config: - reload: false store: spacer-none: 'No Space' spacer-50: '50 Pixel' diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/teaser.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/teaser.yml index 96833a7e..4e75eb7c 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/teaser.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/teaser.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Teaser\Teaser: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: teaser } + - { name: toolbox.area.brick, id: teaser } toolbox: areas: teaser: @@ -18,8 +18,6 @@ toolbox: layout: type: select title: 'Layout' - conditions: - - type: direct config: store: default: 'Default' @@ -27,12 +25,8 @@ toolbox: use_light_box: type: checkbox title: 'use Lightbox?' - conditions: - - type: direct config: ~ additional_classes: type: additionalClasses - conditions: - - type: direct config: store: ~ diff --git a/src/ToolboxBundle/Resources/config/pimcore/areas/video.yml b/src/ToolboxBundle/Resources/config/pimcore/areas/video.yml index 7c6d002a..5485d27a 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/areas/video.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/areas/video.yml @@ -2,7 +2,7 @@ services: ToolboxBundle\Document\Areabrick\Video\Video: parent: ToolboxBundle\Document\Areabrick\AbstractAreabrick tags: - - { name: pimcore.area.brick, id: video } + - { name: toolbox.area.brick, id: video } toolbox: areas: video: @@ -10,8 +10,7 @@ toolbox: autoplay: type: checkbox title: 'Autoplay?' - config: - reload: false + config: ~ additional_classes: type: additionalClasses config: diff --git a/src/ToolboxBundle/Resources/config/pimcore/config.yml b/src/ToolboxBundle/Resources/config/pimcore/config.yml index 01b70475..b4129df1 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/config.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/config.yml @@ -1,3 +1,7 @@ +doctrine_migrations: + migrations_paths: + 'ToolboxBundle\Migrations': '@ToolboxBundle/Migrations' + imports: - { resource: areas/*.yml } - { resource: ckeditor/*.yml } @@ -6,5 +10,4 @@ imports: - { resource: area_restrictions.yml } - { resource: data_attributes.yml } - { resource: image_thumbnails.yml } - - { resource: toolbar.yml } - { resource: document/editables.yml } \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/pimcore/document/editables.yml b/src/ToolboxBundle/Resources/config/pimcore/document/editables.yml index 06b083d9..e3ef59d4 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/document/editables.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/document/editables.yml @@ -1,9 +1,8 @@ pimcore: documents: - tags: + editables: map: - googlemap: \ToolboxBundle\Model\Document\Tag\GoogleMap - parallaximage: \ToolboxBundle\Model\Document\Tag\ParallaxImage - vhs: \ToolboxBundle\Model\Document\Tag\Vhs - dynamiclink: \ToolboxBundle\Model\Document\Tag\DynamicLink - columnadjuster: \ToolboxBundle\Model\Document\Tag\ColumnAdjuster \ No newline at end of file + googlemap: \ToolboxBundle\Model\Document\Editable\GoogleMap + parallaximage: \ToolboxBundle\Model\Document\Editable\ParallaxImage + vhs: \ToolboxBundle\Model\Document\Editable\Vhs + columnadjuster: \ToolboxBundle\Model\Document\Editable\ColumnAdjuster \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/pimcore/routing.yml b/src/ToolboxBundle/Resources/config/pimcore/routing.yml index 613a5b70..13d264bf 100644 --- a/src/ToolboxBundle/Resources/config/pimcore/routing.yml +++ b/src/ToolboxBundle/Resources/config/pimcore/routing.yml @@ -1,15 +1,24 @@ toolbox_ckeditor_area_style: path: /admin/toolbox-ckeditor-style.js - defaults: { _controller: ToolboxBundle\Controller\Admin\SettingsController:ckEditorAreaStyleAction } + controller: ToolboxBundle\Controller\Admin\SettingsController::ckEditorAreaStyleAction + defaults: { } + options: + expose: true toolbox_ckeditor_object_style: path: /admin/toolbox-ckeditor-object-style.js - defaults: { _controller: ToolboxBundle\Controller\Admin\SettingsController:ckEditorObjectStyleAction } + controller: ToolboxBundle\Controller\Admin\SettingsController::ckEditorObjectStyleAction + defaults: { } + options: + expose: true toolbox_frontend_ajax_google_maps_iw: path: /toolbox/ajax/gm-info-window - defaults: { _controller: ToolboxBundle\Controller\AjaxController:gmInfoWindowAction } + controller: ToolboxBundle\Controller\AjaxController::gmInfoWindowAction + defaults: { } toolbox_frontend_ajax_video_types: path: /toolbox/ajax/video-allowed-video-types - defaults: { _controller: ToolboxBundle\Controller\AjaxController:videoGetTypesAction } + controller: ToolboxBundle\Controller\AjaxController::videoGetTypesAction + defaults: { } toolbox_column_adjuster: path: /admin/toolbox-get-column-info - defaults: { _controller: ToolboxBundle\Controller\Admin\ColumnAdjusterController:getColumnInfoAction } \ No newline at end of file + controller: ToolboxBundle\Controller\Admin\ColumnAdjusterController::getColumnInfoAction + defaults: { } \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/pimcore/toolbar.yml b/src/ToolboxBundle/Resources/config/pimcore/toolbar.yml deleted file mode 100644 index 5f2dcec2..00000000 --- a/src/ToolboxBundle/Resources/config/pimcore/toolbar.yml +++ /dev/null @@ -1,9 +0,0 @@ -toolbox: - area_block_configuration: - toolbar: - title: Inhaltsbausteine - width: 200 - x: 10 - y: 125 - buttonWidth: 200 - groups: ~ \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/services/brick.yml b/src/ToolboxBundle/Resources/config/services/brick.yml index dc5d179f..99343b2e 100644 --- a/src/ToolboxBundle/Resources/config/services/brick.yml +++ b/src/ToolboxBundle/Resources/config/services/brick.yml @@ -5,17 +5,5 @@ services: autoconfigure: true public: true - # toolbox service brick configuration builder - ToolboxBundle\Builder\BrickConfigBuilder: - shared: false - - # base brick - ToolboxBundle\Document\Areabrick\AbstractAreabrick: - abstract: true - calls: - - [setConfigManager, ['@ToolboxBundle\Manager\ConfigManager']] - - [setBrickConfigBuilder, ['@ToolboxBundle\Builder\BrickConfigBuilder']] - - [setLayoutManager, ['@ToolboxBundle\Manager\LayoutManager']] - - # legacy alias - toolbox.area.brick.base_brick: '@ToolboxBundle\Document\Areabrick\AbstractAreabrick' \ No newline at end of file + ToolboxBundle\Builder\BrickConfigBuilderInterface: '@ToolboxBundle\Builder\BrickConfigBuilder' + ToolboxBundle\Builder\BrickConfigBuilder: ~ \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/config/services/command.yml b/src/ToolboxBundle/Resources/config/services/command.yml index e42f6c11..74514723 100644 --- a/src/ToolboxBundle/Resources/config/services/command.yml +++ b/src/ToolboxBundle/Resources/config/services/command.yml @@ -4,8 +4,3 @@ services: autowire: true autoconfigure: true public: false - - ToolboxBundle\Command\DynamicLinkMigrationCommand: - autowire: true - autoconfigure: true - public: false diff --git a/src/ToolboxBundle/Resources/config/services/controller.yml b/src/ToolboxBundle/Resources/config/services/controller.yml index 846c61ff..72fb9ecc 100644 --- a/src/ToolboxBundle/Resources/config/services/controller.yml +++ b/src/ToolboxBundle/Resources/config/services/controller.yml @@ -1,33 +1,8 @@ services: - ToolboxBundle\Controller\Admin\ColumnAdjusterController: + ToolboxBundle\Controller\: + resource: '../../Controller' public: true autowire: true - calls: - - [setContainer, ['@service_container']] - tags: - - { name: controller.service_arguments } - - ToolboxBundle\Controller\Admin\SettingsController: - public: true - autowire: true - calls: - - [setContainer, ['@service_container']] - tags: - - { name: controller.service_arguments } - - ToolboxBundle\Controller\AjaxController: - public: true - autowire: true - calls: - - [setContainer, ['@service_container']] - tags: - - { name: controller.service_arguments } - - ToolboxBundle\Controller\SnippetController: - public: true - autowire: true - calls: - - [setContainer, ['@service_container']] - tags: - - { name: controller.service_arguments } + autoconfigure: true + tags: ['controller.service_arguments'] diff --git a/src/ToolboxBundle/Resources/config/services/event.yml b/src/ToolboxBundle/Resources/config/services/event.yml index 12608881..f1300816 100644 --- a/src/ToolboxBundle/Resources/config/services/event.yml +++ b/src/ToolboxBundle/Resources/config/services/event.yml @@ -5,6 +5,10 @@ services: autoconfigure: true public: false + ToolboxBundle\EventListener\PermissionListener: + tags: + - { name: kernel.event_subscriber } + ToolboxBundle\EventListener\Frontend\FrontendJsListener: public: true tags: diff --git a/src/ToolboxBundle/Resources/config/services/manager.yml b/src/ToolboxBundle/Resources/config/services/manager.yml index 690b6ee7..c7337327 100644 --- a/src/ToolboxBundle/Resources/config/services/manager.yml +++ b/src/ToolboxBundle/Resources/config/services/manager.yml @@ -6,7 +6,7 @@ services: autowire: true autoconfigure: true calls: - - [setTemplating, ['@templating']] + - [setTemplating, ['@pimcore.templating.engine.delegating']] ToolboxBundle\Manager\AreaManagerInterface: '@ToolboxBundle\Manager\AreaManager' ToolboxBundle\Manager\AreaManager: @@ -25,3 +25,8 @@ services: public: false autowire: true + ToolboxBundle\Manager\PermissionManagerInterface: '@ToolboxBundle\Manager\PermissionManager' + ToolboxBundle\Manager\PermissionManager: + public: false + autowire: true + diff --git a/src/ToolboxBundle/Resources/config/services/twig.yml b/src/ToolboxBundle/Resources/config/services/twig.yml index 368d2039..3a02425a 100644 --- a/src/ToolboxBundle/Resources/config/services/twig.yml +++ b/src/ToolboxBundle/Resources/config/services/twig.yml @@ -13,8 +13,8 @@ services: tags: - { name: twig.extension } - ToolboxBundle\Twig\Extension\DocumentTagExtension: - parent: Pimcore\Twig\Extension\DocumentTagExtension + ToolboxBundle\Twig\Extension\DocumentEditableExtension: + parent: Pimcore\Twig\Extension\DocumentEditableExtension autowire: true public: false tags: diff --git a/src/ToolboxBundle/Resources/install/admin-translations/data.csv b/src/ToolboxBundle/Resources/install/admin-translations/data.csv index 36dd0f10..4a55ccf6 100644 --- a/src/ToolboxBundle/Resources/install/admin-translations/data.csv +++ b/src/ToolboxBundle/Resources/install/admin-translations/data.csv @@ -121,4 +121,6 @@ "Third Window Width","Third Window Width","Drittel Fensterbreite", "Quarter Window Width","Quarter Window Width","Viertel Fensterbreite", "Fluid Container (Full Width)","Fluid Container (Full Width)","Fluid Container (Volle Breite)", -"No Images for this gallery found.","No Images for this gallery found.","Es wurden keine Bilder für die Galerie gewählt.", \ No newline at end of file +"No Images for this gallery found.","No Images for this gallery found.","Es wurden keine Bilder für die Galerie gewählt.", +"No column size selected.","No column size selected.","Keine Spaltendefinition gewählt.", +"No downloads defined yet.","No downloads defined yet.","Keine Downloads gewählt.", \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/areas/googleMap/icon.svg b/src/ToolboxBundle/Resources/public/areas/google-map/icon.svg similarity index 100% rename from src/ToolboxBundle/Resources/public/areas/googleMap/icon.svg rename to src/ToolboxBundle/Resources/public/areas/google-map/icon.svg diff --git a/src/ToolboxBundle/Resources/public/areas/iFrame/icon.svg b/src/ToolboxBundle/Resources/public/areas/iframe/icon.svg similarity index 100% rename from src/ToolboxBundle/Resources/public/areas/iFrame/icon.svg rename to src/ToolboxBundle/Resources/public/areas/iframe/icon.svg diff --git a/src/ToolboxBundle/Resources/public/areas/linkList/icon.svg b/src/ToolboxBundle/Resources/public/areas/link-list/icon.svg similarity index 100% rename from src/ToolboxBundle/Resources/public/areas/linkList/icon.svg rename to src/ToolboxBundle/Resources/public/areas/link-list/icon.svg diff --git a/src/ToolboxBundle/Resources/public/areas/parallaxContainer/icon.svg b/src/ToolboxBundle/Resources/public/areas/parallax-container/icon.svg similarity index 100% rename from src/ToolboxBundle/Resources/public/areas/parallaxContainer/icon.svg rename to src/ToolboxBundle/Resources/public/areas/parallax-container/icon.svg diff --git a/src/ToolboxBundle/Resources/public/areas/slideColumns/icon.svg b/src/ToolboxBundle/Resources/public/areas/slide-columns/icon.svg similarity index 100% rename from src/ToolboxBundle/Resources/public/areas/slideColumns/icon.svg rename to src/ToolboxBundle/Resources/public/areas/slide-columns/icon.svg diff --git a/src/ToolboxBundle/Resources/public/css/admin.css b/src/ToolboxBundle/Resources/public/css/admin.css index 46d701cc..2acbc088 100644 --- a/src/ToolboxBundle/Resources/public/css/admin.css +++ b/src/ToolboxBundle/Resources/public/css/admin.css @@ -27,6 +27,33 @@ padding: 10px; } +.toolbox-columns .toolbox-column .pimcore_area_entry .pimcore_area_buttons { + margin-top: 0; + top: 0 !important; +} + +/** + + Toolbox Maps + +**/ +div[data-type="googlemap"][data-fetch-error]::before { + content: attr(data-fetch-error); + position: absolute; + z-index: 99; + top: 10px; + left: 10px; + width: calc(100% - 20px); + font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; + background-color: #f2dede; + color: #a94442; + padding: 5px 10px; + margin: 5px 0; + border: 1px solid #a94442; + border-radius: 0; + font-size: 90%; +} + /** Toolbox Columns Adjuster @@ -176,7 +203,7 @@ padding: 10px; } -.toolbox-slide-columns > .row > .slide-columns .pimcore_tag_block:not(.slick-initialized) { +.toolbox-slide-columns > .row > .slide-columns .pimcore_editable_block:not(.slick-initialized) { overflow: hidden; } @@ -199,29 +226,29 @@ } .toolbox-slide-columns > .row > .slide-columns .slick-track > .pimcore_block_entry, -.toolbox-slide-columns > .row > .slide-columns .pimcore_tag_block > .pimcore_block_entry { +.toolbox-slide-columns > .row > .slide-columns .pimcore_editable_block > .pimcore_block_entry { display: block; float: left; clear: none; } .toolbox-slide-columns > .row > .slide-columns.slide-elements-2 .slick-track > .pimcore_block_entry, -.toolbox-slide-columns > .row > .slide-columns.slide-elements-2 .pimcore_tag_block > .pimcore_block_entry { +.toolbox-slide-columns > .row > .slide-columns.slide-elements-2 .pimcore_editable_block > .pimcore_block_entry { width: 49%; } .toolbox-slide-columns > .row > .slide-columns.slide-elements-3 .slick-track > .pimcore_block_entry, -.toolbox-slide-columns > .row > .slide-columns.slide-elements-3 .pimcore_tag_block > .pimcore_block_entry { +.toolbox-slide-columns > .row > .slide-columns.slide-elements-3 .pimcore_editable_block > .pimcore_block_entry { width: 33%; } .toolbox-slide-columns > .row > .slide-columns.slide-elements-4 .slick-track > .pimcore_block_entry, -.toolbox-slide-columns > .row > .slide-columns.slide-elements-4 .pimcore_tag_block > .pimcore_block_entry { +.toolbox-slide-columns > .row > .slide-columns.slide-elements-4 .pimcore_editable_block > .pimcore_block_entry { width: 24%; } .toolbox-slide-columns > .row > .slide-columns.slide-elements-6 .slick-track > .pimcore_block_entry, -.toolbox-slide-columns > .row > .slide-columns.slide-elements-6 .pimcore_tag_block > .pimcore_block_entry { +.toolbox-slide-columns > .row > .slide-columns.slide-elements-6 .pimcore_editable_block > .pimcore_block_entry { width: 15%; } @@ -327,7 +354,7 @@ background: rgba(255, 255, 255, 0.5); } -.toolbox-parallax-container .parallax-content > .pimcore_tag_block { +.toolbox-parallax-container .parallax-content > .pimcore_editable_block { margin: 10px; } @@ -361,19 +388,6 @@ overflow: visible !important; } -/** - - Toolbox Googlemap Container - -**/ -.toolbox-googlemap-container { - -} - -.toolbox-google-map .pimcore_area_edit_button { - top: -35px !important; -} - /** ## ## --------------------------------------- @@ -405,24 +419,28 @@ Toolbox .toolbox-element-window Overlay Defaults **/ -.alert-info { +.tb-alert-info { font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; - background-color: #d9edf7; - color: #31708f; - padding: 10px; - margin: 10px 0; - border: 1px solid #bce8f1; + background-color: #dcd1ea; + color: #6428b4; + padding: 5px 10px; + margin: 5px 0; + border: 1px solid #6428b4; border-radius: 0; + font-size: 90%; + width: 100%; } -.alert-danger { +.tb-alert-danger { font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; background-color: #f2dede; color: #a94442; - padding: 10px; - margin: 10px 0; - border: 1px solid #ebccd1; + padding: 5px 10px; + margin: 5px 0; + border: 1px solid #a94442; border-radius: 0; + font-size: 90%; + width: 100%; } /** Fix Pimcore Bug: If Toolbar is above .pimcore_iframe_mask, z-index will catch accessibility. **/ @@ -430,247 +448,202 @@ z-index: 199 !important; } -.toolbox-element-edit-button { - position: relative; - display: block; - margin: 3px 0 0 0; - padding: 4px; - background: #7b7b7b; - opacity: .8; - text-align: left; - -webkit-transition: opacity .3s ease; - -ms-transition: opacity .3s ease; - transition: opacity .3s ease; -} - -.toolbox-element-edit-button.no-interaction { - height: 35px; -} - -.toolbox-element-edit-button:before { - content: attr(data-title); - position: absolute; - right: 0; - padding: 4px 30px 0 0; - text-transform: uppercase; - font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; - font-size: 12px; - font-weight: normal; - letter-spacing: 0.1em; - color: #bfbfbf; - line-height: 1.5; -} - -.toolbox-element-edit-button:hover { - opacity: 1; -} - -.toolbox-element-edit-button .x-btn-default-small { - border-color: transparent; - background: #000; - padding: 5px 7px 4px 7px; - border-radius: 2px; -} +/** -.toolbox-element-edit-button .x-btn-default-small .x-btn-inner-default-small { - color: white; -} + Extjs Dropdowns list to default -.toolbox-element-window { +**/ +ul.x-list-plain { + display: block !important; } -/* move window element out of scope, because display none won't work because of extjs rendering issues */ -.toolbox-element-window-hidden { - visibility: hidden; - position: absolute; - top: -50000px; - left: -50000px; +ul li.x-boundlist-item { + list-style: inherit; + background: inherit; + margin: inherit; + line-height: 30px; + padding: 0 0 0 10px !important; + display: block !important; } -.toolbox-edit-overlay label { - font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; - font-size: 12px; - font-weight: 700; - padding-right: 10px; +ul li.x-boundlist-item:before { + content: none; } -.toolbox-edit-overlay { - min-height: 150px; /* always force min height! */ - margin: 0; +ul li.x-boundlist-item:hover { + color: inherit; } -.x-window:not(.grid-adjuster-active) .toolbox-edit-overlay.small { - max-width: 560px; +ul li.x-boundlist-selected { + color: #fff; + background: #3c3f41; + border-color: #3c3f41; } -.x-window:not(.grid-adjuster-active) .toolbox-edit-overlay.large { - max-width: 760px; +ul li.x-boundlist-item-over { + color: #404040; + border-color: transparent; + background: #dfe6ec; } -.toolbox-edit-overlay .t-row { - - margin: 0 0 10px 0; - padding: 0 0 10px 0; - border-bottom: 1px dashed #d8d8d8; - +ul li.x-boundlist-selected.x-boundlist-item-over { + color: #fff; + background: #404040; } -.toolbox-edit-overlay .t-row:empty { - display: none; -} +/* only in single edit mode */ -.toolbox-edit-overlay .t-row.editmode-hidden, -.toolbox-edit-overlay .t-row .toolbox-element > .editmode-hidden { - display: none; +body > .single-teaser { + max-width: 250px; } -.toolbox-edit-overlay .t-row:after { - content: "."; - clear: both; - display: block; - visibility: hidden; - height: 0; +body > .single-teaser img { + max-width: 100%; } -.toolbox-edit-overlay .t-row .x-form-type-checkbox { - position: relative; - top: 12px; - left: 5px; +/* Override theme tridon stuff */ +.x-panel-body-default { + font-family: inherit; + background: transparent; } -.toolbox-edit-overlay .t-row .t-col-full { - float: none; - width: 100%; +.toolbox-parallax-container .editmode-label { position: relative; - min-height: 1px; + z-index: 3; } -.toolbox-edit-overlay .t-row .t-col-half { - float: left; - width: 50%; - position: relative; - min-height: 1px; +/* Snippet */ +.toolbox-snippet .x-panel-body-default .x-autocontainer-outerCt { + overflow: hidden !important; } -.toolbox-edit-overlay .t-row > .toolbox-element:nth-child(1) > .t-col-half { - padding-right: 5px; -} +/** -.toolbox-edit-overlay .t-row .t-col-third { - float: left; - width: 33.3333%; - position: relative; - min-height: 1px; -} + Toolbox Edit Button -.toolbox-edit-overlay .t-row > .toolbox-element:nth-child(1) > .t-col-third { - padding-right: 5px; -} +**/ -.toolbox-edit-overlay .t-row > .toolbox-element:nth-child(2) > .t-col-third { - padding-right: 5px; -} +.pimcore_area_buttons { -.x-window:not(.grid-adjuster-active) .toolbox-edit-overlay.large .t-row .pimcore_editable .x-panel-default { - width: 760px; -} + position: relative; + top: 0; + margin-top: 20px; + left: 0; + width: 100% !important; + display: block !important; + visibility: visible !important; -.x-window:not(.grid-adjuster-active) .toolbox-edit-overlay.small .t-row .pimcore_editable .x-panel-default { - width: 560px; + opacity: 0.3; + -webkit-transition: opacity 0.3s ease; + -moz-transition: opacity 0.3s ease; + -o-transition: opacity 0.3s ease; + transition: opacity 0.3s ease; } -.toolbox-edit-overlay .pimcore_tag_input { - border: 1px solid #b7b7b7; - padding: 5px; - box-shadow: none; - display: block !important; +.pimcore_area_buttons.top { + top: 15px !important; } -.toolbox-edit-overlay .t-row .description { - display: block; - margin: 10px 0; - font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; - font-size: 13px; - line-height: 20px; - background: #f7f7f7; - padding: 10px; - border: 1px solid #eee; +.pimcore_block_entry:hover > div.pimcore_area_buttons { + opacity: 1; } -.toolbox-edit-overlay .t-row .pimcore_tag_select { - display: block; +.pimcore_area_buttons .pimcore_block_label { + display: none !important; } /** - Extjs Dropdowns list to default + Toolbox Edit Button **/ -ul.x-list-plain { - display: block !important; -} -ul li.x-boundlist-item { - list-style: inherit; - background: inherit; - margin: inherit; - line-height: 30px; - padding: 0 0 0 10px !important; - display: block !important; +.toolbox-element-edit-button { + position: relative; + display: block; + padding: 0; + opacity: .8; + text-align: left; + -webkit-transition: opacity .3s ease; + transition: opacity .3s ease; + + background: transparent; + border-bottom: 2px solid #6428b4; + margin-bottom: 5px; } -ul li.x-boundlist-item:before { - content: none; +.toolbox-element-edit-button:before { + content: attr(data-title); + position: absolute; + right: 0; + padding: 0; + text-transform: uppercase; + font-family: 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; + font-size: 12px; + font-weight: normal; + letter-spacing: 0.1em; + color: #6428b4; + line-height: 1.5; + top: 9px; } -ul li.x-boundlist-item:hover { - color: inherit; +.toolbox-element-edit-button:hover { + opacity: 1; } -ul li.x-boundlist-selected { - color: #fff; - background: #3c3f41; - border-color: #3c3f41; +.toolbox-element-edit-button.no-interaction { + height: 26px; } -ul li.x-boundlist-item-over { - color: #404040; +.toolbox-element-edit-button .x-btn-default-small { border-color: transparent; - background: #dfe6ec; + background: #6428b4; + padding: 0 10px; + margin: 3px 3px 3px 0; } -ul li.x-boundlist-selected.x-boundlist-item-over { - color: #fff; - background: #404040; +.toolbox-element-edit-button .x-btn-default-small .x-btn-inner-default-small { + color: white; } -/* only in single edit mode */ - -body > .single-teaser { - max-width: 250px; +.toolbox-element-edit-button .x-btn-default-small .x-btn-inner-default-small { + font: 400 11px/16px 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; } -body > .single-teaser img { - max-width: 100%; +.pimcore_area_buttons .pimcore_area_buttons_inner { + background: transparent; } -/* Override theme tridon stuff */ -.x-panel-body-default { - font-family: inherit; - background: transparent; +.pimcore_area_buttons::after { + content: none; } -.toolbox-parallax-container .editmode-label { +/* + Editable Permissions + */ +.editable-blocked { position: relative; - z-index: 3; } -/* Snippet */ -.toolbox-snippet .x-panel-body-default .x-autocontainer-outerCt { - overflow: hidden !important; +.editable-blocked:before { + content: ''; + position: absolute; + left: 0; + top: 0; + right: 0; + bottom: 0; + width: 100%; + height: 100%; + background-color: #c8c8c880; + cursor: default; + z-index: 9999; } -/* Modal Fix */ -.toolbox-modal-open { - overflow: hidden; +.editable-blocked .pimcore_area_buttons, +.editable-blocked .toolbox-element-edit-button a { + display: none !important; +} + +.editable-blocked .toolbox-element-edit-button { + min-height: 35px; } \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/css/admin_53.css b/src/ToolboxBundle/Resources/public/css/admin_53.css deleted file mode 100644 index efafedf4..00000000 --- a/src/ToolboxBundle/Resources/public/css/admin_53.css +++ /dev/null @@ -1,74 +0,0 @@ -/** -## -## --------------------------------------- -## ONLY TOOLBOX INTERNAL STUFF FOR PIMCORE >= 5.3.0 -## --------------------------------------- -## -**/ - -.pimcore_area_buttons .pimcore_block_plus, -.pimcore_area_buttons .pimcore_block_plus_up, -.pimcore_area_buttons .pimcore_block_minus, -.pimcore_area_buttons .pimcore_block_up, -.pimcore_area_buttons .pimcore_block_down, -.pimcore_area_buttons .pimcore_block_amount, -.pimcore_area_buttons .pimcore_block_type, -.pimcore_area_buttons .pimcore_block_options, -.pimcore_area_buttons .pimcore_block_visibility { - float: left; -} - -.pimcore_area_buttons { - opacity: 0.3; - -webkit-transition: opacity 0.3s ease; - -moz-transition: opacity 0.3s ease; - -o-transition: opacity 0.3s ease; - transition: opacity 0.3s ease; -} - -.pimcore_area_buttons .pimcore_block_label { - display: none !important; -} - -.pimcore_block_entry:hover > div.pimcore_area_buttons { - opacity: 1; -} - -.pimcore_area_buttons { - position: relative; - top: 0; - margin-top: 20px; - left: 0; - width: 100% !important; - display: block !important; - visibility: visible !important; -} - -.toolbox-columns .toolbox-column .pimcore_area_entry:first-child .pimcore_area_buttons { - margin-top: 0; -} - -.pimcore_area_buttons .pimcore_area_buttons_inner { - background: transparent; -} - -.pimcore_area_buttons::after { - content: none; -} - -.toolbox-element-edit-button { - padding: 0; -} - -.toolbox-element-edit-button .x-btn-default-small { - padding: 1px 7px 1px 7px; - margin: 3px; -} - -.toolbox-element-edit-button .x-btn-default-small .x-btn-inner-default-small { - font: 400 11px/16px 'Open Sans', 'Helvetica Neue', helvetica, arial, verdana, sans-serif; -} - -.toolbox-element-edit-button.no-interaction { - height: 26px; -} diff --git a/src/ToolboxBundle/Resources/public/css/admin_544.css b/src/ToolboxBundle/Resources/public/css/admin_544.css deleted file mode 100644 index a0c693b7..00000000 --- a/src/ToolboxBundle/Resources/public/css/admin_544.css +++ /dev/null @@ -1,11 +0,0 @@ -/** -## -## --------------------------------------- -## ONLY TOOLBOX INTERNAL STUFF FOR PIMCORE >= 5.4.4 -## --------------------------------------- -## -**/ - -.pimcore_area_buttons.top { - top: 15px !important; -} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/backend/toolbox.js b/src/ToolboxBundle/Resources/public/js/backend/toolbox.js index 40b9e75b..e04d0383 100644 --- a/src/ToolboxBundle/Resources/public/js/backend/toolbox.js +++ b/src/ToolboxBundle/Resources/public/js/backend/toolbox.js @@ -1,129 +1,5 @@ pimcore.registerNS('pimcore.plugin.toolbox.main'); -pimcore.plugin.toolbox.main = Class.create({ - - editWindows: {}, - - initialize: function () { - var _ = this; - try { - Ext.each(Ext.query('div[class="toolbox-element-edit-button"]:not([class="no-interaction"])'), function (item) { - var editButton = new Ext.Button({ - cls: 'pimcore_block_button_plus', - iconCls: 'pimcore_icon_edit', - text: t('edit'), - handler: _.openElementConfig.bind(_, this) - }); - editButton.render(item); - }); - - } catch (e) { - console.log(e); - } - }, - - openElementConfig: function (element) { - - var _ = this, - content; - - if (element.getAttribute('editor-id') !== null) { - editWindow = this.editWindows[element.getAttribute('editor-id')]['editor']; - content = this.editWindows[element.getAttribute('editor-id')]['content']; - } else { - content = Ext.get(element).parent().down('.toolbox-element-window'); - var editWindow = new Ext.Window({ - width: content.getAttribute('data-edit-window-size') === 'small' ? 600 : 800, - height: content.getAttribute('data-edit-window-size') === 'small' ? 400 : 600, - title: t('edit_toolbox_element_configuration'), - closeAction: 'hide', - bodyStyle: 'padding: 10px;', - closable: false, - scrollable: 'y', - listeners: { - afterrender: function (win) { - var needReload = false; - content.removeCls('toolbox-element-window-hidden'); - win.body.down('.x-autocontainer-innerCt').insertFirst(content); - - if (content.query('div.toolbox-element[data-reload=true]').length > 0) { - needReload = true; - } - - var id = win.id.replace('#', ''); - element.setAttribute('editor-id', id); - - var elements = win.body.query('.pimcore_editable'); - for (var i = 0; i < elements.length; i++) { - var name = elements[i].getAttribute('id').split('pimcore_editable_').join(''); - for (var e = 0; e < editables.length; e++) { - - if (editables[e].getName() === name && typeof editables[e].updateLayout === 'function') { - editables[e].updateLayout(); - break; - } - } - } - - this.editWindows[id] = { - editor: win, - element: element, - needReload: needReload - }; - - }.bind(this) - }, - buttons: [{ - text: t('save'), - listeners: { - click: { - scope: _, - fn: _.editmodeSave, - args: [editWindow] - } - }, - iconCls: 'pimcore_icon_save' - }, { - text: t('cancel'), - listeners: { - click: { - scope: _, - fn: _.editmodeClose, - args: [editWindow] - } - }, - iconCls: 'pimcore_icon_cancel' - }] - }); - } - - document.body.classList.add('toolbox-modal-open'); - editWindow.show(); - }, - - editmodeSave: function (scope, button) { - var editWindow = button.up('window'), - data = this.editWindows[editWindow.id]; - - document.body.classList.remove('toolbox-modal-open'); - - if (!data.needReload) { - data.editor.close(); - return; - } - - data.editor.close(); - window.editWindow.reload(); - - }, - - editmodeClose: function (scope, button) { - var editWindow = button.up('window'), - data = this.editWindows[editWindow.id]; - document.body.classList.remove('toolbox-modal-open'); - data.editor.close(); - } - -}); +pimcore.plugin.toolbox.main = Class.create({}); Ext.onReady(function () { new pimcore.plugin.toolbox.main(); diff --git a/src/ToolboxBundle/Resources/public/js/document/edit.js b/src/ToolboxBundle/Resources/public/js/document/edit.js index 36edfcb3..0712c623 100644 --- a/src/ToolboxBundle/Resources/public/js/document/edit.js +++ b/src/ToolboxBundle/Resources/public/js/document/edit.js @@ -2,7 +2,7 @@ pimcore.registerNS('pimcore.document.edit'); pimcore.document.edit = Class.create(pimcore.document.edit, { /** - * Because pimocore does a sloppy job in this method, we need to override it: + * Because pimcore does a sloppy job in this method, we need to override it: * maskFrames will trigger to early => all iframe masks will have a wrong position! */ maskFrames: function () { diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/_route.js b/src/ToolboxBundle/Resources/public/js/document/editables/_route.js deleted file mode 100644 index c72ffab2..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/editables/_route.js +++ /dev/null @@ -1,10 +0,0 @@ -// deprecated. remove with toolbox 4.0 -pimcore.registerNS('toolbox.abstract.document.editable'); -pimcore.registerNS('toolbox.abstract.document.editables.link'); -pimcore.registerNS('toolbox.abstract.document.editables.relations'); -pimcore.registerNS('toolbox.abstract.document.editables.video'); - -toolbox.abstract.document.editable = Class.create(pimcore.document.editable, {}); -toolbox.abstract.document.editables.link = Class.create(pimcore.document.editables.link, {}); -toolbox.abstract.document.editables.relations = Class.create(pimcore.document.editables.relations, {}); -toolbox.abstract.document.editables.video = Class.create(pimcore.document.editables.video, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/areablock.js b/src/ToolboxBundle/Resources/public/js/document/editables/areablock.js index 57eefb42..4efc50ae 100644 --- a/src/ToolboxBundle/Resources/public/js/document/editables/areablock.js +++ b/src/ToolboxBundle/Resources/public/js/document/editables/areablock.js @@ -1,48 +1,139 @@ pimcore.registerNS('pimcore.document.editables.areablock'); pimcore.document.editables.areablock = Class.create(pimcore.document.editables.areablock, { - initialize: function ($super, id, name, options, data, inherited) { + initialize: function ($super, id, name, config, data, inherited) { - var i, $areaEl, $el, $editButton, $editDiv; + var setupToolbar; - $super(id, name, options, data, inherited); + this.config = this.parseConfig(config); - if (this.elements.length > 0) { + setupToolbar = typeof this.config.toolbar === 'undefined' || this.config.toolbar !== false; - for (i = 0; i < this.elements.length; i++) { + // wait until we've sorted permissions out! + this.config.toolbar = false; - try { + this.filterEditablesByPermission(); - $areaEl = Ext.get(this.elements[i]); - $editDiv = $areaEl.query('.pimcore_area_edit_button[data-name="' + this.name + '"]')[0]; + $super(id, name, config, data, inherited); - $areaEl.clearListeners(); + if(setupToolbar === true) { + this.createToolBar(); + } + + this.addToolboxEditBar(); + }, + + filterEditablesByPermission: function () { + + var filteredTypes = [], + filteredGroups = {}; + + if (Ext.isArray(this.config.types)) { + Ext.Array.each(this.config.types, function (brick) { + if (this.hasToolboxPermissionForEditable(brick.type) === true) { + filteredTypes.push(brick); + } + }.bind(this)); + } + + if (Ext.isObject(this.config.group)) { + Ext.Object.each(this.config.group, function (groupName, groupData) { + var groupIsValid = false; + if (Ext.isArray(groupData)) { + Ext.Array.each(groupData, function (typeName) { + if (Ext.Array.map(filteredTypes, function (brick) { + return brick.type; + }).indexOf(typeName) !== -1) { + groupIsValid = true; + return false; + } + }); + } + + if (groupIsValid === true) { + filteredGroups[groupName] = groupData; + } + + }); + + this.config.group = filteredGroups; + } + + this.config.types = filteredTypes; + + }, + + refresh: function ($super) { - if ($editDiv) { + $super(); - $el = Ext.DomHelper.insertAfter($editDiv, { - 'tag': 'div', - 'class': 'toolbox-element-edit-button' - }, true); + this.addToolboxEditBar(); + }, - //remove pimcore default button! - Ext.get($editDiv).destroy(); + hasToolboxPermissionForEditable: function(type) { - $editButton = new Ext.Button({ - cls: 'pimcore_block_button_plus', - iconCls: 'pimcore_icon_edit', - text: t('edit'), - handler: this.editmodeOpen.bind(this, this.elements[i]) - }); + if(!this.config.hasOwnProperty('toolbox_permissions')) { + return true; + } + + return this.config.toolbox_permissions.disallowed.indexOf(type) === -1; + }, + + addToolboxEditBar: function () { - $editButton.render($el); + var i, $areaEl, $areaButtonsEl, $editDiv, $labelDiv, $el, $editButton; + + if (this.elements.length === 0) { + return; + } - } + for (i = 0; i < this.elements.length; i++) { - } catch (e) { - console.log(e); + try { + + $areaEl = Ext.get(this.elements[i]); + $areaButtonsEl = $areaEl.query('.pimcore_area_buttons[data-name="' + this.name + '"]')[0]; + $editDiv = $areaEl.query('.pimcore_block_dialog[data-name="' + this.name + '"]')[0]; + $labelDiv = $areaEl.query('.pimcore_block_label[data-name="' + this.name + '"] b')[0]; + + // check for permission + if (this.hasToolboxPermissionForEditable($areaEl.getAttribute('type')) === false) { + $areaEl.addCls('editable-blocked'); } + + if ($editDiv && Ext.get($editDiv).isVisible() === true) { + + //$areaEl.clearListeners(); + + $el = Ext.DomHelper.insertAfter($areaButtonsEl, { + 'tag': 'div', + 'class': 'toolbox-element-edit-button', + 'data-title': $labelDiv.innerHTML + }, true); + + //remove pimcore default button! + Ext.get($editDiv).setVisible(false); + + $editButton = new Ext.Button({ + cls: 'pimcore_block_button_plus', + iconCls: 'pimcore_icon_edit', + text: t('edit'), + handler: this.openEditableDialogBox.bind(this, this.elements[i], $editDiv), + listeners: { + afterrender: function(ev) { + $areaEl.fireEvent('toolbox.bar.added', $areaEl); + } + } + }); + + $editButton.render($el); + + } + + } catch (e) { + console.error(e); } } + } }); diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/columnadjuster.js b/src/ToolboxBundle/Resources/public/js/document/editables/columnadjuster.js index 1ba36392..79e83a7f 100644 --- a/src/ToolboxBundle/Resources/public/js/document/editables/columnadjuster.js +++ b/src/ToolboxBundle/Resources/public/js/document/editables/columnadjuster.js @@ -1,11 +1,11 @@ pimcore.registerNS('pimcore.document.editables.columnadjuster'); -pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.document.editable, { +pimcore.document.editables.columnadjuster = Class.create(pimcore.document.editable, { getType: function () { return 'columnadjuster'; }, - initialize: function (id, name, options, data, inherited) { + initialize: function (id, name, config, data) { this.id = id; this.name = name; @@ -20,7 +20,7 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume this.gridForm = null; this.toolbar = null; this.gridPreview = {}; - this.options = this.parseOptions(options); + this.config = this.parseConfig(config); this.editWindowState = {w: 0, h: 0}; this.combos = {}; @@ -29,10 +29,17 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume this.gridAmount = 0; this.gridSize = 0; + }, + + render: function () { + + var columnSelector, + checkInitState; this.setupWrapper(); - var columnSelector = Ext.get(this.id).up('.t-row').prev('.t-row').query('.pimcore_tag_select'); + columnSelector = Ext.get(this.id).up('.x-fieldset').prev('.x-fieldset').query('.pimcore_editable_select'); + if (columnSelector.length === 0 || !columnSelector[0].firstChild) { return; } @@ -45,11 +52,11 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume //set current column selection this.currentColumnSelection = this.gridSelector.getValue(); this.currentColumnSelectionName = this.gridSelector.getRawValue(); - this.buttonHolder = Ext.get(id); + this.buttonHolder = Ext.get(this.id); this.statusButton = new Ext.form.Checkbox({ fieldLabel: t('enable_column_adjuster'), - checked: this.data !== false, + checked: !Ext.Object.isEmpty(this.data), labelWidth: 170, labelStyle: 'padding-top:0; font-weight: 300;', listeners: { @@ -66,7 +73,7 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume this.gridEditButton = new Ext.Button({ iconCls: 'toolbox_column_adjuster', text: t('edit_column_configuration'), - hidden: this.data === false, + hidden: Ext.Object.isEmpty(this.data), style: 'background-color: white;', listeners: { 'click': function () { @@ -79,9 +86,9 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume } }); - var checkInitState = function () { + checkInitState = function () { //there is only 1 column: we don't need a column adjuster... - if (this.currentColumnSelection.split('_').length === 2) { + if (this.currentColumnSelection === null || this.currentColumnSelection.split('_').length === 2) { this.data = false; this.gridEditButton.setDisabled(true); this.statusButton.setValue(false); @@ -121,16 +128,20 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume expandEditor: function () { + var windowSelector, + editWindow, + cancelButton; + if (this.gridEditorActive === true) { return; } - var windowSelector = Ext.get(this.id).up('.x-window'); + windowSelector = Ext.get(this.id).up('.x-window'); if (windowSelector.length === 0) { return; } - var editWindow = Ext.getCmp(windowSelector.id); + editWindow = Ext.getCmp(windowSelector.id); if (!editWindow) { return; } @@ -143,7 +154,7 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume this.editWindowState.w = editWindow.getWidth(); this.editWindowState.h = editWindow.getHeight(); - var cancelButton = Ext.ComponentQuery.query('button[iconCls=pimcore_icon_cancel]', editWindow); + cancelButton = Ext.ComponentQuery.query('button[iconCls=pimcore_icon_cancel]', editWindow); if (cancelButton.length === 1) { cancelButton[0].setDisabled(true); } @@ -195,10 +206,8 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }, - /** - * @returns {null|Ext.FormPanel} - */ populateGridForm: function () { + var _ = this, currentDocumentId = null, tabPanel = new Ext.TabPanel({ @@ -289,8 +298,8 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume inherited = grid.value === null, realValue = grid.value === null ? _.findInheritedGridValue(breakpointIndex, gridIndex, 'value') : grid.value; - if(_.columnStore) { - Ext.Object.each(_.columnStore, function(k, v) { + if (_.columnStore) { + Ext.Object.each(_.columnStore, function (k, v) { storeData.push([k, v]); }); } else { @@ -324,7 +333,7 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume typeAhead: true, mode: 'local', forceSelection: true, - disabled: isInherited === true, + disabled: breakpointIndex !== 0 && isInherited === true, triggerAction: 'all', labelAlign: 'top', style: 'margin-right:2px;', @@ -357,7 +366,7 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume typeAhead: true, mode: 'local', forceSelection: true, - disabled: isInherited === true, + disabled: breakpointIndex !== 0 && isInherited === true, triggerAction: 'all', labelAlign: 'top', style: 'margin-right:8px;', @@ -464,10 +473,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }, - /** - * @param identifier - * @param triggerEl - */ updateData: function (identifier, triggerEl) { var form = this.gridForm.getForm(), _ = this; @@ -581,9 +586,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }, - /** - * @returns {string} - */ mergeCustomGridValue: function () { if (!this.data.breakpoints) { @@ -613,12 +615,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }.bind(this)); }, - /** - * @param currentBreakpointIndex - * @param gridIndex - * @param returnProperty - * @returns {*} - */ findInheritedGridValue: function (currentBreakpointIndex, gridIndex, returnProperty) { var val = null, @@ -638,10 +634,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }, - /** - * @param identifier - * @returns {*} - */ findBreakPointDataByIdentifier: function (identifier) { var currentBreakpointIndex = null; Ext.Array.each(this.breakPoints, function (breakpoint, breakpointIndex) { @@ -654,11 +646,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume return currentBreakpointIndex; }, - /** - * - * @param gridIndex - * @returns {boolean} - */ gridColumnHasOffset: function (gridIndex) { var hasOffset = false; Ext.Array.each(this.breakPoints, function (breakpoint, breakpointIndex) { @@ -673,11 +660,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume return hasOffset; }, - /** - * - * @param message - * @param startDelayed - */ cancelAdjustment: function (message, startDelayed) { this.statusButton.setValue(false); this.adjustmentFailed = false; @@ -688,9 +670,6 @@ pimcore.document.editables.columnadjuster = Class.create(toolbox.abstract.docume }.bind(this), startDelayed ? startDelayed : 0); }, - /** - * @returns {*|boolean} - */ getValue: function () { return this.data; } diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/dynamiclink.js b/src/ToolboxBundle/Resources/public/js/document/editables/dynamiclink.js deleted file mode 100644 index 856dfe2d..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/editables/dynamiclink.js +++ /dev/null @@ -1,223 +0,0 @@ -pimcore.registerNS('pimcore.document.editables.dynamiclink'); -pimcore.document.editables.dynamiclink = Class.create(toolbox.abstract.document.editables.link, { - - getType: function () { - return 'dynamiclink'; - }, - - openEditor: function () { - - this.window = this.openDynamicLinkEditPanel(this.data, { - empty: this.empty.bind(this), - cancel: this.cancel.bind(this), - save: this.save.bind(this) - }); - - }, - - openDynamicLinkEditPanel : function (data, callback) { - - var fieldPath = new Ext.form.TextField({ - fieldLabel: t('path'), - value: data.path, - name: "path", - width: 520, - fieldCls: "pimcore_droptarget_input", - enableKeyEvents: true, - listeners: { - keyup: function (el) { - if(el.getValue().match(/^www\./)) { - el.setValue("http://" + el.getValue()); - } - } - } - }); - - fieldPath.on("render", function (el) { - - if (typeof dndManager !== 'undefined') { - dndManager.addDropTarget( - el.getEl(), - function(target, dd, e, data) { - return Ext.dd.DropZone.prototype.dropAllowed; - }, - function(target, dd, e, data) { - - var record = data.records[0]; - if (record.data.elementType == "asset" || record.data.elementType == "document" || record.data.elementType == "object") { - if( record.data.elementType == "object") { - fieldPath.setValue(record.data.className + '::' + record.data.path); - } else { - fieldPath.setValue(record.data.path); - } - return true; - } - - return false; - }); - } - - }.bind(this)); - - var form = new Ext.FormPanel({ - itemId: "form", - items: [ - { - xtype:'tabpanel', - deferredRender: false, - defaults:{autoHeight:true, bodyStyle:'padding:10px'}, - border: false, - items: [ - { - title:t('basic'), - layout:'vbox', - border: false, - defaultType: 'textfield', - items: [ - { - fieldLabel: t('text'), - name: 'text', - value: data.text - }, - { - xtype: "fieldcontainer", - layout: 'hbox', - border: false, - items: [fieldPath, { - xtype: "button", - iconCls: "pimcore_icon_search", - style: "margin-left: 5px", - handler: function () { - pimcore.helpers.itemselector(false, function (item) { - if (item) { - if( item.type == 'object') { - fieldPath.setValue(item.classname + "::" + item.fullpath); - } else { - fieldPath.setValue(item.fullpath); - } - - return true; - } - }, { - type: ["asset","document","object"] - }); - } - }] - }, - { - xtype:'fieldset', - layout: 'vbox', - title: t('properties'), - collapsible: false, - defaultType: 'textfield', - width: '100%', - defaults: { - width: 250 - }, - items :[ - { - xtype: "combo", - fieldLabel: t('target'), - name: 'target', - triggerAction: 'all', - editable: true, - mode: "local", - store: ["","_blank","_self","_top","_parent"], - value: data.target, - width: 300 - }, - { - fieldLabel: t('parameters'), - name: 'parameters', - value: data.parameters - }, - { - fieldLabel: t('anchor'), - name: 'anchor', - value: data.anchor - }, - { - fieldLabel: t('title'), - name: 'title', - value: data.title - } - ] - } - ] - }, - { - title: t('advanced'), - layout:'form', - defaultType: 'textfield', - border: false, - items: [ - { - fieldLabel: t('accesskey'), - name: 'accesskey', - value: data.accesskey - }, - { - fieldLabel: t('relation'), - name: 'rel', - width: 300, - value: data.rel - }, - { - fieldLabel: ('tabindex'), - name: 'tabindex', - value: data.tabindex - }, - { - fieldLabel: t('class'), - name: 'class', - width: 300, - value: data["class"] - }, - { - fieldLabel: t('attributes') + ' (key="value")', - name: 'attributes', - width: 300, - value: data["attributes"] - } - ] - } - ] - } - ], - buttons: [ - { - text: t("empty"), - listeners: { - "click": callback["empty"] - } - }, - { - text: t("cancel"), - listeners: { - "click": callback["cancel"] - } - }, - { - text: t("save"), - listeners: { - "click": callback["save"] - }, - iconCls: "pimcore_icon_save" - } - ] - }); - - var window = new Ext.Window({ - modal: false, - width: 600, - height: 470, - title: t("edit_link"), - items: [form], - layout: "fit" - }); - - window.show(); - - return window; - } -}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/googlemap.js b/src/ToolboxBundle/Resources/public/js/document/editables/googlemap.js index c1c7e249..7b6e2207 100644 --- a/src/ToolboxBundle/Resources/public/js/document/editables/googlemap.js +++ b/src/ToolboxBundle/Resources/public/js/document/editables/googlemap.js @@ -1,5 +1,9 @@ pimcore.registerNS('pimcore.document.editables.googlemap'); -pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.editable, { +pimcore.document.editables.googlemap = Class.create(pimcore.document.editable, { + + form: null, + element: null, + previewData: null, getType: function () { return 'googlemap'; @@ -10,12 +14,12 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed }, reload: function () { - if (this.options.reload) { + if (this.config.reload) { this.reloadDocument(); } }, - initialize: function (id, name, options, data) { + initialize: function (id, name, config, data) { if (typeof google === 'undefined') { console.warn('toolbox googleMap: google js api is not reachable.'); @@ -24,28 +28,74 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed this.id = id; this.name = name; - this.data = data; + this.data = data.locations; + this.previewData = data; + this.config = this.parseConfig(config); + }, + + subRender: function () { - this.options = this.parseOptions(options); - this.geocoder = new google.maps.Geocoder(); + var errorCollector = [], mapEditButton; + + if (typeof google === 'undefined') { + return; + } this.setupWrapper(); - Ext.get(id).setStyle({ - display: 'inline' + this.element = Ext.get(this.id); + + mapEditButton = new Ext.Button({ + iconCls: 'pimcore_icon_geopoint', + cls: 'googlemap_edit_locations_button', + text: t('locations'), + listeners: { + 'click': this.openEditor.bind(this) + } }); - var buttonHolder = Ext.get(id).up('.toolbox-google-map').prev('.toolbox-element-edit-button'), - mapEditButton = new Ext.Button({ - iconCls: 'pimcore_icon_geopoint', - cls: 'googlemap_edit_locations_button', - text: t('locations'), - listeners: { - 'click': this.openEditor.bind(this) + mapEditButton.render(this.getButtonHolder()); + + if (this.previewData['hasValidKey'] === false) { + + Ext.DomHelper.append(this.element, { + 'tag': 'div', + 'class': 'tb-alert-info', + 'html': 'No valid API Key defined' + }, true); + + } + + if (this.data && this.data.length > 0) { + Ext.Array.each(this.data, function (location, i) { + if (typeof location.status !== 'undefined' && location.status !== null) { + errorCollector.push('[' + i + ']: ' + location.status) } }); + } - mapEditButton.render(buttonHolder); + if (errorCollector.length > 0) { + this.element.dom.setAttribute('data-fetch-error', errorCollector.join(',')); + } + }, + + render: function () { + + // this is a sub render element (append button to toolbox edit bar). + if (this.hasButtonHolder() === false) { + Ext.get(this.id).up('.pimcore_area_entry').addListener('toolbox.bar.added', this.subRender.bind(this)); + return; + } + + this.subRender(); + }, + + hasButtonHolder: function () { + return this.getButtonHolder() !== null; + }, + + getButtonHolder: function () { + return Ext.get(this.id).up('.toolbox-google-map').prev('.toolbox-element-edit-button'); }, openEditor: function () { @@ -55,10 +105,24 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed }); }, - openGoogleMapEditPanel: function (data, callback) { + openGoogleMapEditPanel: function (locations, callback) { + + var window, addLocation; - data = data || []; - var addLocation = function (ev, buttonEv, location) { + locations = locations || {}; + + window = new Ext.Window({ + modal: true, + autoScroll: true, + width: 900, + height: 500, + title: t('edit_locations'), + layout: 'fit' + }); + + addLocation = function (ev, buttonEv, location) { + + var compositeField; if (typeof location === 'undefined') { location = { @@ -72,133 +136,143 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed } } - var itemRow1 = [{ - xtype: 'textfield', - name: 'location_title', - emptyText: t('location_title'), - anchor: '100%', - summaryDisplay: true, - allowBlank: false, - blankText: t('field_mandatory'), - value: location.title, - flex: 1, - msgTarget: 'qtip' - }]; - - var itemRow2 = [{ - xtype: 'textfield', - name: 'location_street', - fieldLabel: t('location_street'), - labelAlign: 'top', - style: 'margin: 0 5px 0 0', - anchor: '100%', - summaryDisplay: true, - allowBlank: false, - blankText: t('field_mandatory'), - value: location.street, - flex: 1, - msgTarget: 'qtip' - }, - { - xtype: 'textfield', - name: 'location_zip', - fieldLabel: t('location_zip'), - labelAlign: 'top', - style: 'margin: 0 5px 0 0', - anchor: '100%', - summaryDisplay: true, - allowBlank: false, - blankText: t('field_mandatory'), - value: location.zip, - flex: 1, - msgTarget: 'qtip' - }, - { - xtype: 'textfield', - name: 'location_city', - fieldLabel: t('location_city'), - labelAlign: 'top', - style: 'margin: 0 5px 0 0', - anchor: '100%', - summaryDisplay: true, - allowBlank: false, - blankText: t('field_mandatory'), - value: location.city, - flex: 1, - msgTarget: 'qtip' - }, - { - xtype: 'textfield', - name: 'location_country', - fieldLabel: t('location_country'), - labelAlign: 'top', - anchor: '100%', - summaryDisplay: true, - allowBlank: false, - blankText: t('field_mandatory'), - value: location.country, - flex: 1, - msgTarget: 'qtip' - }]; - - var itemRow3 = [{ - xtype: 'checkbox', - name: 'location_hide_info_window', - labelAlign: 'left', - fieldLabel: t('location_hide_info_window'), - value: location.hideInfoWindow, - anchor: '100%', - labelWidth: false, - style: 'width: 190px;', - labelStyle: 'width: 190px;' - }]; - - var itemRow4 = [{ - xtype: 'textarea', - name: 'location_add', - fieldLabel: t('location_add'), - labelAlign: 'top', - anchor: '100%', - summaryDisplay: true, - allowBlank: true, - value: location.add, - flex: 1, - grow: false - }]; - - var compositeField = new Ext.form.FieldContainer({ - //layout: 'anchor', + compositeField = new Ext.form.FormPanel({ hideLabel: true, - style: 'margin-bottom: 15px; padding: 10px; background: rgba(214, 221, 230, 0.45);', + layout: 'form', + style: 'margin-bottom: 15px; padding: 5px; background: rgba(214, 221, 230, 0.45);', items: [ - Ext.form.FieldContainer({ + { + xtype: 'container', layout: 'hbox', hideLabel: true, style: 'padding-bottom:5px;', border: false, - items: itemRow1 - }), - Ext.form.FieldContainer({ + items: [ + { + xtype: 'textfield', + name: 'location_title', + emptyText: t('location_title'), + summaryDisplay: true, + allowBlank: false, + blankText: t('field_mandatory'), + value: location.title, + flex: 1, + msgTarget: 'qtip' + } + ] + }, + { + xtype: 'container', layout: 'hbox', hideLabel: true, style: 'padding-bottom:5px;', border: false, - items: itemRow2 - }), - Ext.form.FieldContainer({ + items: [ + { + xtype: 'textfield', + name: 'location_street', + fieldLabel: t('location_street'), + labelAlign: 'top', + style: 'margin: 0 5px 0 0', + summaryDisplay: true, + allowBlank: false, + blankText: t('field_mandatory'), + value: location.street, + flex: 1, + msgTarget: 'qtip' + }, + { + xtype: 'textfield', + name: 'location_zip', + fieldLabel: t('location_zip'), + labelAlign: 'top', + style: 'margin: 0 5px 0 0', + summaryDisplay: true, + allowBlank: false, + blankText: t('field_mandatory'), + value: location.zip, + flex: 1, + msgTarget: 'qtip' + }, + { + xtype: 'textfield', + name: 'location_city', + fieldLabel: t('location_city'), + labelAlign: 'top', + style: 'margin: 0 5px 0 0', + summaryDisplay: true, + allowBlank: false, + blankText: t('field_mandatory'), + value: location.city, + flex: 1, + msgTarget: 'qtip' + }, + { + xtype: 'textfield', + name: 'location_country', + fieldLabel: t('location_country'), + labelAlign: 'top', + anchor: '100%', + summaryDisplay: true, + allowBlank: false, + blankText: t('field_mandatory'), + value: location.country, + flex: 1, + msgTarget: 'qtip' + }] + }, + { + xtype: 'container', layout: 'hbox', hideLabel: true, style: 'padding-bottom:5px;', border: false, - items: itemRow3 - }), - Ext.form.FieldContainer({ + items: [{ + xtype: 'checkbox', + name: 'location_hide_info_window', + labelAlign: 'left', + fieldLabel: t('location_hide_info_window'), + value: location.hideInfoWindow, + anchor: '100%', + labelWidth: false, + style: 'width: 190px;', + labelStyle: 'width: 190px;' + }] + }, + { + xtype: 'container', layout: 'hbox', hideLabel: true, style: 'padding-bottom:5px;', border: false, - items: itemRow4 - }) + items: [{ + xtype: 'textarea', + name: 'location_add', + fieldLabel: t('location_add'), + labelAlign: 'top', + anchor: '100%', + summaryDisplay: true, + allowBlank: true, + value: location.add, + flex: 1, + grow: false + }] + }, + { + xtype: 'hidden', + name: 'location_checksum', + value: typeof location.checksum !== 'undefined' ? location.checksum : null, + }, + { + xtype: 'hidden', + name: 'location_lat', + value: typeof location.lat !== 'undefined' ? location.lat : null, + }, + { + xtype: 'hidden', + name: 'location_lng', + value: typeof location.lng !== 'undefined' ? location.lng : null, + } ] }); @@ -207,47 +281,29 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed iconCls: 'pimcore_icon_delete', text: t('remove'), handler: function (compositeField, el) { - selector.remove(compositeField); - selector.updateLayout(); + this.form.remove(compositeField); + this.form.updateLayout(); }.bind(this, compositeField) }, { xtype: 'box', style: 'clear:both;' }]); - selector.add(compositeField); - selector.updateLayout(); - - }; - - var selector = new Ext.form.FieldSet({ - title: t('locations'), - collapsible: false, - autoHeight: true, - items: [{ - xtype: 'toolbar', - style: 'margin-bottom:10px;', - items: ['->', { - xtype: 'button', - text: t('location_add_location'), - iconCls: 'pimcore_icon_add', - handler: addLocation - }] - }] - }); + this.form.add(compositeField); + this.form.updateLayout(); - if (data && data.length > 0) { - data.forEach(function (location) { - addLocation(null, null, location); - }); - } + }.bind(this); - var form = new Ext.FormPanel({ + this.form = new Ext.FormPanel({ itemId: 'form', - scrollable: true, - items: [ - selector - ], + scrollable: 'y', + layout: 'form', + tbar: ['->', { + xtype: 'button', + text: t('location_add_location'), + iconCls: 'pimcore_icon_add', + handler: addLocation.bind(this) + }], buttons: [ { text: t('save'), @@ -263,24 +319,27 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed }, iconCls: 'pimcore_icon_cancel' } - ] - }); + ], + listeners: { + afterrender: function () { + if (locations && locations.length > 0) { + locations.forEach(function (location) { + addLocation(null, null, location); + }); + } - var window = new Ext.Window({ - modal: false, - width: 900, - height: 500, - title: t('edit_locations'), - items: [form], - layout: 'fit' + } + } }); document.body.classList.add('toolbox-modal-open'); + + window.add(this.form); + window.show(); return window; - }, cancel: function () { @@ -292,44 +351,55 @@ pimcore.document.editables.googlemap = Class.create(toolbox.abstract.document.ed var form = this.window.getComponent('form').getForm(), locations = [], - location; + location, + values; - if (form.isValid()) { - var values = form.getFieldValues(); - if (typeof values['location_street'] === 'string') { - location = { - title: values['location_title'], - street: values['location_street'], - zip: values['location_zip'], - city: values['location_city'], - country: values['location_country'], - hideInfoWindow: values['location_hide_info_window'], - add: values['location_add'] - }; - locations.push(location); - } else { - if (values.hasOwnProperty('location_title') && values['location_title'].length > 0) { - values['location_title'].forEach(function (value, index) { - location = { - title: value, - street: values['location_street'][index], - zip: values['location_zip'][index], - city: values['location_city'][index], - country: values['location_country'][index], - hideInfoWindow: values['location_hide_info_window'][index], - add: values['location_add'][index] - }; - locations.push(location); - }); - } + if (!form.isValid()) { + return; + } + + values = form.getFieldValues(); + + if (typeof values['location_street'] === 'string') { + location = { + title: values['location_title'], + street: values['location_street'], + zip: values['location_zip'], + city: values['location_city'], + country: values['location_country'], + hideInfoWindow: values['location_hide_info_window'], + add: values['location_add'], + checksum: values['location_checksum'], + lat: values['location_lat'], + lng: values['location_lng'], + }; + locations.push(location); + } else { + if (values.hasOwnProperty('location_title') && values['location_title'].length > 0) { + values['location_title'].forEach(function (value, index) { + location = { + title: value, + street: values['location_street'][index], + zip: values['location_zip'][index], + city: values['location_city'][index], + country: values['location_country'][index], + hideInfoWindow: values['location_hide_info_window'][index], + add: values['location_add'][index], + checksum: values['location_checksum'][index], + lat: values['location_lat'][index], + lng: values['location_lng'][index], + }; + locations.push(location); + }); } + } - this.data = locations; + this.data = locations; - // close window - document.body.classList.remove('toolbox-modal-open'); - this.window.close(); - this.reload(); - } + // close window + document.body.classList.remove('toolbox-modal-open'); + this.window.close(); + + this.reloadDocument(); } }); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/parallaximage.js b/src/ToolboxBundle/Resources/public/js/document/editables/parallaximage.js index 41d3597c..25a2ad1f 100644 --- a/src/ToolboxBundle/Resources/public/js/document/editables/parallaximage.js +++ b/src/ToolboxBundle/Resources/public/js/document/editables/parallaximage.js @@ -1,22 +1,22 @@ pimcore.registerNS('pimcore.document.editables.parallaximage'); -pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.document.editables.relations, { +pimcore.document.editables.parallaximage = Class.create(pimcore.document.editables.relations, { - updateLayout: function() { + modelName: null, + + updateLayout: function () { this.element.render(this.id); }, - initialize: function(id, name, options, data, inherited) { - + initialize: function (id, name, config, data) { this.id = id; this.name = name; - this.options = this.parseOptions(options); + this.config = this.parseConfig(config); this.data = data; - this.setupWrapper(); + this.modelName = 'ParallaxImageRelationsEntry' - var modelName = 'ParallaxImageRelationsEntry'; - if(!Ext.ClassManager.isCreated(modelName) ) { - Ext.define(modelName, { + if (!Ext.ClassManager.isCreated(this.modelName)) { + Ext.define(this.modelName, { extend: 'Ext.data.Model', idProperty: 'rowId', fields: [ @@ -32,30 +32,40 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen this.store = new Ext.data.ArrayStore({ data: this.data, - model: modelName + model: this.modelName }); - var positionStoreElements = []; - Ext.Object.each(this.options.position, function(k,v) { + }, + + render: function () { + + var positionStoreElements = [], + sizeStoreElements = [], + positionStore, + sizeStore, + elementConfig; + + this.setupWrapper(); + + Ext.Object.each(this.config.position, function (k, v) { positionStoreElements.push({id: k, name: v}); }); - var positionStore = Ext.create('Ext.data.Store',{ + positionStore = Ext.create('Ext.data.Store', { fields: ['id', 'name'], data: positionStoreElements }); - var sizeStoreElements = []; - Ext.Object.each(this.options.size, function(k,v) { + Ext.Object.each(this.config.size, function (k, v) { sizeStoreElements.push({id: k, name: v}); }); - var sizeStore = Ext.create('Ext.data.Store',{ + sizeStore = Ext.create('Ext.data.Store', { fields: ['id', 'name'], data: sizeStoreElements }); - var elementConfig = { + elementConfig = { store: this.store, bodyStyle: 'color:#000', selModel: Ext.create('Ext.selection.RowModel', {}), @@ -77,12 +87,12 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen header: t('position'), dataIndex: 'parallaxPosition', flex: 100, - renderer: function(value, metadata, record) { + renderer: function (value, metadata, record) { var val = positionStore.findRecord('id', value); record.set('parallaxPosition', value); - if( val ) { + if (val) { return val.get('name'); } @@ -97,12 +107,12 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen triggerAction: 'all', emptyText: 'Select action', editable: false, - valueField:'id', - displayField:'name', + valueField: 'id', + displayField: 'name', listeners: { - focus: function(obj) { + focus: function (obj) { obj.expand(); - },select:function(obj) { + }, select: function (obj) { obj.blur(); } }, @@ -113,12 +123,12 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen header: t('size') + ' (' + t('template') + ')', dataIndex: 'parallaxSize', flex: 100, - renderer: function(value, metadata, record) { + renderer: function (value, metadata, record) { var val = sizeStore.findRecord('id', value); record.set('parallaxSize', value); - if( val ) { + if (val) { return val.get('name'); } @@ -133,12 +143,12 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen triggerAction: 'all', emptyText: 'Select action', editable: false, - valueField:'id', - displayField:'name', + valueField: 'id', + displayField: 'name', listeners: { - focus: function(obj) { + focus: function (obj) { obj.expand(); - },select:function(obj) { + }, select: function (obj) { obj.blur(); } }, @@ -146,13 +156,13 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen } }, { - xtype:'actioncolumn', - width:30, - items:[ + xtype: 'actioncolumn', + width: 30, + items: [ { - tooltip:t('up'), - icon:'/bundles/toolbox/images/admin/up.svg', - handler:function (grid, rowIndex) { + tooltip: t('up'), + icon: '/bundles/toolbox/images/admin/up.svg', + handler: function (grid, rowIndex) { if (rowIndex > 0) { var rec = grid.getStore().getAt(rowIndex); grid.getStore().removeAt(rowIndex); @@ -163,13 +173,13 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen ] }, { - xtype:'actioncolumn', - width:30, - items:[ + xtype: 'actioncolumn', + width: 30, + items: [ { - tooltip:t('down'), - icon:'/bundles/toolbox/images/admin/down.svg', - handler:function (grid, rowIndex) { + tooltip: t('down'), + icon: '/bundles/toolbox/images/admin/down.svg', + handler: function (grid, rowIndex) { if (rowIndex < (grid.getStore().getCount() - 1)) { var rec = grid.getStore().getAt(rowIndex); grid.getStore().removeAt(rowIndex); @@ -212,15 +222,15 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen }; // height specifics - if(typeof this.options.height !== 'undefined') { - elementConfig.height = this.options.height; + if (typeof this.config.height !== 'undefined') { + elementConfig.height = this.config.height; } else { elementConfig.autoHeight = true; } // width specifics - if(typeof this.options.width !== 'undefined') { - elementConfig.width = this.options.width; + if (typeof this.config.width !== 'undefined') { + elementConfig.width = this.config.width; } this.element = new Ext.grid.GridPanel(elementConfig); @@ -231,13 +241,15 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen this.onNodeDrop.bind(this)); }.bind(this)); + + this.element.render(this.id); }, onNodeDrop: function (target, dd, e, data) { var record = data.records[0]; - if(!this.dndAllowed(this.getCustomPimcoreDropData(record))){ + if (!this.dndAllowed(this.getCustomPimcoreDropData(record))) { return false; } @@ -252,8 +264,7 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen if (initData.type === 'object') { if (data.className) { initData.subtype = data.className; - } - else { + } else { initData.subtype = 'folder'; } } @@ -271,11 +282,9 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen } return false; - }, - - onRowContextmenu: function (grid, record, tr, rowIndex, e, eOpts ) { + onRowContextmenu: function (grid, record, tr, rowIndex, e, eOpts) { var menu = new Ext.menu.Menu(); @@ -293,7 +302,7 @@ pimcore.document.editables.parallaximage = Class.create(toolbox.abstract.documen item.parentMenu.destroy(); var subtype = record.data.subtype; - if (record.data.type === 'object' && record.data.subtype != 'folder') { + if (record.data.type === 'object' && record.data.subtype !== 'folder') { subtype = 'object'; } pimcore.helpers.openElement(record.data.id, record.data.type, subtype); diff --git a/src/ToolboxBundle/Resources/public/js/document/editables/vhs.js b/src/ToolboxBundle/Resources/public/js/document/editables/vhs.js index 77ff8c42..97d25575 100644 --- a/src/ToolboxBundle/Resources/public/js/document/editables/vhs.js +++ b/src/ToolboxBundle/Resources/public/js/document/editables/vhs.js @@ -1,34 +1,64 @@ pimcore.registerNS('pimcore.document.editables.vhs'); -pimcore.document.editables.vhs = Class.create(toolbox.abstract.document.editables.video, { - - initialize: function(id, name, options, data) { +pimcore.document.editables.vhs = Class.create(pimcore.document.editables.video, { + initialize: function (id, name, config, data) { this.id = id; this.name = name; this.videoEditor = {}; - this.options = this.parseOptions(options); + this.config = this.parseConfig(config); this.data = data; + }, + + subRender: function () { + + var element, emptyContainer, videoEditButton; this.setupWrapper(); - var element = Ext.get('pimcore_video_' + name), - emptyContainer = element.query('.pimcore_tag_video_empty')[0], - buttonHolder = Ext.get(id).up('.toolbox-video').prev('.toolbox-element-edit-button'), - videoEditbutton = new Ext.Button({ + this.element = Ext.get(this.id); + + element = Ext.get('pimcore_video_' + this.name); + emptyContainer = element.query('.pimcore_editable_video_empty')[0]; + videoEditButton = new Ext.Button({ iconCls: 'pimcore_icon_video', cls: 'pimcore_edit_link_button', text: t('settings'), listeners: { - click : this.openEditor.bind(this) + click: this.openEditor.bind(this) } }); - videoEditbutton.render(buttonHolder); + videoEditButton.render(this.getButtonHolder()); - if(emptyContainer) { + if (this.inherited) { + button.hide(); + } + + if (emptyContainer) { emptyContainer = Ext.get(emptyContainer); emptyContainer.on('click', this.openEditor.bind(this)); } + + }, + + render: function () { + + // this is a sub render element (append button to toolbox edit bar). + if (this.hasButtonHolder() === false) { + Ext.get(this.id).up('.pimcore_area_entry').addListener('toolbox.bar.added', this.subRender.bind(this)); + return; + } + + this.subRender(); + + }, + + hasButtonHolder: function () { + return this.getButtonHolder() !== null; + }, + + getButtonHolder: function () { + return Ext.get(this.id).up('.toolbox-video').prev('.toolbox-element-edit-button'); }, openEditor: function () { diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/_route.js b/src/ToolboxBundle/Resources/public/js/document/tags/_route.js deleted file mode 100644 index 3c042cb1..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/_route.js +++ /dev/null @@ -1,10 +0,0 @@ -// deprecated. remove with toolbox 4.0 -pimcore.registerNS('toolbox.abstract.document.editable'); -pimcore.registerNS('toolbox.abstract.document.editables.link'); -pimcore.registerNS('toolbox.abstract.document.editables.relations'); -pimcore.registerNS('toolbox.abstract.document.editables.video'); - -toolbox.abstract.document.editable = Class.create(pimcore.document.tag, {}); -toolbox.abstract.document.editables.link = Class.create(pimcore.document.tags.link, {}); -toolbox.abstract.document.editables.relations = Class.create(pimcore.document.tags.relations, {}); -toolbox.abstract.document.editables.video = Class.create(pimcore.document.tags.video, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/areablock.js b/src/ToolboxBundle/Resources/public/js/document/tags/areablock.js deleted file mode 100644 index 542b30d9..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/areablock.js +++ /dev/null @@ -1,49 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.areablock'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.areablock = Class.create(pimcore.document.tags.areablock, { - - initialize: function ($super, id, name, options, data, inherited) { - - var i, $areaEl, $el, $editButton, $editDiv; - - $super(id, name, options, data, inherited); - - if (this.elements.length > 0) { - - for (i = 0; i < this.elements.length; i++) { - - try { - - $areaEl = Ext.get(this.elements[i]); - $editDiv = $areaEl.query('.pimcore_area_edit_button[data-name="' + this.name + '"]')[0]; - - $areaEl.clearListeners(); - - if ($editDiv) { - - $el = Ext.DomHelper.insertAfter($editDiv, { - 'tag': 'div', - 'class': 'toolbox-element-edit-button' - }, true); - - //remove pimcore default button! - Ext.get($editDiv).destroy(); - - $editButton = new Ext.Button({ - cls: 'pimcore_block_button_plus', - iconCls: 'pimcore_icon_edit', - text: t('edit'), - handler: this.editmodeOpen.bind(this, this.elements[i]) - }); - - $editButton.render($el); - - } - - } catch (e) { - console.log(e); - } - } - } - } -}); diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/columnadjuster.js b/src/ToolboxBundle/Resources/public/js/document/tags/columnadjuster.js deleted file mode 100644 index 768ce927..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/columnadjuster.js +++ /dev/null @@ -1,3 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.columnadjuster'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.columnadjuster = Class.create(pimcore.document.editables.columnadjuster, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/dynamiclink.js b/src/ToolboxBundle/Resources/public/js/document/tags/dynamiclink.js deleted file mode 100644 index acf0346f..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/dynamiclink.js +++ /dev/null @@ -1,3 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.dynamiclink'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.dynamiclink = Class.create(pimcore.document.editables.dynamiclink, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/googlemap.js b/src/ToolboxBundle/Resources/public/js/document/tags/googlemap.js deleted file mode 100644 index c7561dbc..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/googlemap.js +++ /dev/null @@ -1,3 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.googlemap'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.googlemap = Class.create(pimcore.document.editables.googlemap, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/parallaximage.js b/src/ToolboxBundle/Resources/public/js/document/tags/parallaximage.js deleted file mode 100644 index 4a714c95..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/parallaximage.js +++ /dev/null @@ -1,3 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.parallaximage'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.parallaximage = Class.create(pimcore.document.editables.parallaximage, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/document/tags/vhs.js b/src/ToolboxBundle/Resources/public/js/document/tags/vhs.js deleted file mode 100644 index ab74317a..00000000 --- a/src/ToolboxBundle/Resources/public/js/document/tags/vhs.js +++ /dev/null @@ -1,3 +0,0 @@ -pimcore.registerNS('pimcore.document.tags.vhs'); -// deprecated. remove with toolbox 4.0 -pimcore.document.tags.vhs = Class.create(pimcore.document.editables.vhs, {}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-googleMaps.js b/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-googleMaps.js deleted file mode 100644 index 448acef8..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-googleMaps.js +++ /dev/null @@ -1,146 +0,0 @@ -/* - __ __ ___ _ __ __ - ____/ /___ ______/ /_ _________ ____ ___ ____/ (_)___ _(_) /_____ _/ / - / __ / __ `/ ___/ __ \/ ___/ __ \/ __ `__ \ / __ / / __ `/ / __/ __ `/ / - / /_/ / /_/ / /__/ / / / /__/ /_/ / / / / / / / /_/ / / /_/ / / /_/ /_/ / / - \__,_/\__,_/\___/_/ /_/\___/\____/_/ /_/ /_/ \__,_/_/\__, /_/\__/\__,_/_/ - /____/ - copyright © dachcom digital - - */ -var DachcomToolboxGoogleMaps = (function () { - 'use strict'; - var self = { - - $doc: $ !== undefined ? $(document) : null, - isBusy : false, - editMode : false, - - init: function() { - self.editMode = typeof _PIMCORE_EDITMODE !== 'undefined' && _PIMCORE_EDITMODE === true; - self.startSystem(); - }, - - startSystem: function() { - this.setupGoogleMaps(); - }, - - setupGoogleMaps: function() { - - var $maps = $('.toolbox-googlemap'), - - //internal callback 1 - isValidLocation = function(location) { - return location.hasOwnProperty('lat') && location.hasOwnProperty('lng') && !isNaN(location.lat) && !isNaN(location.lng); - }, - - //internal callback 2 - addMarker = function(map, location, markerIcon, showInfoWindowOnLoad) { - - var marker, infoWindow; - - if ( isValidLocation(location) ) { - - marker = new google.maps.Marker({ - position: {lat: location.lat, lng: location.lng}, - map: map, - title: location.title, - icon: markerIcon, - contentLoaded: false - }); - - if(location.hideInfoWindow !== true) { - - infoWindow = new google.maps.InfoWindow({ - content: '
' - }); - - marker.addListener('click', function() { - infoWindow.open(map, marker); - if(marker.contentLoaded === false) { - $.ajax({ - url: '/toolbox/ajax/gm-info-window', - method: 'POST', - data: { - mapParams : location, - language: $('html').attr('lang') - }, - complete: function(result) { - marker.contentLoaded = true; - infoWindow.setContent(result.responseText); - map.setCenter(marker.getPosition()); - } - }); - } - }); - - if(showInfoWindowOnLoad === true) { - google.maps.event.trigger(marker, 'click'); - } - } - } - }; - - $maps.each(function() { - - var $map = $(this), - map, latLngBounds, listener, - locations = $map.data('locations') || [], - mapStyleUrl = $map.data('mapstyleurl'), - markerIcon = $map.data('markericon'), - showInfoWindowOnLoad = $map.data('show-info-window-on-load') === 1, - mapOptions = { - center: new google.maps.LatLng (0, 0) - }; - - $.each($map.data(), function(name, value) { - if ( name.substring(0,9) === 'mapoption' ) { - name = name.replace('mapoption', ''); - name = name.charAt(0).toLowerCase() + name.slice(1); - mapOptions[name] = value; - } - }); - - map = new google.maps.Map($map.get(0), mapOptions); - latLngBounds = new google.maps.LatLngBounds(); - - if ( typeof mapStyleUrl === 'string' ) { - $.getJSON(mapStyleUrl).done(function(data) { - map.set('styles', data); - }); - } - - if ( locations.length > 0 ) { - $.each(locations, function(i, location) { - if ( isValidLocation(location) ) { - latLngBounds.extend( new google.maps.LatLng(location.lat, location.lng) ); - addMarker(map, location, markerIcon, showInfoWindowOnLoad); - } - }); - - map.fitBounds( latLngBounds ); - - listener = google.maps.event.addListener(map, 'idle', function() { - var zoom = (typeof mapOptions.zoom === 'number' && (mapOptions.zoom % 1) === 0) ? mapOptions.zoom : 17; - map.setZoom(zoom); - google.maps.event.removeListener(listener); - }); - } - //store map as data attribute - $map.data('toolbox-google-map', map); - }); - } - }; - - return { - init: self.init - }; - -})(); - -if( $ !== undefined) { - $(function() { - 'use strict'; - DachcomToolboxGoogleMaps.init(); - }); -} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-main.js b/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-main.js deleted file mode 100644 index 2ec7b324..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-main.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - __ __ ___ _ __ __ - ____/ /___ ______/ /_ _________ ____ ___ ____/ (_)___ _(_) /_____ _/ / - / __ / __ `/ ___/ __ \/ ___/ __ \/ __ `__ \ / __ / / __ `/ / __/ __ `/ / - / /_/ / /_/ / /__/ / / / /__/ /_/ / / / / / / / /_/ / / /_/ / / /_/ /_/ / / - \__,_/\__,_/\___/_/ /_/\___/\____/_/ /_/ /_/ \__,_/_/\__, /_/\__/\__,_/_/ - /____/ - copyright © dachcom digital - - */ -var DachcomToolbox = (function () { - - 'use strict'; - - var self = { - - $doc: $ !== undefined ? $(document) : null, - - isBusy : false, - - editMode : false, - - init: function() { - - self.editMode = typeof _PIMCORE_EDITMODE !== 'undefined' && _PIMCORE_EDITMODE === true; - } - - }; - - return { - init: self.init - }; - -})(); - -if( $ !== undefined) { - - $(function() { - 'use strict'; - DachcomToolbox.init(); - }); - -} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-video.js b/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-video.js deleted file mode 100644 index 5cd00ac1..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/legacy/toolbox-video.js +++ /dev/null @@ -1,397 +0,0 @@ -/* - __ __ ___ _ __ __ - ____/ /___ ______/ /_ _________ ____ ___ ____/ (_)___ _(_) /_____ _/ / - / __ / __ `/ ___/ __ \/ ___/ __ \/ __ `__ \ / __ / / __ `/ / __/ __ `/ / - / /_/ / /_/ / /__/ / / / /__/ /_/ / / / / / / / /_/ / / /_/ / / /_/ /_/ / / - \__,_/\__,_/\___/_/ /_/\___/\____/_/ /_/ /_/ \__,_/_/\__, /_/\__/\__,_/_/ - /____/ - copyright © dachcom digital - - */ -var DachcomToolboxVideo = (function () { - - 'use strict'; - - var self = { - - $doc: $ !== undefined ? $(document) : null, - - isBusy : false, - - editMode : false, - - video: {}, - - videoElements: 0, - - videoInitialized: 0, - - init: function() { - - self.editMode = typeof _PIMCORE_EDITMODE !== 'undefined' && _PIMCORE_EDITMODE === true; - - self.startSystem(); - - }, - - startSystem: function() { - - this.setupVideoElements(); - $(window).on('scroll.toolbox', this.onScroll.bind(this)); - - }, - - setupVideoElements: function() { - - var _self = this; - - this.video.autoplayVideos = []; - - if( this.editMode) { - return false; - } - - this.video.youtubeVideos = $('.toolbox-video[data-type="youtube"]'); - this.video.vimeoVideos = $('.toolbox-video[data-type="vimeo"]'); - - $('.toolbox-video.autoplay[data-type="asset"]').each(function() { - - _self.video.autoplayVideos.push({ - type: 'asset', - container: $(this), - player: $(this).find('video').get(0) - }); - - }); - - if ( this.video.youtubeVideos.length > 0 ) { - - this.videoElements += this.video.youtubeVideos.length; - - var tag = document.createElement('script'); - tag.src = 'https://www.youtube.com/iframe_api'; - - var firstScriptTag = document.getElementsByTagName('script')[0]; - firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); - - var YTdeferred = $.Deferred(); - window.onYouTubeIframeAPIReady = function() { - YTdeferred.resolve(); - }; - - YTdeferred.done(function() { - - _self.video.youtubeVideos.each(function() { - - var $container = $(this), - $player = $container.find('.player'), - videoId = _self._getVideoId($player.data('video-uri'), 'youtube'), - playInLightBox = $player.data('play-in-lightbox'), - posterPath = $player.data('poster-path'); - - if( playInLightBox && posterPath !== '' ) { - - _self._checkVideoState(true); - $container.on('click', function(ev) { - ev.preventDefault(); - $container.trigger('toolbox.video.youtube.lightbox', [{'videoId' : videoId, 'posterPath' : posterPath, 'YT' : window.YT}]); - }); - - } else { - - var initPlayer = function(el, autostart) { - - var player = new window.YT.Player(el, { - videoId: videoId, - events: { - 'onReady': function() { - - $container.addClass('player-ready'); - - if( autostart === true ) { - _self._playVideo( player, 'youtube'); - } - } - } - - }); - - $container.addClass('player-ready'); - if ( $container.hasClass('autoplay') ) { - - _self.video.autoplayVideos.push({ - type: 'youtube', - container: $container, - player: player - }); - } - - _self._checkVideoState( autostart !== true ); - - }; - - if( posterPath === '' ) { - - initPlayer($player.get(0)); - - } else { - - _self._checkVideoState(true); - - $container.one('click', function(ev) { - ev.preventDefault(); - initPlayer($player.get(0), true); - $container.find('.poster-overlay').remove(); - }); - } - } - }); - }); - } - - if ( this.video.vimeoVideos.length > 0 ) { - - this.videoElements += this.video.vimeoVideos.length; - - this.video.vimeoVideos.each(function() { - - var $container = $(this), - $player = $container.find('.player'), - videoId = _self._getVideoId($player.data('video-uri'), 'vimeo'), - playInLightBox = $player.data('play-in-lightbox'), - posterPath = $player.data('poster-path'); - - if( playInLightBox && posterPath !== '' ) { - - _self._checkVideoState(true); - - $container.on('click', function(ev) { - ev.preventDefault(); - $container.trigger('toolbox.video.vimeo.lightbox', [{'videoId' : videoId, 'posterPath' : posterPath, 'Vimeo' : Vimeo.Player}]); - }); - - } else { - - var initPlayer = function(el, autostart) { - - var player = new Vimeo.Player(el, { - id: videoId - }); - - player.on('loaded', function() { - - if( autostart === true ) { - _self._playVideo( player, 'vimeo'); - } - - }); - - $container.addClass('player-ready'); - if ( $container.hasClass('autoplay') ) { - - _self.video.autoplayVideos.push({ - type: 'vimeo', - container: $container, - player: player - }); - } - - _self._checkVideoState( autostart !== true ); - - }; - - if( posterPath === '') { - - initPlayer($player.get(0)); - - } else { - - _self._checkVideoState(true); - - $container.one('click', function(ev) { - ev.preventDefault(); - initPlayer($player.get(0), true); - $container.find('.poster-overlay').remove(); - }); - } - } - }); - } - - // special treatment for videos inside accordion (bootstrap collapse) - $.each(this.video.autoplayVideos, function(i, videoObj) { - - var $el = videoObj.container; - - if ( $el.parents('.panel-collapse').length > 0 ) { - - $el.parents('.panel-group').on('shown.bs.collapse', function () { - _self._playVideo( videoObj.player, videoObj.type ); - }); - - $el.parents('.panel-group').on('hide.bs.collapse', function () { - _self._pauseVideo( videoObj.player, videoObj.type ); - }); - } - - }); - }, - - _checkVideoAutoPlay: function() { - - var _self = this, - tolerancePixel = 40, - scrollTop = $(window).scrollTop() + tolerancePixel, - scrollBottom = $(window).scrollTop() + $(window).height() - tolerancePixel; - - $.each(this.video.autoplayVideos, function(i, videoObj) { - - var yTopMedia = videoObj.container.offset().top, - yBottomMedia = videoObj.container.height() + yTopMedia; - - if(scrollTop < yBottomMedia && scrollBottom > yTopMedia) { - _self._playVideo( videoObj.player, videoObj.type ); - } else { - _self._pauseVideo( videoObj.player, videoObj.type ); - } - - }); - - }, - - _playVideo: function(player, type) { - - if ( type === 'asset' ) { - - if ( player.paused ) player.play(); - - } else if ( type === 'youtube' ) { - - if(typeof player.getPlayerState === 'function') { - if ( player.getPlayerState() !== window.YT.PlayerState.PLAYING ) { - player.playVideo(); - } - } - - } else if ( type === 'vimeo' ) { - - if(typeof player.getPaused === 'function') { - player.getPaused().then(function(paused) { - if (paused) { - player.play(); - } - }).catch(function(error) { /* fail silently */ }); - } - } - - }, - - _pauseVideo: function(player, type) { - - if( type === 'asset' ) { - - if( !player.paused ) player.pause(); - - } else if( type === 'youtube' ) { - - if(typeof player.getPlayerState === 'function') { - if( player.getPlayerState() === window.YT.PlayerState.PLAYING ) { - player.pauseVideo(); - } - } - - } else if( type === 'vimeo' ) { - - if(typeof player.getPaused === 'function') { - player.getPaused().then(function(paused) { - if( !paused ) player.pause(); - }).catch(function(error) { /* fail silently */ }); - } - } - }, - - _getVideoId: function(url, type) { - - var regExp, match; - - url = url.toString(); - - if( type === 'youtube' ) { - - if( !url.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/) ) { - return url; - } else { - regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\??v?=?))([^#\&\?]*).*/; - match = url.match(regExp); - - if ( match && match[7] ) { - return match[7]; - } else { - console.log('Unable to parse video id from url: ' + url); - } - } - - } else if( type === 'vimeo' ) { - - if( !url.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/) ) { - return url; - } else { - regExp = /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/; - match = url.match(regExp); - - if (match && match[3]) { - return match[3]; - } else { - console.log('Unable to parse video id from url: ' + url); - } - - } - - } - - }, - - _checkVideoState: function( increase ) { - - if( increase === true) { - this.videoInitialized++; - } - - if( this.videoElements === this.videoInitialized ) { - this._onAllVideosLoaded(); - } - }, - - _onAllVideosLoaded: function() { - - this._checkVideoAutoPlay(); - }, - - onScroll: function(ev) { - - if( typeof Modernizr !== 'undefined' && Modernizr.touchevents ) { - return; - } - - if ( this.video.autoplayVideos.length > 0 ) { - this._checkVideoAutoPlay(); - } - - } - - }; - - return { - init: self.init - }; - -})(); - -if( $ !== undefined) { - - $(function() { - 'use strict'; - DachcomToolboxVideo.init(); - }); - -} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.core.js b/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.core.js deleted file mode 100644 index aeead75e..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.core.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Project: PIMCORE Toolbox - * Extension: Core - * Version: 2.3 - * Author: DACHCOM.DIGITAL - * License: GPL-3.0-or-later -*/ -;(function ($) { - 'use strict'; - $.extend({ - toolboxCore: function (options) { - var defaults = { - editmode: false, - theme: 'bootstrap3', - googleMapsHandler: { - enabled: true, - selector: '.toolbox-googlemap', - config: {} - }, - videoHandler: { - enabled: true, - selector: '.toolbox-video', - config: {} - }, - iframeHandler: { - enabled: true, - selector: '.toolbox-iframe', - config: {} - }, - gOptOutLinkHandler: { - enabled: true, - selector: 'a.google-opt-out-link', - config: {} - } - }, - _ = this, - options = options || {}; - - _.init = function () { - this.settings = $.extend(true, defaults, options); - $.data(document, 'toolboxCore', this.settings); - this.initSystem(); - }; - - _.initSystem = function () { - if (this.settings.googleMapsHandler.enabled === true) { - var settings = this.settings.googleMapsHandler.config; - settings.editmode = this.settings.editmode; - settings.theme = this.settings.theme; - $(this.settings.googleMapsHandler.selector).toolboxGoogleMaps(settings); - } - - if (this.settings.videoHandler.enabled === true) { - var settings = this.settings.videoHandler.config; - settings.editmode = this.settings.editmode; - settings.theme = this.settings.theme; - $(this.settings.videoHandler.selector).toolboxVideo(settings); - } - - if (this.settings.iframeHandler.enabled === true) { - var settings = this.settings.iframeHandler.config; - settings.editmode = this.settings.editmode; - $(this.settings.iframeHandler.selector).toolboxIframe(settings); - } - - if (this.settings.gOptOutLinkHandler.enabled === true) { - var settings = this.settings.gOptOutLinkHandler.config; - settings.editmode = this.settings.editmode; - $(this.settings.gOptOutLinkHandler.selector).toolboxGoogleOptOutLink(settings); - } - }; - - _.init(); - } - }); - - $.toolboxCore.init = function (callback) { - callback(); - } - -})(jQuery); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.google-maps.js b/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.google-maps.js deleted file mode 100644 index accdf75c..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.google-maps.js +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Project: PIMCORE Toolbox - * Extension: Google Maps - * Version: 2.3 - * Author: DACHCOM.DIGITAL - * License: GPL-3.0-or-later -*/ -;(function ($, window, document) { - 'use strict'; - var clName = 'ToolboxGoogleMaps'; - - function ToolboxGoogleMaps(map, options) { - this.$map = $(map); - this.options = $.extend(true, $.fn.toolboxGoogleMaps.defaults, options); - this.init(); - } - - $.extend(ToolboxGoogleMaps.prototype, { - - editMode: false, - mapInstance: null, - - init: function () { - this.editMode = this.options.editmode; - this.setupGoogleMaps(); - }, - - setupGoogleMaps: function () { - - var _ = this, - $map = this.$map, - latLngBounds, - listener, - locations = $map.data('locations') || [], - mapStyleUrl = $map.data('mapstyleurl'), - markerIcon = $map.data('markericon'), - showInfoWindowOnLoad = $map.data('show-info-window-on-load') === 1, - mapOptions = { - center: new google.maps.LatLng(0, 0) - }; - - $.each($map.data(), function (name, value) { - if (name.substring(0, 9) === 'mapoption') { - name = name.replace('mapoption', ''); - name = name.charAt(0).toLowerCase() + name.slice(1); - mapOptions[name] = value; - } - }); - - this.mapInstance = new google.maps.Map($map.get(0), mapOptions); - latLngBounds = new google.maps.LatLngBounds(); - - if (typeof mapStyleUrl === 'string') { - $.getJSON(mapStyleUrl).done(function (data) { - _.mapInstance.set('styles', data); - }); - } - - if (locations.length > 0) { - $.each(locations, function (i, location) { - if (_.isValidLocation(location)) { - latLngBounds.extend(new google.maps.LatLng(location.lat, location.lng)); - _.addMarker(location, markerIcon, showInfoWindowOnLoad); - } - }); - - this.mapInstance.fitBounds(latLngBounds); - - listener = google.maps.event.addListener(this.mapInstance, 'idle', function () { - var zoom = (typeof mapOptions.zoom === 'number' && (mapOptions.zoom % 1) === 0) ? mapOptions.zoom : 17; - _.mapInstance.setZoom(zoom); - google.maps.event.removeListener(listener); - }); - } - - //store map as data attribute - $map.data('toolbox-google-map', this.mapInstance); - - this.checkElementEnvironment(); - - if (this.options.centerMapOnResize === true) { - $(window).on('resize.toolbox.googleMap', this.checkResizeContext.bind(this)); - } - }, - - isValidLocation: function (location) { - return location.hasOwnProperty('lat') - && location.hasOwnProperty('lng') - && !isNaN(location.lat) - && !isNaN(location.lng); - }, - - addMarker: function (location, markerIcon, showInfoWindowOnLoad) { - var _ = this, marker, infoWindow; - - if (!this.isValidLocation(location)) { - return; - } - - marker = new google.maps.Marker({ - position: {lat: location.lat, lng: location.lng}, - map: this.mapInstance, - title: location.title, - icon: markerIcon, - contentLoaded: false - }); - - if (location.hideInfoWindow !== true) { - - infoWindow = new google.maps.InfoWindow({ - content: '
' - }); - - marker.addListener('click', function () { - infoWindow.open(this.mapInstance, marker); - if (marker.contentLoaded === false) { - $.ajax({ - url: '/toolbox/ajax/gm-info-window', - method: 'POST', - data: { - mapParams: location, - language: $('html').attr('lang') - }, - complete: function (result) { - marker.contentLoaded = true; - infoWindow.setContent(result.responseText); - _.mapInstance.setCenter(marker.getPosition()); - } - }); - } - }); - - if (showInfoWindowOnLoad === true) { - google.maps.event.trigger(marker, 'click'); - } - } - }, - - checkElementEnvironment: function () { - - var _ = this; - - // special treatment for a re-init map inside accordion and tabs - if (this.options.theme === 'bootstrap3' || this.options.theme === 'bootstrap4') { - $(document).on('shown.bs.collapse', function (ev) { - var $target = $(ev.target); - if ($target && $.contains($target[0], _.$map[0])) { - var x = _.mapInstance.getZoom(), - c = _.mapInstance.getCenter(); - google.maps.event.trigger(_.mapInstance, 'resize'); - _.mapInstance.setZoom(x); - _.mapInstance.setCenter(c); - } - }).on('shown.bs.tab shown-tabs.bs.tab-collapse', function (ev) { - var $target = $($(ev.target).attr('href')); - if ($target && $.contains($target[0], _.$map[0])) { - var x = _.mapInstance.getZoom(), - c = _.mapInstance.getCenter(); - google.maps.event.trigger(_.mapInstance, 'resize'); - _.mapInstance.setZoom(x); - _.mapInstance.setCenter(c); - } - }); - } - }, - - checkResizeContext: function (ev) { - var x = this.mapInstance.getZoom(), - c = this.mapInstance.getCenter(); - google.maps.event.trigger(this.mapInstance, 'resize'); - this.mapInstance.setZoom(x); - this.mapInstance.setCenter(c); - } - - }); - - $.fn.toolboxGoogleMaps = function (options) { - this.each(function () { - if (!$.data(this, 'tb-ext-google-maps-' + clName)) { - $.data(this, 'tb-ext-google-maps-' + clName, new ToolboxGoogleMaps(this, options)); - } - }); - return this; - }; - - $.fn.toolboxGoogleMaps.defaults = { - editmode: false, - centerMapOnResize: true, - theme: 'bootstrap4' - }; - -})(jQuery, window, document); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.googleOptOutLink.js b/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.googleOptOutLink.js deleted file mode 100644 index 4a8f49f5..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.googleOptOutLink.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Project: PIMCORE Toolbox - * Extension: Google Analytics Opt Out Link - * Version: 2.4 - * Author: DACHCOM.DIGITAL - * License: GPL-3.0-or-later -*/ -;(function ($, window, document) { - 'use strict'; - var clName = 'ToolboxGoogleOptOutLink'; - - function ToolboxGoogleOptOutLink(element, options) { - this.$element = $(element); - this.options = $.extend(true, $.fn.toolboxVideo.defaults, options); - this.translations = window['toolboxJsFrontend'] ? window['toolboxJsFrontend']['translations'] : {}; - this.init(); - } - - $.extend(ToolboxGoogleOptOutLink.prototype, { - - editMode: false, - - init: function () { - - var _ = this; - this.editMode = this.options.editmode; - - if (this.editMode == true) { - return; - } - - if (_.readCookie('tb-google-opt-out-link') !== null) { - _.$element.addClass('disabled'); - } - - _.$element.on('click', function (ev) { - ev.preventDefault(); - if (_.readCookie('tb-google-opt-out-link') !== null) { - _.notify(_.translations['toolbox.goptout_already_opt_out']); - } else { - _.createCookie('tb-google-opt-out-link', $(this).attr('name'), 999); - _.notify(_.translations['toolbox.goptout_successfully_opt_out']); - $(this).addClass('disabled'); - } - }); - }, - - notify: function (message) { - if (typeof this.options.notify === 'function') { - this.options.notify.call(undefined, message); - } else { - alert(message); - } - }, - - readCookie: function (name) { - var nameEQ = name + '='; - var ca = document.cookie.split(';'); - for (var i = 0; i < ca.length; i++) { - var c = ca[i]; - while (c.charAt(0) == ' ') c = c.substring(1, c.length); - if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); - } - return null; - }, - - createCookie: function (name, value, days) { - if (days) { - var date = new Date(); - date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); - var expires = '; expires=' + date.toGMTString(); - } - else var expires = ''; - document.cookie = name + '=' + value + expires + '; path=/'; - } - }); - - $.fn.toolboxGoogleOptOutLink = function (options) { - var els = []; - this.each(function (i) { - if (!$.data(this, 'tb-ext-google-opt-out-link')) { - $.data(this, 'tb-ext-google-opt-out-link', new ToolboxGoogleOptOutLink(this, options)); - } - }); - - return this; - }; - - $.fn.toolboxGoogleOptOutLink.defaults = { - editmode: false, - notify: null - }; - -}) -(jQuery, window, document); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.iframe.js b/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.iframe.js deleted file mode 100644 index 07590436..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.iframe.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Project: PIMCORE Toolbox - * Extension: Iframe - * Version: 2.3 - * Author: DACHCOM.DIGITAL - * License: GPL-3.0-or-later -*/ -;(function ($, window, document) { - 'use strict'; - var clName = 'ToolboxIframe'; - - function ToolboxIframe(element, options) { - this.$element = $(element); - this.$iframe = this.$element.find('iframe').first(); - this.options = $.extend(true, $.fn.toolboxVideo.defaults, options); - this.init(); - } - - $.extend(ToolboxIframe.prototype, { - - editMode: false, - isReady: false, - - init: function () { - - var tbElement = null; - this.editMode = this.options.editmode; - - if (this.$iframe.length === 0) { - this.$element.addClass('iframe-invalid'); - return; - } - - tbElement = this.$iframe.closest('.toolbox-iframe'); - tbElement.trigger('toolbox.iframe.load'); - - this.$iframe.on('load', function () { - tbElement.addClass('iframe-loaded'); - tbElement.trigger('toolbox.iframe.loaded'); - }.bind(this)); - } - }); - - $.fn.toolboxIframe = function (options) { - var els = []; - this.each(function (i) { - if (!$.data(this, 'tb-ext-iframe-' + clName)) { - $.data(this, 'tb-ext-iframe-' + clName, new ToolboxIframe(this, options)); - els.push(this); - } - }); - - return this; - }; - - $.fn.toolboxIframe.defaults = { - editmode: false - }; - -}) -(jQuery, window, document); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.video.js b/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.video.js deleted file mode 100644 index 6b90713b..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/plugins/jquery.tb.ext.video.js +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Project: PIMCORE Toolbox - * Extension: Video - * Version: 2.3 - * Author: DACHCOM.DIGITAL - * License: GPL-3.0-or-later -*/ -;(function ($, window, document) { - 'use strict'; - var clName = 'ToolboxVideo'; - - function VideoIdExtractor(options) { - this.userMethods = options; - this.extrator = { - asset: function (videoId) { - return videoId; - }, - youtube: function (url) { - var regExp, match, url = url.toString(); - if (!url.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/)) { - return url; - } else { - regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\??v?=?))([^#\&\?]*).*/; - match = url.match(regExp); - if (match && match[7]) { - return match[7]; - } else { - console.log('Unable to parse video id from url: ' + url); - } - } - }, - - vimeo: function (url) { - var regExp, match, url = url.toString(); - if (!url.match(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/)) { - return url; - } else { - regExp = /https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)/; - match = url.match(regExp); - if (match && match[3]) { - return match[3]; - } else { - console.log('Unable to parse video id from url: ' + url); - } - } - } - }; - - this.getVideoId = function () { - - var args = Array.prototype.slice.call(arguments), - type = args.shift(); - - if (typeof this.userMethods[type] === 'function') { - return this.userMethods[type].apply(null, args); - } - - if (typeof this.extrator[type] === 'function') { - return this.extrator[type].apply(null, args); - } - - console.warn('no valid video id extractor for ' + type + ' found!'); - - return null; - } - } - - function ToolboxVideo(element, options) { - this.$element = $(element); - this.options = $.extend(true, $.fn.toolboxVideo.defaults, options); - this.videoIdExtractor = new VideoIdExtractor(this.options.videoIdExtractor); - this.init(); - } - - $.extend(ToolboxVideo.prototype, { - - $player: null, - elementId: null, - videoId: null, - videoType: null, - playerEngine: null, - autoPlay: false, - playInLightBox: false, - videoParameter: {}, - - hasPoster: false, - posterPath: null, - - editMode: false, - - internalTypes: ['youtube', 'vimeo', 'asset'], - isReady: false, - - init: function () { - this.editMode = this.options.editmode; - - if (this.editMode == true) { - return; - } - - this.setupVideoElement(); - $(window).on('scroll.toolbox.video', this.pingAutoPlay.bind(this)); - }, - - setupVideoElement: function () { - - this.elementId = this.$element.data('tb-ext-video-index'); - this.videoType = this.$element.data('type'); - - if (this.$element.hasClass('autoplay')) { - this.autoPlay = true; - } - - this.$player = this.$element.find('.player'); - if (this.$player.length === 0) { - return; - } - - this.videoId = this.getVideoId(this.$player.data('video-uri')); - this.playInLightBox = this.$player.data('play-in-lightbox'); - this.posterPath = this.$player.data('poster-path'); - - if (this.$player.data('video-parameter') !== undefined) { - this.videoParameter = this.$player.data('video-parameter'); - } - - if (this.posterPath) { - this.hasPoster = true; - } - - switch (this.videoType) { - case 'youtube' : - this.setupYoutubeVideo(); - break; - case 'asset' : - this.setupAssetVideo(); - break; - case 'vimeo': - this.setupVimeoVideo(); - break; - default: - this.setupCustomVideo(); - } - - this.checkElementEnvironment(); - - }, - - checkElementEnvironment: function () { - - var _ = this; - - // special treatment for a auto play video inside accordion and tabs - if (this.autoPlay === true && (this.options.theme === 'bootstrap3' || this.options.theme === 'bootstrap4')) { - $(document).on('shown.bs.collapse', function (ev) { - var $target = $(ev.target); - if ($target && $.contains($target[0], _.$element[0])) { - _.playVideo(); - } - }).on('hide.bs.collapse', function (ev) { - var $target = $(ev.target); - if ($target && $.contains($target[0], _.$element[0])) { - _.pauseVideo(); - } - }).on('shown.bs.tab shown-tabs.bs.tab-collapse', function (ev) { - var $target = $($(ev.target).attr('href')); - if ($target && $.contains($target[0], _.$element[0])) { - _.playVideo(); - } - }).on('hide.bs.tab hide-tabs.bs.tab-collapse', function (ev) { - var $target = $($(ev.target).attr('href')); - if ($target && $.contains($target[0], _.$element[0])) { - _.pauseVideo(); - } - }); - } - }, - - setupAssetVideo: function () { - - var _ = this; - - if (_.playInLightBox && _.hasPoster) { - _.$element.on('click', function (ev) { - ev.preventDefault(); - _.$element.trigger('toolbox.video.asset.lightbox', [{ - 'videoId': _.videoId, - 'posterPath': _.posterPath - }]); - }); - - } else { - - if (!_.hasPoster) { - _.isReady = true; - _.$element.addClass('player-ready'); - _.$element.trigger('toolbox.video.asset.init'); - } else { - _.$element.one('click', function (ev) { - ev.preventDefault(); - _.isReady = true; - _.$element.find('.poster-overlay').remove(); - _.$element.addClass('player-ready'); - _.$element.trigger('toolbox.video.asset.init'); - }); - } - } - }, - - setupYoutubeVideo: function () { - - var _ = this, - tag, - deferred, - currentIndex = this.elementId, - apiIsReady = $('body').data('toolbox-youtube-api-ready') === true; - - if (apiIsReady === false) { - deferred = $.Deferred(); - if (window.toolboxVideoYoutubeDeferer === undefined) { - window.toolboxVideoYoutubeDeferer = {}; - } - if (!window.toolboxVideoYoutubeDeferer[currentIndex]) { - window.toolboxVideoYoutubeDeferer[currentIndex] = deferred; - } - } - - if ($('body').find('script.tb-video-youtube-api').length === 0) { - tag = document.createElement('script'); - tag.src = this.options.resources.youtube; - tag.className = 'tb-video-youtube-api'; - $('body').append(tag); - - window.onYouTubeIframeAPIReady = function () { - $('body').data('toolbox-youtube-api-ready', true); - if (window.toolboxVideoYoutubeDeferer) { - $.each(window.toolboxVideoYoutubeDeferer, function (i, d) { - delete window.toolboxVideoYoutubeDeferer[i]; - if (Object.keys(window.toolboxVideoYoutubeDeferer).length === 0) { - delete window.toolboxVideoYoutubeDeferer; - } - d.resolve(); - }) - } - }; - } - - var init = function () { - - if (_.playInLightBox && _.hasPoster) { - _.$element.on('click', function (ev) { - ev.preventDefault(); - _.$element.trigger('toolbox.video.youtube.lightbox', [{ - 'videoId': _.videoId, - 'posterPath': _.posterPath, - 'YT': window.YT - }]); - }); - - } else { - - var initPlayer = function ($el, autostart) { - var player, - playerVars = $.extend({}, _.options.apiParameter.youtube, _.videoParameter), - options = { - videoId: _.videoId, - host: 'https://www.youtube-nocookie.com', - events: { - 'onReady': function () { - _.isReady = true; - _.playerEngine = player; - _.$element.addClass('player-ready'); - if (autostart === true) { - _.playVideo(); - } - } - } - }; - - player = new window.YT.Player( - $el, $.extend({}, {playerVars: playerVars}, options) - ); - }; - - if (!_.hasPoster) { - initPlayer(_.$player.get(0), _.autoPlay); - } else { - _.$element.one('click', function (ev) { - ev.preventDefault(); - initPlayer(_.$player.get(0), true); - _.$element.find('.poster-overlay').remove(); - }); - } - } - } - - if (apiIsReady) { - init(); - } else { - deferred.done(function (YT) { - init(); - }); - } - }, - - setupVimeoVideo: function () { - - var _ = this, - tag, - deferred, - currentIndex = this.elementId, - apiIsReady = $('body').data('toolbox-vimeo-api-ready') === true; - - if (apiIsReady === false) { - deferred = $.Deferred(); - if (window.toolboxVideoVimeoStatus === undefined) { - window.toolboxVideoVimeoStatus = 'init'; - } - - if (window.toolboxVideoVimeoDeferer === undefined) { - window.toolboxVideoVimeoDeferer = {}; - } - - if (!window.toolboxVideoVimeoDeferer[currentIndex]) { - window.toolboxVideoVimeoDeferer[currentIndex] = deferred; - } - } - - if (window.toolboxVideoVimeoStatus === 'init') { - window.toolboxVideoVimeoStatus = 'loading'; - $.getScript(this.options.resources.vimeo, function (data, textStatus, jqxhr) { - window.toolboxVideoVimeoStatus = 'loaded'; - $('body').data('toolbox-vimeo-api-ready', true); - if (window.toolboxVideoVimeoDeferer) { - $.each(window.toolboxVideoVimeoDeferer, function (i, d) { - delete window.toolboxVideoVimeoDeferer[i]; - if (Object.keys(window.toolboxVideoVimeoDeferer).length === 0) { - delete window.toolboxVideoVimeoDeferer; - } - d.resolve(); - }) - } - }); - } - - var init = function () { - - if (_.playInLightBox && _.hasPoster) { - _.$element.on('click', function (ev) { - ev.preventDefault(); - _.$element.trigger('toolbox.video.vimeo.lightbox', [{ - 'videoId': _.videoId, - 'posterPath': _.posterPath, - 'Vimeo': Vimeo.Player - }]); - }); - - } else { - - var initPlayer = function (el, autostart) { - - var player, - options = { - id: _.videoId - }; - - player = new Vimeo.Player( - el, $.extend({}, _.options.apiParameter.vimeo, _.videoParameter, options) - ); - - player.on('loaded', function () { - _.isReady = true; - _.playerEngine = player; - _.$element.addClass('player-ready'); - if (autostart === true) { - _.playVideo(); - } - }); - }; - - if (!_.hasPoster) { - initPlayer(_.$player.get(0), _.autoPlay); - } else { - _.$element.one('click', function (ev) { - ev.preventDefault(); - initPlayer(_.$player.get(0), true); - _.$element.find('.poster-overlay').remove(); - }); - } - } - } - - if (apiIsReady) { - init(); - } else { - deferred.done(function (YT) { - init(); - }); - } - }, - - setupCustomVideo: function () { - this.$element.trigger('toolbox.video.custom.setup', [this]); - }, - - playVideo: function () { - - var _ = this; - - if (this.isReady === false) { - return; - } - - switch (this.videoType) { - case 'youtube' : - if (typeof this.playerEngine.getPlayerState === 'function') { - if (this.playerEngine.getPlayerState() !== window.YT.PlayerState.PLAYING) { - this.playerEngine.playVideo(); - } - } - break; - case 'asset' : - this.$element.trigger('toolbox.video.asset.play'); - break; - case 'vimeo': - if (typeof this.playerEngine.getPaused === 'function') { - this.playerEngine.getPaused().then(function (paused) { - if (paused) { - _.playerEngine.play(); - } - }).catch(function (error) { /* fail silently */ - }); - } - break; - default: - this.$element.trigger('toolbox.video.custom.play'); - } - }, - - pauseVideo: function (player, type) { - - var _ = this; - - if (this.isReady === false) { - return; - } - - switch (this.videoType) { - case 'youtube' : - if (typeof this.playerEngine.getPlayerState === 'function') { - if (this.playerEngine.getPlayerState() === window.YT.PlayerState.PLAYING) { - this.playerEngine.pauseVideo(); - } - } - break; - case 'asset' : - this.$element.trigger('toolbox.video.asset.pause'); - break; - case 'vimeo': - if (typeof this.playerEngine.getPaused === 'function') { - this.playerEngine.getPaused().then(function (paused) { - if (!paused) { - _.playerEngine.pause(); - } - }).catch(function (error) { /* fail silently */ - }); - } - break; - default: - this.$element.trigger('toolbox.video.custom.pause'); - } - }, - - getVideoId: function (url) { - return this.videoIdExtractor.getVideoId(this.videoType, url); - }, - - pingAutoPlay: function (ev) { - - if (typeof Modernizr !== 'undefined' && Modernizr.touchevents) { - return; - } - - if (!this.isReady || this.autoPlay === false) { - return; - } - - var _ = this, - tolerancePixel = 40, - scrollTop = $(window).scrollTop() + tolerancePixel, - scrollBottom = $(window).scrollTop() + $(window).height() - tolerancePixel; - - var yTopMedia = this.$element.offset().top, - yBottomMedia = this.$element.height() + yTopMedia; - - if (scrollTop < yBottomMedia && scrollBottom > yTopMedia) { - _.playVideo(); - } else { - _.pauseVideo(); - } - } - }); - - $.fn.toolboxVideo = function (options) { - var els = []; - this.each(function (i) { - if (!window.toolboxYoutubeElementCounter) { - window.toolboxYoutubeElementCounter = 0; - } - if (!$.data(this, 'tb-ext-video-' + clName)) { - $.data(this, 'tb-ext-video-index', window.toolboxYoutubeElementCounter); - $.data(this, 'tb-ext-video-' + clName, new ToolboxVideo(this, options)); - window.toolboxYoutubeElementCounter++; - els.push(this); - } - }); - - return this; - }; - - $.fn.toolboxVideo.defaults = { - editmode: false, - videoIdExtractor: {}, - theme: 'bootstrap4', - resources: { - youtube: 'https://www.youtube.com/iframe_api', - vimeo: 'https://player.vimeo.com/api/player.js', - }, - apiParameter: { - youtube: {}, - vimeo: {} - } - }; - -}) -(jQuery, window, document); diff --git a/src/ToolboxBundle/Resources/public/js/frontend/vendor/vimeo-api.min.js b/src/ToolboxBundle/Resources/public/js/frontend/vendor/vimeo-api.min.js deleted file mode 100644 index 16082e4b..00000000 --- a/src/ToolboxBundle/Resources/public/js/frontend/vendor/vimeo-api.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! @vimeo/player v1.0.1 | (c) 2016 Vimeo | MIT License | https://github.com/vimeo/player.js */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e.Vimeo=e.Vimeo||{},e.Vimeo.Player=t())}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e,t,n){var r=T.get(e.element)||{};t in r||(r[t]=[]),r[t].push(n),T.set(e.element,r)}function n(e,t){var n=T.get(e.element)||{};return n[t]||[]}function r(e,t,n){var r=T.get(e.element)||{};if(!r[t])return!0;if(!n)return r[t]=[],T.set(e.element,r),!0;var o=r[t].indexOf(n);return-1!==o&&r[t].splice(o,1),T.set(e.element,r),r[t]&&0===r[t].length}function o(e,t){var n=T.get(e);T.set(t,n),T["delete"](e)}function i(e,t){return 0===e.indexOf(t.toLowerCase())?e:""+t.toLowerCase()+e.substr(0,1).toUpperCase()+e.substr(1)}function a(e){return e instanceof window.HTMLElement}function u(e){return!isNaN(parseFloat(e))&&isFinite(e)&&Math.floor(e)==e}function s(e){return/^(https?:)?\/\/(player.)?vimeo.com/.test(e)}function c(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],t=e.id,n=e.url,r=t||n;if(!r)throw new Error("An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.");if(u(r))return"https://vimeo.com/"+r;if(s(r))return r.replace("http:","https:");if(t)throw new TypeError("“"+t+"” is not a valid video id.");throw new TypeError("“"+r+"” is not a vimeo.com url.")}function f(e){for(var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=_,r=Array.isArray(n),o=0,n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if(o=n.next(),o.done)break;i=o.value}var a=i,u=e.getAttribute("data-vimeo-"+a);(u||""===u)&&(t[a]=""===u?1:u)}return t}function l(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return new Promise(function(n,r){if(!s(e))throw new TypeError("“"+e+"” is not a vimeo.com url.");var o="https://vimeo.com/api/oembed.json?url="+encodeURIComponent(e);for(var i in t)t.hasOwnProperty(i)&&(o+="&"+i+"="+encodeURIComponent(t[i]));var a="XDomainRequest"in window?new XDomainRequest:new XMLHttpRequest;a.open("GET",o,!0),a.onload=function(){if(404===a.status)return void r(new Error("“"+e+"” was not found."));if(403===a.status)return void r(new Error("“"+e+"” is not embeddable."));try{var t=JSON.parse(a.responseText);n(t)}catch(o){r(o)}},a.onerror=function(){var e=a.status?" ("+a.status+")":"";r(new Error("There was an error fetching the embed code from Vimeo"+e+"."))},a.send()})}function h(e,t){var n=e.html;if(!t)throw new TypeError("An element must be provided");if(null!==t.getAttribute("data-vimeo-initialized"))return t.querySelector("iframe");var r=document.createElement("div");r.innerHTML=n;var o=r.firstChild;return t.appendChild(o),t.setAttribute("data-vimeo-initialized","true"),o}function d(){var e=arguments.length<=0||void 0===arguments[0]?document:arguments[0],t=[].slice.call(e.querySelectorAll("[data-vimeo-id], [data-vimeo-url]")),n=function(e){"console"in window&&console.error&&console.error("There was an error creating an embed: "+e)},r=function(){if(i){if(a>=o.length)return"break";u=o[a++]}else{if(a=o.next(),a.done)return"break";u=a.value}var e=u;try{if(null!==e.getAttribute("data-vimeo-defer"))return"continue";var t=c(e),r=f(e);l(t,r).then(function(t){return h(t,e)})["catch"](n)}catch(s){n(s)}};e:for(var o=t,i=Array.isArray(o),a=0,o=i?o:o[Symbol.iterator]();;){var u,s=r();switch(s){case"break":break e;case"continue":continue}}}function p(e){return"string"==typeof e&&(e=JSON.parse(e)),e}function v(e,t,n){if(e.element.contentWindow.postMessage){var r={method:t};void 0!==n&&(r.value=n);var o=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1"));o>=8&&10>o&&(r=JSON.stringify(r)),e.element.contentWindow.postMessage(r,e.origin)}}function y(e,t){t=p(t);var o=[],i=void 0;if(t.event){if("error"===t.event)for(var a=n(e,t.data.method),u=a,s=Array.isArray(u),c=0,u=s?u:u[Symbol.iterator]();;){var f;if(s){if(c>=u.length)break;f=u[c++]}else{if(c=u.next(),c.done)break;f=c.value}var l=f,h=new Error(t.data.message);h.name=t.data.name,l.reject(h),r(e,t.data.method,l)}o=n(e,"event:"+t.event),i=t.data}else t.method&&(o=n(e,t.method),i=t.value,r(e,t.method));for(var d=o,v=Array.isArray(d),y=0,d=v?d:d[Symbol.iterator]();;){var m;if(v){if(y>=d.length)break;m=d[y++]}else{if(y=d.next(),y.done)break;m=y.value}var g=m;try{if("function"==typeof g){g.call(e,i);continue}g.resolve(i)}catch(w){}}}var m="undefined"!=typeof Array.prototype.indexOf,g="undefined"!=typeof window.postMessage;if(!m||!g)throw new Error("Sorry, the Vimeo Player API is not available in this browser.");var w="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},b=(e(function(e,t){!function(e){function t(e,t){function r(e){return this&&this.constructor===r?(this._keys=[],this._values=[],this._itp=[],this.objectOnly=t,void(e&&n.call(this,e))):new r(e)}return t||w(e,"size",{get:y}),e.constructor=r,r.prototype=e,r}function n(e){this.add?e.forEach(this.add,this):e.forEach(function(e){this.set(e[0],e[1])},this)}function r(e){return this.has(e)&&(this._keys.splice(g,1),this._values.splice(g,1),this._itp.forEach(function(e){g-1}function o(e){return this.has(e)?this._values[g]:void 0}function i(e,t){if(this.objectOnly&&t!==Object(t))throw new TypeError("Invalid value used as weak collection key");if(t!=t||0===t)for(g=e.length;g--&&!b(e[g],t););else g=e.indexOf(t);return g>-1}function a(e){return i.call(this,this._values,e)}function u(e){return i.call(this,this._keys,e)}function s(e,t){return this.has(e)?this._values[g]=t:this._values[this._keys.push(e)-1]=t,this}function c(e){return this.has(e)||this._values.push(e),this}function f(){(this._keys||0).length=this._values.length=0}function l(){return v(this._itp,this._keys)}function h(){return v(this._itp,this._values)}function d(){return v(this._itp,this._keys,this._values)}function p(){return v(this._itp,this._values,this._values)}function v(e,t,n){var r=[0],o=!1;return e.push(r),{next:function(){var i,a=r[0];return!o&&a0&&e(n,s))}catch(c){i.call(new u(s),c)}}}function i(t){var r=this;r.triggered||(r.triggered=!0,r.def&&(r=r.def),r.msg=t,r.state=2,r.chain.length>0&&e(n,r))}function a(e,t,n,r){for(var o=0;o1&&"console"in window&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),t=t[0]),"string"==typeof t&&(t=document.getElementById(t)),!a(t))throw new TypeError("You must pass either a valid element or a valid id.");if("IFRAME"!==t.nodeName){var i=t.querySelector("iframe");i&&(t=i)}if("IFRAME"===t.nodeName&&!s(t.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(x.has(t))return x.get(t);this.element=t,this.origin="*";var u=new E(function(e,i){var a=function(t){if(s(t.origin)&&n.element.contentWindow===t.source){"*"===n.origin&&(n.origin=t.origin);var r=p(t.data),o="event"in r&&"ready"===r.event,i="method"in r&&"ping"===r.method;return o||i?(n.element.setAttribute("data-ready","true"),void e()):void y(n,r)}};if(window.addEventListener?window.addEventListener("message",a,!1):window.attachEvent&&window.attachEvent("onmessage",a),"IFRAME"!==n.element.nodeName){var u=f(t,r),d=c(u);l(d,u).then(function(e){var r=h(e,t);return n.element=r,o(t,r),e})["catch"](function(e){return i(e)})}});return j.set(this,u),x.set(this.element,this),"IFRAME"===this.element.nodeName&&v(this,"ping"),this}return e.prototype.then=function(e){var t=arguments.length<=1||void 0===arguments[1]?function(){}:arguments[1];return this.ready().then(e,t)},e.prototype.callMethod=function(e){var n=this,r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return new E(function(o,i){return n.ready().then(function(){t(n,e,{resolve:o,reject:i}),v(n,e,r)})})},e.prototype.get=function(e){var n=this;return new E(function(r,o){return e=i(e,"get"),n.ready().then(function(){t(n,e,{resolve:r,reject:o}),v(n,e)})})},e.prototype.set=function(e,n){var r=this;return E.resolve(n).then(function(n){if(e=i(e,"set"),void 0===n||null===n)throw new TypeError("There must be a value to set.");return r.ready().then(function(){return new E(function(o,i){t(r,e,{resolve:o,reject:i}),v(r,e,n)})})})},e.prototype.on=function(e,r){if(!e)throw new TypeError("You must pass an event name.");if(!r)throw new TypeError("You must pass a callback function.");if("function"!=typeof r)throw new TypeError("The callback must be a function.");var o=n(this,"event:"+e);0===o.length&&this.callMethod("addEventListener",e)["catch"](function(){}),t(this,"event:"+e,r)},e.prototype.off=function(e,t){if(!e)throw new TypeError("You must pass an event name.");if(t&&"function"!=typeof t)throw new TypeError("The callback must be a function.");var n=r(this,"event:"+e,t);n&&this.callMethod("removeEventListener",e)["catch"](function(e){})},e.prototype.loadVideo=function(e){return this.callMethod("loadVideo",e)},e.prototype.ready=function(){var e=j.get(this);return E.resolve(e)},e.prototype.enableTextTrack=function(e,t){if(!e)throw new TypeError("You must pass a language.");return this.callMethod("enableTextTrack",{language:e,kind:t})},e.prototype.disableTextTrack=function(){return this.callMethod("disableTextTrack")},e.prototype.pause=function(){return this.callMethod("pause")},e.prototype.play=function(){return this.callMethod("play")},e.prototype.unload=function(){return this.callMethod("unload")},e.prototype.getAutopause=function(){return this.get("autopause")},e.prototype.setAutopause=function(e){return this.set("autopause",e)},e.prototype.getColor=function(){return this.get("color")},e.prototype.setColor=function(e){return this.set("color",e)},e.prototype.getCurrentTime=function(){return this.get("currentTime")},e.prototype.setCurrentTime=function(e){return this.set("currentTime",e)},e.prototype.getDuration=function(){return this.get("duration")},e.prototype.getEnded=function(){return this.get("ended")},e.prototype.getLoop=function(){return this.get("loop")},e.prototype.setLoop=function(e){return this.set("loop",e)},e.prototype.getPaused=function(){return this.get("paused")},e.prototype.getTextTracks=function(){return this.get("textTracks")},e.prototype.getVideoEmbedCode=function(){return this.get("videoEmbedCode")},e.prototype.getVideoId=function(){return this.get("videoId")},e.prototype.getVideoTitle=function(){return this.get("videoTitle")},e.prototype.getVideoWidth=function(){return this.get("videoWidth")},e.prototype.getVideoHeight=function(){return this.get("videoHeight")},e.prototype.getVideoUrl=function(){return this.get("videoUrl")},e.prototype.getVolume=function(){return this.get("volume")},e.prototype.setVolume=function(e){return this.set("volume",e)},e}();return d(),A}); \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/public/js/startup.js b/src/ToolboxBundle/Resources/public/js/startup.js index c5731ee3..b62b17ef 100755 --- a/src/ToolboxBundle/Resources/public/js/startup.js +++ b/src/ToolboxBundle/Resources/public/js/startup.js @@ -4,13 +4,8 @@ pimcore.plugin.toolbox = Class.create(pimcore.plugin.admin, { getClassName: function() { return 'pimcore.plugin.toolbox'; }, - initialize: function() { pimcore.plugin.broker.registerPlugin(this); - }, - - pimcoreReady: function (params,broker){ - } }); diff --git a/src/ToolboxBundle/Resources/public/js/toolbox-ckeditor-plugins.js b/src/ToolboxBundle/Resources/public/js/toolbox-ckeditor-plugins.js index cc28e4a0..d8ca5cde 100644 --- a/src/ToolboxBundle/Resources/public/js/toolbox-ckeditor-plugins.js +++ b/src/ToolboxBundle/Resources/public/js/toolbox-ckeditor-plugins.js @@ -65,7 +65,7 @@ CKEDITOR.dialog.add('tbGoogleOptOutLinkDialog', function (editor) { element = element.getAscendant('a', true); } - if (!element || element.getName() != 'a' || !element.hasClass('google-opt-out-link')) { + if (!element || element.getName() !== 'a' || !element.hasClass('google-opt-out-link')) { element = editor.document.createElement('a'); element.setAttribute('class', 'google-opt-out-link'); element.setAttribute('href', '#'); @@ -82,7 +82,6 @@ CKEDITOR.dialog.add('tbGoogleOptOutLinkDialog', function (editor) { }, onOk: function () { - var dialog = this; var aLink = this.element; this.commitContent(aLink); diff --git a/src/ToolboxBundle/Resources/views/Admin/AreaConfig/fieldSet.html.twig b/src/ToolboxBundle/Resources/views/Admin/AreaConfig/fieldSet.html.twig deleted file mode 100644 index 15bbfc7b..00000000 --- a/src/ToolboxBundle/Resources/views/Admin/AreaConfig/fieldSet.html.twig +++ /dev/null @@ -1,68 +0,0 @@ -{% apply spaceless %} - -{% if config_elements|length > 0 %} - -
-
- -
- - {% set row_element_counter = 0 %} - {% set row_counter = 0 %} - {% set last_col_class = null %} - - {% for c, config_element in config_elements %} - - {% set edit_mode_hidden_class = config_element.additional_config.editmode_hidden == true ? 'editmode-hidden' : '' %} - - {% if c == 0 %} -
- {% endif %} - - {% if config_element.additional_config.col_class == 't-col-half' or config_element.additional_config.col_class == 't-col-third' %} - {% set row_element_counter = row_element_counter + 1 %} - {% else %} - {% set row_element_counter = 0 %} - {% endif %} - - {% if config_element.additional_config.col_class == 't-col-full' and last_col_class != 't-col-full' %} -
- {% endif %} - -
-
- - {% if config_element.additional_config.title is not null %} - - {% endif %} - {% include '@Toolbox/Admin/AreaConfig/Elements/tag.html.twig' with {'type' : config_element.additional_config.type, 'tag_name' : config_element.additional_config.name, 'tag_config': config_element.tag_config} %} - - {% if config_element.additional_config.description is defined and config_element.additional_config.description is not empty %} -
{{ config_element.additional_config.description }}
- {% endif %} - -
-
- - {% if row_element_counter == 0 or (config_element.additional_config.col_class == 't-col-half' and row_element_counter is divisible by(2)) or (config_element.additional_config.col_class == 't-col-third' and row_element_counter is divisible by(3)) %} - {% set edit_mode_hidden_class = config_elements[c+1].additional_config is defined and config_elements[c+1].additional_config.editmode_hidden == true ? 'editmode-hidden' : '' %} -
- {% endif %} - - {% set last_col_class = config_element.additional_config.col_class %} - - {% if c == config_elements|length - 1 %} -
- {% endif %} - - {% endfor %} - -
- -
- -{% else %} -
-{% endif %} - -{% endapply %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/anchor/view.html.twig b/src/ToolboxBundle/Resources/views/Areas/anchor/view.html.twig deleted file mode 100644 index a8fbf97c..00000000 --- a/src/ToolboxBundle/Resources/views/Areas/anchor/view.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} -{{ wrap_macro.createWrapHead(elementThemeConfig) }} -{% include toolbox_area_path(areaId) %} -{{ wrap_macro.createWrapFoot(elementThemeConfig) }} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/container/view.html.twig b/src/ToolboxBundle/Resources/views/Areas/container/view.html.twig deleted file mode 100644 index 02de0efe..00000000 --- a/src/ToolboxBundle/Resources/views/Areas/container/view.html.twig +++ /dev/null @@ -1,7 +0,0 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} -
- {{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) with { 'containerClass' : pimcore_checkbox('full_width_container').isChecked() ? 'container-fluid' : 'container' } %} - {{ wrap_macro.createWrapFoot(elementThemeConfig) }} -
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Helper/field-alert.html.twig b/src/ToolboxBundle/Resources/views/Helper/field-alert.html.twig deleted file mode 100644 index d44b5da6..00000000 --- a/src/ToolboxBundle/Resources/views/Helper/field-alert.html.twig +++ /dev/null @@ -1 +0,0 @@ -
{{ message }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/view.html.twig deleted file mode 100644 index e8f840ea..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/view.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include toolbox_area_path(areaId, '/AccordionTab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/areablock.html.twig deleted file mode 100644 index c732c933..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/areablock.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@Toolbox/Helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/view.html.twig deleted file mode 100644 index 7d0f596e..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/view.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% if type is not empty %} - {% include toolbox_area_path(areaId, 'Partial/' ~ partialName) %} -{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/LinkList/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/LinkList/view.html.twig deleted file mode 100644 index dc76e585..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/LinkList/view.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -
    - {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} - {% if useDynamicLinks == true %} -
  • {{ pimcore_dynamiclink('linklist', {'class' : 'list-link'}) }}
  • - {% else %} -
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • - {% endif %} - {% endfor %} -
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/view.html.twig deleted file mode 100644 index 34b25bad..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/view.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include toolbox_area_path(areaId, 'Partial/background-' ~ backgroundMode) %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/view.html.twig deleted file mode 100644 index e8f840ea..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/view.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include toolbox_area_path(areaId, '/AccordionTab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/areablock.html.twig deleted file mode 100644 index c732c933..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/areablock.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include '@Toolbox/Helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/view.html.twig deleted file mode 100644 index 7d0f596e..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/view.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% if type is not empty %} - {% include toolbox_area_path(areaId, 'Partial/' ~ partialName) %} -{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/Partial/list.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/Partial/list.html.twig deleted file mode 100644 index 1e90518c..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/Partial/list.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% if downloads is iterable %} -
-
    - {% for download in downloads %} - {% include toolbox_area_path(areaId, '/Partial/item') with { - 'download': download, - 'showPreviewImages' : showPreviewImages, - 'showFileInfo' : showFileInfo, - } %} - {% endfor %} -
-
-{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/view.html.twig deleted file mode 100644 index 0e76072c..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/view.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -{% include toolbox_area_path(areaId, 'Partial/list') with { -'editmode': editmode, -'showPreviewImages': pimcore_checkbox('show_preview_images').isChecked(), -'showFileInfo': pimcore_checkbox('show_file_info').isChecked(), -} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/LinkList/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/LinkList/view.html.twig deleted file mode 100644 index dc76e585..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/LinkList/view.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -
    - {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} - {% if useDynamicLinks == true %} -
  • {{ pimcore_dynamiclink('linklist', {'class' : 'list-link'}) }}
  • - {% else %} -
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • - {% endif %} - {% endfor %} -
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/view.html.twig deleted file mode 100644 index 34b25bad..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/view.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include toolbox_area_path(areaId, 'Partial/background-' ~ backgroundMode) %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/view.html.twig deleted file mode 100644 index e8f840ea..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/view.html.twig +++ /dev/null @@ -1 +0,0 @@ -{% include toolbox_area_path(areaId, '/AccordionTab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/areablock.html.twig deleted file mode 100644 index 9854d739..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/areablock.html.twig +++ /dev/null @@ -1,2 +0,0 @@ - -{% include '@Toolbox/Helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/view.html.twig deleted file mode 100644 index 7d0f596e..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/view.html.twig +++ /dev/null @@ -1,3 +0,0 @@ -{% if type is not empty %} - {% include toolbox_area_path(areaId, 'Partial/' ~ partialName) %} -{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/Partial/list.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/Partial/list.html.twig deleted file mode 100644 index a07f1820..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/Partial/list.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% if downloads is iterable %} -
-
    - {% for download in downloads %} - {% include toolbox_area_path(areaId, '/Partial/item') with { - 'download': download, - 'showPreviewImages' : showPreviewImages, - 'showFileInfo' : showFileInfo, - } %} - {% endfor %} -
-
-{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/LinkList/view.html.twig b/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/LinkList/view.html.twig deleted file mode 100644 index 1d6933f6..00000000 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/LinkList/view.html.twig +++ /dev/null @@ -1,9 +0,0 @@ -
    - {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} - {% if useDynamicLinks == true %} -
  • {{ pimcore_dynamiclink('linklist', {'class' : 'list-link'}) }}
  • - {% else %} -
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • - {% endif %} - {% endfor %} -
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Admin/AreaConfig/Elements/tag.html.twig b/src/ToolboxBundle/Resources/views/admin/area-config/Elements/tag.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Admin/AreaConfig/Elements/tag.html.twig rename to src/ToolboxBundle/Resources/views/admin/area-config/Elements/tag.html.twig diff --git a/src/ToolboxBundle/Resources/views/Admin/Javascript/frontend.html.twig b/src/ToolboxBundle/Resources/views/admin/javascript/frontend.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Admin/Javascript/frontend.html.twig rename to src/ToolboxBundle/Resources/views/admin/javascript/frontend.html.twig diff --git a/src/ToolboxBundle/Resources/views/Admin/Settings/ckeditor-area-style.html.twig b/src/ToolboxBundle/Resources/views/admin/settings/ckeditor-area-style.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Admin/Settings/ckeditor-area-style.html.twig rename to src/ToolboxBundle/Resources/views/admin/settings/ckeditor-area-style.html.twig diff --git a/src/ToolboxBundle/Resources/views/Admin/Settings/ckeditor-object-style.html.twig b/src/ToolboxBundle/Resources/views/admin/settings/ckeditor-object-style.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Admin/Settings/ckeditor-object-style.html.twig rename to src/ToolboxBundle/Resources/views/admin/settings/ckeditor-object-style.html.twig diff --git a/src/ToolboxBundle/Resources/views/Areas/accordion/view.html.twig b/src/ToolboxBundle/Resources/views/areas/accordion/view.html.twig similarity index 67% rename from src/ToolboxBundle/Resources/views/Areas/accordion/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/accordion/view.html.twig index d6dc8dc1..6af9ed2c 100644 --- a/src/ToolboxBundle/Resources/views/Areas/accordion/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/accordion/view.html.twig @@ -1,9 +1,8 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %} {% set panel = pimcore_block('panels', {'default': 2}) %} {% set type = pimcore_select('type').getData() %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) with {'id': id, 'type' : type, 'panel' : panel} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) with {'id': id, 'type' : type, 'panel' : panel} %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
diff --git a/src/ToolboxBundle/Resources/views/areas/anchor/view.html.twig b/src/ToolboxBundle/Resources/views/areas/anchor/view.html.twig new file mode 100644 index 00000000..20e9df41 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/areas/anchor/view.html.twig @@ -0,0 +1,4 @@ +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %} +{{ wrap_macro.createWrapHead(elementThemeConfig) }} +{% include toolbox_area_path(areaId, areaTemplateDirectory) %} +{{ wrap_macro.createWrapFoot(elementThemeConfig) }} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/columns/view.html.twig b/src/ToolboxBundle/Resources/views/areas/columns/view.html.twig similarity index 67% rename from src/ToolboxBundle/Resources/views/Areas/columns/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/columns/view.html.twig index 67f0dec5..304b7403 100644 --- a/src/ToolboxBundle/Resources/views/Areas/columns/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/columns/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/areas/container/view.html.twig b/src/ToolboxBundle/Resources/views/areas/container/view.html.twig new file mode 100644 index 00000000..b8a57552 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/areas/container/view.html.twig @@ -0,0 +1,6 @@ +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %} +
+ {{ wrap_macro.createWrapHead(elementThemeConfig) }} + {% include toolbox_area_path(areaId, areaTemplateDirectory) with { 'containerClass' : pimcore_checkbox('full_width_container').isChecked() ? 'container-fluid' : 'container' } %} + {{ wrap_macro.createWrapFoot(elementThemeConfig) }} +
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/content/view.html.twig b/src/ToolboxBundle/Resources/views/areas/content/view.html.twig similarity index 63% rename from src/ToolboxBundle/Resources/views/Areas/content/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/content/view.html.twig index 73a81df5..8aa95669 100644 --- a/src/ToolboxBundle/Resources/views/Areas/content/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/content/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/download/view.html.twig b/src/ToolboxBundle/Resources/views/areas/download/view.html.twig similarity index 60% rename from src/ToolboxBundle/Resources/views/Areas/download/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/download/view.html.twig index 32e6a87c..2ffdfca4 100644 --- a/src/ToolboxBundle/Resources/views/Areas/download/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/download/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/gallery/view.html.twig b/src/ToolboxBundle/Resources/views/areas/gallery/view.html.twig similarity index 55% rename from src/ToolboxBundle/Resources/views/Areas/gallery/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/gallery/view.html.twig index f5b238dc..83e2fff0 100644 --- a/src/ToolboxBundle/Resources/views/Areas/gallery/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/gallery/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/googleMap/view.html.twig b/src/ToolboxBundle/Resources/views/areas/google-map/view.html.twig similarity index 74% rename from src/ToolboxBundle/Resources/views/Areas/googleMap/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/google-map/view.html.twig index bfff6b57..179b9b41 100644 --- a/src/ToolboxBundle/Resources/views/Areas/googleMap/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/google-map/view.html.twig @@ -1,8 +1,7 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) with { + {% include toolbox_area_path(areaId, areaTemplateDirectory) with { 'mapZoom': pimcore_numeric('map_zoom').getData(), 'mapType': pimcore_select('map_type').getData(), 'iwOnInit': pimcore_checkbox('iw_on_init').isChecked() diff --git a/src/ToolboxBundle/Resources/views/Areas/headline/view.html.twig b/src/ToolboxBundle/Resources/views/areas/headline/view.html.twig similarity index 70% rename from src/ToolboxBundle/Resources/views/Areas/headline/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/headline/view.html.twig index e06ea694..573d1172 100644 --- a/src/ToolboxBundle/Resources/views/Areas/headline/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/headline/view.html.twig @@ -1,10 +1,9 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} {% if anchorName is not empty %} {% endif %} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
diff --git a/src/ToolboxBundle/Resources/views/Areas/iFrame/view.html.twig b/src/ToolboxBundle/Resources/views/areas/iframe/view.html.twig similarity index 60% rename from src/ToolboxBundle/Resources/views/Areas/iFrame/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/iframe/view.html.twig index 237d51c6..21f0f6e1 100644 --- a/src/ToolboxBundle/Resources/views/Areas/iFrame/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/iframe/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/image/view.html.twig b/src/ToolboxBundle/Resources/views/areas/image/view.html.twig similarity index 60% rename from src/ToolboxBundle/Resources/views/Areas/image/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/image/view.html.twig index 578863a2..0f7f91c1 100644 --- a/src/ToolboxBundle/Resources/views/Areas/image/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/image/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/linkList/view.html.twig b/src/ToolboxBundle/Resources/views/areas/link-list/view.html.twig similarity index 60% rename from src/ToolboxBundle/Resources/views/Areas/linkList/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/link-list/view.html.twig index 486855e0..084283a4 100644 --- a/src/ToolboxBundle/Resources/views/Areas/linkList/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/link-list/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/parallaxContainer/view.html.twig b/src/ToolboxBundle/Resources/views/areas/parallax-container/view.html.twig similarity index 65% rename from src/ToolboxBundle/Resources/views/Areas/parallaxContainer/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/parallax-container/view.html.twig index aeffc796..61130efd 100644 --- a/src/ToolboxBundle/Resources/views/Areas/parallaxContainer/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/parallax-container/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/separator/view.html.twig b/src/ToolboxBundle/Resources/views/areas/separator/view.html.twig similarity index 61% rename from src/ToolboxBundle/Resources/views/Areas/separator/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/separator/view.html.twig index c85ab97d..ed868c0b 100644 --- a/src/ToolboxBundle/Resources/views/Areas/separator/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/separator/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/slideColumns/view.html.twig b/src/ToolboxBundle/Resources/views/areas/slide-columns/view.html.twig similarity index 65% rename from src/ToolboxBundle/Resources/views/Areas/slideColumns/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/slide-columns/view.html.twig index 0639b9ab..5793e892 100644 --- a/src/ToolboxBundle/Resources/views/Areas/slideColumns/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/slide-columns/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/snippet/view.html.twig b/src/ToolboxBundle/Resources/views/areas/snippet/view.html.twig similarity index 77% rename from src/ToolboxBundle/Resources/views/Areas/snippet/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/snippet/view.html.twig index 039502bc..d905b89f 100644 --- a/src/ToolboxBundle/Resources/views/Areas/snippet/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/snippet/view.html.twig @@ -1,4 +1,4 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} {{ pimcore_snippet('snippet') }} diff --git a/src/ToolboxBundle/Resources/views/Areas/spacer/view.html.twig b/src/ToolboxBundle/Resources/views/areas/spacer/view.html.twig similarity index 59% rename from src/ToolboxBundle/Resources/views/Areas/spacer/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/spacer/view.html.twig index eeba77b2..6827c029 100644 --- a/src/ToolboxBundle/Resources/views/Areas/spacer/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/spacer/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) with {'spacerClass' : pimcore_select('spacer_class').getData()} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) with {'spacerClass' : pimcore_select('spacer_class').getData()} %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/teaser/view.html.twig b/src/ToolboxBundle/Resources/views/areas/teaser/view.html.twig similarity index 60% rename from src/ToolboxBundle/Resources/views/Areas/teaser/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/teaser/view.html.twig index e436a30b..af0e423f 100644 --- a/src/ToolboxBundle/Resources/views/Areas/teaser/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/teaser/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Areas/video/view.html.twig b/src/ToolboxBundle/Resources/views/areas/video/view.html.twig similarity index 66% rename from src/ToolboxBundle/Resources/views/Areas/video/view.html.twig rename to src/ToolboxBundle/Resources/views/areas/video/view.html.twig index 334dc7be..975e874a 100644 --- a/src/ToolboxBundle/Resources/views/Areas/video/view.html.twig +++ b/src/ToolboxBundle/Resources/views/areas/video/view.html.twig @@ -1,7 +1,6 @@ -{% import '@Toolbox/Macro/wrap.html.twig' as wrap_macro %} -{{ elementConfigBar|raw }} +{% import '@Toolbox/macro/wrap.html.twig' as wrap_macro %}
{{ wrap_macro.createWrapHead(elementThemeConfig) }} - {% include toolbox_area_path(areaId) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory) %} {{ wrap_macro.createWrapFoot(elementThemeConfig) }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Helper/areablock.html.twig b/src/ToolboxBundle/Resources/views/helper/areablock.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Helper/areablock.html.twig rename to src/ToolboxBundle/Resources/views/helper/areablock.html.twig diff --git a/src/ToolboxBundle/Resources/views/helper/field-alert.html.twig b/src/ToolboxBundle/Resources/views/helper/field-alert.html.twig new file mode 100644 index 00000000..3c6d819b --- /dev/null +++ b/src/ToolboxBundle/Resources/views/helper/field-alert.html.twig @@ -0,0 +1 @@ +
{{ message }}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Macro/mapLink.html.twig b/src/ToolboxBundle/Resources/views/macro/mapLink.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Macro/mapLink.html.twig rename to src/ToolboxBundle/Resources/views/macro/mapLink.html.twig diff --git a/src/ToolboxBundle/Resources/views/Macro/wrap.html.twig b/src/ToolboxBundle/Resources/views/macro/wrap.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Macro/wrap.html.twig rename to src/ToolboxBundle/Resources/views/macro/wrap.html.twig diff --git a/src/ToolboxBundle/Resources/views/Snippet/content.html.twig b/src/ToolboxBundle/Resources/views/snippet/content.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Snippet/content.html.twig rename to src/ToolboxBundle/Resources/views/snippet/content.html.twig diff --git a/src/ToolboxBundle/Resources/views/Snippet/Layout/teaser-layout.html.twig b/src/ToolboxBundle/Resources/views/snippet/layout/teaser-layout.html.twig similarity index 89% rename from src/ToolboxBundle/Resources/views/Snippet/Layout/teaser-layout.html.twig rename to src/ToolboxBundle/Resources/views/snippet/layout/teaser-layout.html.twig index 23c28e0a..7aa821eb 100644 --- a/src/ToolboxBundle/Resources/views/Snippet/Layout/teaser-layout.html.twig +++ b/src/ToolboxBundle/Resources/views/snippet/layout/teaser-layout.html.twig @@ -1,7 +1,7 @@ {% extends '@Toolbox/snippet-layout.html.twig' %} {% block snippet_content %} {% if editmode %} -
+
{% if layoutStore|length > 0 %} {{ pimcore_select('ts_type', {'store' : layoutStore, reload: true, width: 300}) }}
@@ -18,7 +18,7 @@
{% endif %} {% if pimcore_select('ts_type').isEmpty() == false %} - {% include '@Toolbox/Snippet/teaser-' ~ pimcore_select('ts_type').getData() ~ '.html.twig' %} + {% include '@Toolbox/snippet/teaser-' ~ pimcore_select('ts_type').getData() ~ '.html.twig' %} {% endif %} {% if editmode %}
diff --git a/src/ToolboxBundle/Resources/views/Snippet/teaser-default.html.twig b/src/ToolboxBundle/Resources/views/snippet/teaser-default.html.twig similarity index 50% rename from src/ToolboxBundle/Resources/views/Snippet/teaser-default.html.twig rename to src/ToolboxBundle/Resources/views/snippet/teaser-default.html.twig index d23d0c43..dcee69d6 100644 --- a/src/ToolboxBundle/Resources/views/Snippet/teaser-default.html.twig +++ b/src/ToolboxBundle/Resources/views/snippet/teaser-default.html.twig @@ -1,22 +1,11 @@ {% set lightBoxParam = useLightBox is defined and useLightBox is not empty ? useLightBox : pimcore_checkbox('use_light_box').isChecked() %} {% set useLightBox = lightBoxParam and editmode == false %} -{% set hasLink = false %} -{% set link = null %} -{% set linkTarget = null %} - -{% if useDynamicLinks == true %} - {% set linkElement = pimcore_dynamiclink('link') %} - {% set hasLink = linkElement.isEmpty() == false %} - {% set linkElementData = hasLink ? linkElement.data : [] %} - {% set link = hasLink ? linkElement.href : null %} - {% set linkTarget = hasLink and linkElementData.target is defined ? linkElement.target : null %} -{% else %} - {% set linkElement = pimcore_link('link') %} - {% set hasLink = linkElement.isEmpty() == false %} - {% set linkElementData = hasLink ? linkElement.data : [] %} - {% set link = hasLink ? linkElement.href : null %} - {% set linkTarget = hasLink and linkElementData.target is defined ? linkElement.target : null %} -{% endif %} + +{% set linkElement = pimcore_link('link') %} +{% set hasLink = linkElement.isEmpty() == false %} +{% set linkElementData = hasLink ? linkElement.data : [] %} +{% set link = hasLink ? linkElement.href : null %} +{% set linkTarget = hasLink and linkElementData.target is defined ? linkElement.target : null %}
@@ -35,9 +24,5 @@ {{ pimcore_wysiwyg('text', {'height' : 100, 'customConfig' : toolbox_get_ckeditor_config_path()}) }}
- {% if useDynamicLinks == true %} - {{ pimcore_dynamiclink('link', {'class' : 'btn btn-default teaser-link'}) }} - {% else %} - {{ pimcore_link('link', {'class' : 'btn btn-default teaser-link'}) }} - {% endif %} + {{ pimcore_link('link', {'class' : 'btn btn-default teaser-link'}) }}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/accordion.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/accordion.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/accordion.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/accordion.html.twig index 47dc7a36..7c800f5f 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/accordion.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/accordion.html.twig @@ -10,14 +10,14 @@ data-parent="#{{ id }}" data-target="#panel-{{ id }}-{{ panel.currentIndex }}"> - {% include toolbox_area_path(areaId, 'Partial/Accordion/title') %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/accordion/title') %}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/tab.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/tab.html.twig similarity index 91% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/tab.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/tab.html.twig index 6bea0db2..7c7ded00 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/AccordionTab/tab.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/accordion-tab/tab.html.twig @@ -6,14 +6,14 @@ {% if editmode %} {{ pimcore_input('name') }}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
{% else %} {{ pimcore_input('name').data }} {% set content %} - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} {% endset %} {% set tabContent = tabContent|merge([{ 'index': panel.currentIndex, 'content': content}]) %} {% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/Partial/Accordion/title.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/partial/Accordion/title.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Accordion/Partial/Accordion/title.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/partial/Accordion/title.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/view.html.twig new file mode 100644 index 00000000..4519a4d6 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/accordion/view.html.twig @@ -0,0 +1 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, '/accordion-tab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Anchor/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/anchor/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Anchor/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/anchor/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/areablock.html.twig new file mode 100644 index 00000000..1f49b98e --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/areablock.html.twig @@ -0,0 +1 @@ +{% include '@Toolbox/helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/column.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/column.html.twig similarity index 55% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/column.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/column.html.twig index 33525eca..f1226b3e 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Columns/Partial/column.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/partial/column.html.twig @@ -1,7 +1,7 @@ {% for column in columns %}
- {% include toolbox_area_path(areaId, 'Partial/areablock') with { 'column' : column } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/areablock') with { 'column' : column } %}
{% endfor %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/view.html.twig new file mode 100644 index 00000000..481a2a4a --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/columns/view.html.twig @@ -0,0 +1,7 @@ +{% if type is not empty and partialName is not empty %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/' ~ partialName) %} +{% elseif editmode == true %} +
+ {{ 'No column size selected.'|trans({}, 'admin') }} +
+{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Container/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/container/view.html.twig similarity index 68% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Container/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/container/view.html.twig index 091b15c0..8c32d2f9 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Container/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/container/view.html.twig @@ -1,5 +1,5 @@
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Content/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/content/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Content/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/content/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/Partial/item.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/partial/item.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/Partial/item.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/partial/item.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/Partial/list.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/partial/list.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/Partial/list.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/partial/list.html.twig index 2b96099c..92b4080f 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/Partial/list.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/partial/list.html.twig @@ -6,7 +6,7 @@ {% for download in downloads %} - {% include toolbox_area_path(areaId, '/Partial/item') with { + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/item') with { 'download': download, 'showPreviewImages' : showPreviewImages, 'showFileInfo' : showFileInfo, diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/view.html.twig similarity index 66% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/view.html.twig index 0e76072c..ae838e4f 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Download/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/download/view.html.twig @@ -1,4 +1,4 @@ -{% include toolbox_area_path(areaId, 'Partial/list') with { +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/list') with { 'editmode': editmode, 'showPreviewImages': pimcore_checkbox('show_preview_images').isChecked(), 'showFileInfo': pimcore_checkbox('show_file_info').isChecked(), diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/Partial/gallery.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/partial/gallery.html.twig similarity index 95% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/Partial/gallery.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/partial/gallery.html.twig index 8fac2a11..17eaf3e5 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/Partial/gallery.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/partial/gallery.html.twig @@ -23,7 +23,7 @@ {% endif %} {% else %} {% if editmode %} -
+
{{ 'No Images for this gallery found.'|trans({}, 'admin') }}
{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/view.html.twig similarity index 84% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/view.html.twig index 427d16f5..e4460b54 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/gallery/view.html.twig @@ -1,4 +1,4 @@ -{% include toolbox_area_path(areaId, 'Partial/gallery') with +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/gallery') with { 'editmode': editmode, 'images': images, diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/infoWindow.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/info-window.html.twig similarity index 90% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/infoWindow.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/info-window.html.twig index 679ae752..2c4cf253 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/infoWindow.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/info-window.html.twig @@ -11,7 +11,7 @@ mapParams['lat'] mapParams['lng'] #} -{% import '@Toolbox/Macro/mapLink.html.twig' as link_generator %} +{% import '@Toolbox/macro/mapLink.html.twig' as link_generator %}
{{ mapParams.title }}
{{ mapParams.street }}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/view.html.twig similarity index 88% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/view.html.twig index 08762af9..3a109005 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/google-map/view.html.twig @@ -1,6 +1,5 @@
{{ pimcore_googlemap('googlemap', { - 'reload' : true, 'mapZoom' : mapZoom, 'mapType' : mapType, 'iwOnInit' : iwOnInit diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Headline/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/headline/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Headline/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/headline/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/Partial/lightbox.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/partial/lightbox.html.twig similarity index 73% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/Partial/lightbox.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/partial/lightbox.html.twig index 8a662ec5..70a2a5a4 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/Partial/lightbox.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/partial/lightbox.html.twig @@ -7,6 +7,6 @@ {{ pimcore_image('ci') }} {% else %} - {% include toolbox_area_path(areaId, '/Partial/single') with { 'class' : 'img-responsive ' ~ class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/single') with { 'class' : 'img-responsive ' ~ class } %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/Partial/single.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/partial/single.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/Partial/single.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/partial/single.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/view.html.twig similarity index 64% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/view.html.twig index 1c562f97..c358f534 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Image/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/image/view.html.twig @@ -3,9 +3,9 @@
{% if useLightBox == true %} - {% include toolbox_area_path(areaId, 'Partial/lightbox') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/lightbox') with { 'class' : class } %} {% else %} - {% include toolbox_area_path(areaId, 'Partial/single') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/single') with { 'class' : class } %} {% endif %} {% if pimcore_checkbox('show_caption').isChecked() == true %} diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/link-list/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/link-list/view.html.twig new file mode 100644 index 00000000..e861502e --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/link-list/view.html.twig @@ -0,0 +1,5 @@ +
    + {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} +
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • + {% endfor %} +
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-prepend.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-prepend.html.twig similarity index 72% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-prepend.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-prepend.html.twig index effc3526..3e272b49 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-prepend.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-prepend.html.twig @@ -1,6 +1,6 @@
- {% include toolbox_area_path(areaId, 'Partial/parallax-content') with { + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/parallax-content') with { 'behindElements' : behindElements, 'frontElements' : frontElements, 'sectionContent' : sectionContent diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-wrap.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-wrap.html.twig similarity index 68% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-wrap.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-wrap.html.twig index fc70fbe8..7ce94dec 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/background-wrap.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/background-wrap.html.twig @@ -1,5 +1,5 @@
- {% include toolbox_area_path(areaId, 'Partial/parallax-content') with { + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/parallax-content') with { 'behindElements' : behindElements, 'frontElements' : frontElements, 'sectionContent' : sectionContent diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/behind-front-elements.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/behind-front-elements.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/behind-front-elements.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/behind-front-elements.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/parallax-content.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/parallax-content.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Partial/parallax-content.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/partial/parallax-content.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/section.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/section.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/section.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/section.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/view.html.twig new file mode 100644 index 00000000..a1317c9a --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/view.html.twig @@ -0,0 +1 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/background-' ~ backgroundMode) %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Wrapper/container-wrapper.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/wrapper/container-wrapper.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/ParallaxContainer/Wrapper/container-wrapper.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/parallax-container/wrapper/container-wrapper.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Separator/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/separator/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Separator/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/separator/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/SlideColumns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/slide-columns/view.html.twig similarity index 90% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/SlideColumns/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/slide-columns/view.html.twig index df6aeef8..d82d4f9a 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/SlideColumns/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/slide-columns/view.html.twig @@ -6,7 +6,7 @@ {{ c }} / {{ slideElements.count }} {% endif %}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %}
{% set c = c+1 %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Spacer/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/spacer/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Spacer/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/spacer/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Teaser/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/teaser/view.html.twig similarity index 88% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Teaser/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/teaser/view.html.twig index 455e0a34..69836885 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Teaser/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/teaser/view.html.twig @@ -4,7 +4,7 @@ {% if layout is empty %} {% set layout = 'standard' %} {% endif %} - {% include '@Toolbox/Snippet/teaser-' ~ layout ~ '.html.twig' %} + {% include '@Toolbox/snippet/teaser-' ~ layout ~ '.html.twig' %} {% else %} {# "teaser-standard" is the snippet name. define your teaser layout in the specific teaser snippet! #} {{ pimcore_snippet('teaser-standard', {'useLightBox' : pimcore_checkbox('use_light_box').isChecked()}) }} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/Partial/overlay.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/partial/overlay.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/Partial/overlay.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/partial/overlay.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-asset.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-asset.html.twig similarity index 74% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-asset.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-asset.html.twig index f5dcbd0f..9b906fe0 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-asset.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-asset.html.twig @@ -11,5 +11,5 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-vimeo.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-vimeo.html.twig similarity index 54% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-vimeo.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-vimeo.html.twig index 6271ac9a..812051e2 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-vimeo.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-vimeo.html.twig @@ -1,4 +1,4 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-youtube.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-youtube.html.twig similarity index 54% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-youtube.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-youtube.html.twig index f652ae37..75a1a938 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/type-youtube.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/type-youtube.html.twig @@ -1,5 +1,5 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/view.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/view.html.twig index 0cb6037a..00f15267 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap3/video/view.html.twig @@ -14,7 +14,7 @@ {% else %}
- {% include toolbox_area_path(areaId, 'type-' ~ videoType) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'type-' ~ videoType) %}
{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/accordion.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/accordion.html.twig similarity index 79% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/accordion.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/accordion.html.twig index e0dd6f0a..f370e17e 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/accordion.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/accordion.html.twig @@ -2,11 +2,11 @@ {% for i in pimcore_iterate_block(panel) %}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/tab.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/tab.html.twig similarity index 92% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/tab.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/tab.html.twig index d822a117..6df7f30c 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/AccordionTab/tab.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/accordion-tab/tab.html.twig @@ -6,14 +6,14 @@ {% if editmode %} {{ pimcore_input('name') }}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
{% else %} {{ pimcore_input('name').data }} {% set content %} - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} {% endset %} {% set tabContent = tabContent|merge([{ 'index': panel.currentIndex, 'content': content}]) %} {% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/Partial/Accordion/title.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/partial/accordion/title.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Accordion/Partial/Accordion/title.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/partial/accordion/title.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/view.html.twig new file mode 100644 index 00000000..4519a4d6 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/accordion/view.html.twig @@ -0,0 +1 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, '/accordion-tab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Anchor/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/anchor/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Anchor/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/anchor/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/areablock.html.twig new file mode 100644 index 00000000..1f49b98e --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/areablock.html.twig @@ -0,0 +1 @@ +{% include '@Toolbox/helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/column.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/column.html.twig similarity index 55% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/column.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/column.html.twig index 33525eca..f1226b3e 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Columns/Partial/column.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/partial/column.html.twig @@ -1,7 +1,7 @@ {% for column in columns %}
- {% include toolbox_area_path(areaId, 'Partial/areablock') with { 'column' : column } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/areablock') with { 'column' : column } %}
{% endfor %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/view.html.twig new file mode 100644 index 00000000..481a2a4a --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/columns/view.html.twig @@ -0,0 +1,7 @@ +{% if type is not empty and partialName is not empty %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/' ~ partialName) %} +{% elseif editmode == true %} +
+ {{ 'No column size selected.'|trans({}, 'admin') }} +
+{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Container/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/container/view.html.twig similarity index 68% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Container/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/container/view.html.twig index 091b15c0..8c32d2f9 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Container/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/container/view.html.twig @@ -1,5 +1,5 @@
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %}
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Content/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/content/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Content/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/content/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/Partial/item.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/partial/item.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Download/Partial/item.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/partial/item.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/partial/list.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/partial/list.html.twig new file mode 100644 index 00000000..d0e9dddf --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/partial/list.html.twig @@ -0,0 +1,15 @@ +{% if downloads is iterable and downloads|length > 0 %} +
+
    + {% for download in downloads %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/item') with { + download: download, + showPreviewImages : showPreviewImages, + showFileInfo : showFileInfo, + } %} + {% endfor %} +
+
+{% elseif editmode == true %} +
{{ 'No downloads defined yet.'|trans({}, 'admin') }}
+{% endif %} diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/view.html.twig new file mode 100644 index 00000000..af28ee8c --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/download/view.html.twig @@ -0,0 +1,5 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/list') with { +editmode: editmode, +showPreviewImages: pimcore_checkbox('show_preview_images').isChecked(), +showFileInfo: pimcore_checkbox('show_file_info').isChecked(), +} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/Partial/gallery.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/partial/gallery.html.twig similarity index 95% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/Partial/gallery.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/partial/gallery.html.twig index 8fac2a11..17eaf3e5 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Gallery/Partial/gallery.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/partial/gallery.html.twig @@ -23,7 +23,7 @@ {% endif %} {% else %} {% if editmode %} -
+
{{ 'No Images for this gallery found.'|trans({}, 'admin') }}
{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/view.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/view.html.twig index bbc206c1..1fd54c10 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Gallery/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/gallery/view.html.twig @@ -1,4 +1,4 @@ -{% include toolbox_area_path(areaId, 'Partial/gallery') with +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/gallery') with { 'editmode': editmode, 'images': images, diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/infoWindow.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/info-window.html.twig similarity index 90% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/infoWindow.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/info-window.html.twig index 9bd8b8f1..fb34f738 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/GoogleMap/infoWindow.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/info-window.html.twig @@ -12,7 +12,7 @@ mapParams['lng'] #} -{% import '@Toolbox/Macro/mapLink.html.twig' as link_generator %} +{% import '@Toolbox/macro/mapLink.html.twig' as link_generator %}
{{ mapParams.title }}
{{ mapParams.street }}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/view.html.twig similarity index 88% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/view.html.twig index 08762af9..3a109005 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/GoogleMap/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/google-map/view.html.twig @@ -1,6 +1,5 @@
{{ pimcore_googlemap('googlemap', { - 'reload' : true, 'mapZoom' : mapZoom, 'mapType' : mapType, 'iwOnInit' : iwOnInit diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Headline/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/headline/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Headline/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/headline/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/IFrame/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/iframe/view.html.twig similarity index 94% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/IFrame/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/iframe/view.html.twig index c2135458..0c111c75 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/IFrame/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/iframe/view.html.twig @@ -2,7 +2,7 @@ {{ 'No iframe url available'|trans({}, 'admin') }} {% else %} {% if isValid == false %} -
+
{{ 'Iframe url is not embedabble since the source does not allow to be included in iframes'|trans({}, 'admin') }} {% if errorMessage != null %}
Error was: "{{ errorMessage }}"
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/lightbox.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/lightbox.html.twig similarity index 76% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/lightbox.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/lightbox.html.twig index 21aeb366..fa1cde10 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/lightbox.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/lightbox.html.twig @@ -7,6 +7,6 @@ {{ pimcore_image('ci') }} {% else %} - {% include toolbox_area_path(areaId, '/Partial/single') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/single') with { 'class' : class } %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/single.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/single.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/single.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/single.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/single_link.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/single_link.html.twig similarity index 72% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/single_link.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/single_link.html.twig index f701cfae..4a171a85 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/Partial/single_link.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/partial/single_link.html.twig @@ -4,6 +4,6 @@ {% set link_element = pimcore_link('image_link') %} {% set link_element_data = link_element.data %} - {% include toolbox_area_path(areaId, '/Partial/single') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/single') with { 'class' : class } %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/view.html.twig similarity index 59% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/view.html.twig index b0c8422f..dc5a81b7 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Image/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/image/view.html.twig @@ -4,11 +4,11 @@
{% if useLightBox == true %} - {% include toolbox_area_path(areaId, 'Partial/lightbox') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/lightbox') with { 'class' : class } %} {% elseif hasLink == true %} - {% include toolbox_area_path(areaId, 'Partial/single_link') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/single_link') with { 'class' : class } %} {% else %} - {% include toolbox_area_path(areaId, 'Partial/single') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/single') with { 'class' : class } %} {% endif %} {% if pimcore_checkbox('show_caption').isChecked() == true %} diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/link-list/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/link-list/view.html.twig new file mode 100644 index 00000000..e861502e --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/link-list/view.html.twig @@ -0,0 +1,5 @@ +
    + {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} +
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • + {% endfor %} +
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-prepend.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-prepend.html.twig similarity index 72% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-prepend.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-prepend.html.twig index fe38581e..2b885e2f 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-prepend.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-prepend.html.twig @@ -1,6 +1,6 @@
- {% include toolbox_area_path(areaId, 'Partial/parallax-content') with { + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/parallax-content') with { 'behindElements' : behindElements, 'frontElements' : frontElements, 'sectionContent' : sectionContent diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-wrap.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-wrap.html.twig similarity index 68% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-wrap.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-wrap.html.twig index 297433ba..5638f5f4 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/background-wrap.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/background-wrap.html.twig @@ -1,5 +1,5 @@
- {% include toolbox_area_path(areaId, 'Partial/parallax-content') with { + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/parallax-content') with { 'behindElements' : behindElements, 'frontElements' : frontElements, 'sectionContent' : sectionContent diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/behind-front-elements.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/behind-front-elements.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/behind-front-elements.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/behind-front-elements.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/parallax-content.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/parallax-content.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Partial/parallax-content.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/partial/parallax-content.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/section.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/section.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/section.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/section.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/view.html.twig new file mode 100644 index 00000000..a1317c9a --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/view.html.twig @@ -0,0 +1 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/background-' ~ backgroundMode) %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Wrapper/container-wrapper.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/wrapper/container-wrapper.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/ParallaxContainer/Wrapper/container-wrapper.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/parallax-container/wrapper/container-wrapper.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Separator/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/separator/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Separator/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/separator/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/SlideColumns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/slide-columns/view.html.twig similarity index 90% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/SlideColumns/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/slide-columns/view.html.twig index d14c1a5a..10951076 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/SlideColumns/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/slide-columns/view.html.twig @@ -6,7 +6,7 @@ {{ c }} / {{ slideElements.count }} {% endif %}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %}
{% set c = c+1 %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Spacer/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/spacer/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Spacer/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/spacer/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Teaser/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/teaser/view.html.twig similarity index 88% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Teaser/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/teaser/view.html.twig index 455e0a34..69836885 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Teaser/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/teaser/view.html.twig @@ -4,7 +4,7 @@ {% if layout is empty %} {% set layout = 'standard' %} {% endif %} - {% include '@Toolbox/Snippet/teaser-' ~ layout ~ '.html.twig' %} + {% include '@Toolbox/snippet/teaser-' ~ layout ~ '.html.twig' %} {% else %} {# "teaser-standard" is the snippet name. define your teaser layout in the specific teaser snippet! #} {{ pimcore_snippet('teaser-standard', {'useLightBox' : pimcore_checkbox('use_light_box').isChecked()}) }} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/Partial/overlay.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/partial/overlay.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/Partial/overlay.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/partial/overlay.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-asset.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-asset.html.twig similarity index 78% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-asset.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-asset.html.twig index e9e962a3..4b31a830 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-asset.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-asset.html.twig @@ -11,5 +11,5 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-vimeo.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-vimeo.html.twig similarity index 65% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-vimeo.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-vimeo.html.twig index 609137e2..d63da520 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-vimeo.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-vimeo.html.twig @@ -1,4 +1,4 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-youtube.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-youtube.html.twig similarity index 65% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-youtube.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-youtube.html.twig index 4126637d..3e8d1760 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Video/type-youtube.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/type-youtube.html.twig @@ -1,5 +1,5 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox' : playInLightbox} %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/view.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/view.html.twig index 0cb6037a..00f15267 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Video/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/bootstrap4/video/view.html.twig @@ -14,7 +14,7 @@ {% else %}
- {% include toolbox_area_path(areaId, 'type-' ~ videoType) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'type-' ~ videoType) %}
{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/accordion.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/accordion.html.twig similarity index 72% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/accordion.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/accordion.html.twig index 5662d491..3f4c0456 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/accordion.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/accordion.html.twig @@ -2,9 +2,9 @@
    {% for i in pimcore_iterate_block(panel) %}
  • - {% include toolbox_area_path(areaId, 'Partial/Accordion/title') %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/accordion/title') %}
    - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
  • {% endfor %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/tab.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/tab.html.twig similarity index 89% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/tab.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/tab.html.twig index 3bf18ddd..1694a72a 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/AccordionTab/tab.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/accordion-tab/tab.html.twig @@ -6,14 +6,14 @@ {% if editmode %} {{ pimcore_input('name') }}
    - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %}
    {% else %} {{ pimcore_input('name').data }} {% set content %} - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'accord', 'type' : 'accordion'} %} {% endset %} {% set tabContent = tabContent|merge([{ 'index': panel.currentIndex, 'content': content}]) %} {% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/Partial/Accordion/title.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/partial/accordion/title.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Accordion/Partial/Accordion/title.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/partial/accordion/title.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/view.html.twig new file mode 100644 index 00000000..4519a4d6 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/accordion/view.html.twig @@ -0,0 +1 @@ +{% include toolbox_area_path(areaId, areaTemplateDirectory, '/accordion-tab/' ~ (pimcore_select('component').data == 'tab' ? 'tab' : 'accordion')) %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Anchor/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/anchor/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Anchor/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/anchor/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/areablock.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/areablock.html.twig new file mode 100644 index 00000000..d5e7c6d7 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/areablock.html.twig @@ -0,0 +1,2 @@ + +{% include '@Toolbox/helper/areablock.html.twig' with {'name': column.name, 'type' : 'columns'} %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/column.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/column.html.twig similarity index 55% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/column.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/column.html.twig index 33525eca..f1226b3e 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap4/Columns/Partial/column.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/partial/column.html.twig @@ -1,7 +1,7 @@ {% for column in columns %}
    - {% include toolbox_area_path(areaId, 'Partial/areablock') with { 'column' : column } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/areablock') with { 'column' : column } %}
    {% endfor %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/view.html.twig new file mode 100644 index 00000000..481a2a4a --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/columns/view.html.twig @@ -0,0 +1,7 @@ +{% if type is not empty and partialName is not empty %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/' ~ partialName) %} +{% elseif editmode == true %} +
    + {{ 'No column size selected.'|trans({}, 'admin') }} +
    +{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Container/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/container/view.html.twig similarity index 69% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Container/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/container/view.html.twig index 0a6e04da..83fb3ab4 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Container/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/container/view.html.twig @@ -1,3 +1,3 @@
    - {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'container-block', 'type' : 'container'} %}
    \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Content/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/content/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Content/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/content/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/Partial/item.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/partial/item.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/Partial/item.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/download/partial/item.html.twig diff --git a/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/partial/list.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/partial/list.html.twig new file mode 100644 index 00000000..7c0e83b3 --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/partial/list.html.twig @@ -0,0 +1,15 @@ +{% if downloads is iterable and downloads|length > 0 %} +
    +
      + {% for download in downloads %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/item') with { + download: download, + showPreviewImages : showPreviewImages, + showFileInfo : showFileInfo, + } %} + {% endfor %} +
    +
    +{% elseif editmode == true %} +
    {{ 'No downloads defined yet.'|trans({}, 'admin') }}
    +{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/view.html.twig similarity index 67% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/download/view.html.twig index 244c83fa..616612e5 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Download/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/download/view.html.twig @@ -1,4 +1,4 @@ -{% include toolbox_area_path(areaId, 'Partial/list') with { +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/list') with { 'editmode': editmode, 'showPreviewImages': pimcore_checkbox('show_preview_images').isChecked(), 'showFileInfo': pimcore_checkbox('show_file_info').isChecked(), diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/Partial/gallery.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/partial/gallery.html.twig similarity index 97% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/Partial/gallery.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/partial/gallery.html.twig index 41b67700..fdd83a29 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/Partial/gallery.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/partial/gallery.html.twig @@ -38,7 +38,7 @@
{% else %} {% if editmode %} -
+
{{ 'No Images for this gallery found.'|trans({}, 'admin') }}
{% endif %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/view.html.twig similarity index 81% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/view.html.twig index bbc206c1..1fd54c10 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Gallery/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/gallery/view.html.twig @@ -1,4 +1,4 @@ -{% include toolbox_area_path(areaId, 'Partial/gallery') with +{% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/gallery') with { 'editmode': editmode, 'images': images, diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/infoWindow.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/info-window.html.twig similarity index 90% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/infoWindow.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/info-window.html.twig index 9bd8b8f1..fb34f738 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/infoWindow.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/info-window.html.twig @@ -12,7 +12,7 @@ mapParams['lng'] #} -{% import '@Toolbox/Macro/mapLink.html.twig' as link_generator %} +{% import '@Toolbox/macro/mapLink.html.twig' as link_generator %}
{{ mapParams.title }}
{{ mapParams.street }}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/view.html.twig similarity index 73% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/view.html.twig index f44fc8d7..7aeb6c27 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/GoogleMap/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/google-map/view.html.twig @@ -1,8 +1,7 @@
{{ pimcore_googlemap('googlemap', { - 'reload' : true, 'mapZoom' : mapZoom, 'mapType' : mapType, - 'iwOnInit' : iwOnInit, + 'iwOnInit' : iwOnInit }) }}
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Headline/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/headline/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Headline/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/headline/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/IFrame/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/iframe/view.html.twig similarity index 91% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/IFrame/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/iframe/view.html.twig index 5a3d725c..dc130d6d 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/IFrame/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/iframe/view.html.twig @@ -2,7 +2,7 @@ {{ 'No iframe url available'|trans({}, 'admin') }} {% else %} {% if isValid == false %} -
+
{{ 'Iframe url is not embedabble since the source does not allow to be included in iframes'|trans({}, 'admin') }} {% if errorMessage != null %}
Error was: "{{ errorMessage }}"
diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/lightbox.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/lightbox.html.twig similarity index 73% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/lightbox.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/lightbox.html.twig index 6e346f3e..6ba90186 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/lightbox.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/lightbox.html.twig @@ -7,6 +7,6 @@ {{ pimcore_image('ci') }} {% else %} - {% include toolbox_area_path(areaId, '/Partial/single') with { 'class' : 'img-fluid ' ~ class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/single') with { 'class' : 'img-fluid ' ~ class } %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/single.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/single.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/single.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/single.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/single_link.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/single_link.html.twig similarity index 59% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/single_link.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/single_link.html.twig index 91abb480..08fce99f 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/Partial/single_link.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/partial/single_link.html.twig @@ -2,6 +2,6 @@ {{ pimcore_image('ci') }} {% else %} - {% include toolbox_area_path(areaId, '/Partial/single') with { 'class' : 'img-fluid ' ~ class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/single') with { 'class' : 'img-fluid ' ~ class } %} {% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/view.html.twig similarity index 59% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/image/view.html.twig index dace6e60..4d333b65 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Image/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/image/view.html.twig @@ -4,11 +4,11 @@
{% if useLightBox == true %} - {% include toolbox_area_path(areaId, 'Partial/lightbox') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/lightbox') with { 'class' : class } %} {% elseif hasLink == true %} - {% include toolbox_area_path(areaId, 'Partial/single_link') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/single_link') with { 'class' : class } %} {% else %} - {% include toolbox_area_path(areaId, 'Partial/single') with { 'class' : class } %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'partial/single') with { 'class' : class } %} {% endif %} {% if pimcore_checkbox('show_caption').isChecked() == true %} diff --git a/src/ToolboxBundle/Resources/views/toolbox/uikit3/link-list/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/link-list/view.html.twig new file mode 100644 index 00000000..50294a3f --- /dev/null +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/link-list/view.html.twig @@ -0,0 +1,5 @@ +
    + {% for i in pimcore_iterate_block(pimcore_block('linklistblock')) %} +
  • {{ pimcore_link('linklist', {'class' : 'list-link'}) }}
  • + {% endfor %} +
\ No newline at end of file diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Separator/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/separator/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Separator/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/separator/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/SlideColumns/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/slide-columns/view.html.twig similarity index 89% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/SlideColumns/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/slide-columns/view.html.twig index fe961620..38136914 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/SlideColumns/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/slide-columns/view.html.twig @@ -7,7 +7,7 @@ {{ c }} / {{ slideElements.count }} {% endif %}
- {% include '@Toolbox/Helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %} + {% include '@Toolbox/helper/areablock.html.twig' with {'name': 'slideCol', 'type' : 'slideColumns'} %}
{% set c = c+1 %} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Spacer/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/spacer/view.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Spacer/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/spacer/view.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Teaser/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/teaser/view.html.twig similarity index 88% rename from src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Teaser/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/teaser/view.html.twig index 455e0a34..69836885 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/Bootstrap3/Teaser/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/teaser/view.html.twig @@ -4,7 +4,7 @@ {% if layout is empty %} {% set layout = 'standard' %} {% endif %} - {% include '@Toolbox/Snippet/teaser-' ~ layout ~ '.html.twig' %} + {% include '@Toolbox/snippet/teaser-' ~ layout ~ '.html.twig' %} {% else %} {# "teaser-standard" is the snippet name. define your teaser layout in the specific teaser snippet! #} {{ pimcore_snippet('teaser-standard', {'useLightBox' : pimcore_checkbox('use_light_box').isChecked()}) }} diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/Partial/overlay.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/partial/overlay.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/Partial/overlay.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/video/partial/overlay.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-asset.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-asset.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-asset.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-asset.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-vimeo.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-vimeo.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-vimeo.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-vimeo.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-youtube.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-youtube.html.twig similarity index 100% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/type-youtube.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/video/type-youtube.html.twig diff --git a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/view.html.twig b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/view.html.twig similarity index 70% rename from src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/view.html.twig rename to src/ToolboxBundle/Resources/views/toolbox/uikit3/video/view.html.twig index f4230915..5410d037 100644 --- a/src/ToolboxBundle/Resources/views/Toolbox/UIkit3/Video/view.html.twig +++ b/src/ToolboxBundle/Resources/views/toolbox/uikit3/video/view.html.twig @@ -15,9 +15,9 @@
{% if posterPath is not empty %} - {% include toolbox_area_path(areaId, '/Partial/overlay') with {'posterPath' : posterPath, 'playInLightbox': playInLightbox} %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, '/partial/overlay') with {'posterPath' : posterPath, 'playInLightbox': playInLightbox} %} {% endif %} - {% include toolbox_area_path(areaId, 'type-' ~ videoType) %} + {% include toolbox_area_path(areaId, areaTemplateDirectory, 'type-' ~ videoType) %}
{% endif %} \ No newline at end of file diff --git a/src/ToolboxBundle/Tool/Install.php b/src/ToolboxBundle/Tool/Install.php index 812453fa..0696ac62 100644 --- a/src/ToolboxBundle/Tool/Install.php +++ b/src/ToolboxBundle/Tool/Install.php @@ -2,134 +2,35 @@ namespace ToolboxBundle\Tool; -use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Migrations\AbortMigrationException; -use Doctrine\DBAL\Migrations\MigrationException; -use Doctrine\DBAL\Migrations\Version; +use Pimcore\Extension\Bundle\Installer\Exception\InstallationException; +use Pimcore\Extension\Bundle\Installer\SettingsStoreAwareInstaller; use Pimcore\Model\Document\DocType; -use Pimcore\Model\Translation\Admin; -use Pimcore\Extension\Bundle\Installer\MigrationInstaller; -use Pimcore\Migrations\Migration\InstallMigration; -use Symfony\Component\Filesystem\Filesystem; +use Pimcore\Model\Translation; -class Install extends MigrationInstaller +class Install extends SettingsStoreAwareInstaller { - const SYSTEM_CONFIG_DIR_PATH = PIMCORE_PRIVATE_VAR . '/bundles/ToolboxBundle'; + public const SYSTEM_CONFIG_DIR_PATH = PIMCORE_PRIVATE_VAR . '/bundles/ToolboxBundle'; - /** - * {@inheritdoc} - */ - public function getMigrationVersion(): string - { - return '00000001'; - } - - /** - * @throws AbortMigrationException - * @throws MigrationException - */ - protected function beforeInstallMigration() - { - $markVersionsAsMigrated = true; - - // legacy: - // we switched from config to migration - // if config.yml exists, this instance needs to migrate - // so every migration needs to run. - // fresh: - // skip all versions since they are not required anymore - // (fresh installation does not require any version migrations) - $fileSystem = new Filesystem(); - if ($fileSystem->exists(self::SYSTEM_CONFIG_DIR_PATH . '/config.yml')) { - $markVersionsAsMigrated = false; - } - - if ($markVersionsAsMigrated === true) { - $migrationConfiguration = $this->migrationManager->getBundleConfiguration($this->bundle); - $this->migrationManager->markVersionAsMigrated($migrationConfiguration->getVersion($migrationConfiguration->getLatestVersion())); - } - - $this->initializeFreshSetup(); - } - - /** - * @param Schema $schema - * @param Version $version - */ - public function migrateInstall(Schema $schema, Version $version) - { - /** @var InstallMigration $migration */ - $migration = $version->getMigration(); - if ($migration->isDryRun()) { - $this->outputWriter->write('DRY-RUN: Skipping installation'); - - return; - } - } - - /** - * @param Schema $schema - * @param Version $version - */ - public function migrateUninstall(Schema $schema, Version $version) - { - /** @var InstallMigration $migration */ - $migration = $version->getMigration(); - if ($migration->isDryRun()) { - $this->outputWriter->write('DRY-RUN: Skipping uninstallation'); - - return; - } - - // currently nothing to do. - } - - /** - * @param string|null $version - * - * @throws AbortMigrationException - */ - protected function beforeUpdateMigration(string $version = null) + public function install(): void { $this->installTranslations(); $this->installDocumentTypes(); - } - /** - * {@inheritdoc} - */ - public function needsReloadAfterInstall() - { - return true; + parent::install(); } - /** - * @throws AbortMigrationException - */ - public function initializeFreshSetup() + private function installTranslations(): void { - $this->installTranslations(); - $this->installDocumentTypes(); - } + $csvAdmin = __DIR__ . '/../Resources/install//admin-translations/data.csv'; - /** - * Imports admin-translations. - * - * @throws AbortMigrationException - */ - private function installTranslations() - { try { - Admin::importTranslationsFromFile($this->getInstallSourcesPath() . '/admin-translations/data.csv', true); + Translation::importTranslationsFromFile($csvAdmin, Translation::DOMAIN_ADMIN, true, \Pimcore\Tool\Admin::getLanguages()); } catch (\Exception $e) { - throw new AbortMigrationException(sprintf('Failed to install admin translations. error was: "%s"', $e->getMessage())); + throw new InstallationException(sprintf('Failed to install admin translations. error was: "%s"', $e->getMessage())); } } - /** - * @throws AbortMigrationException - */ - private function installDocumentTypes() + private function installDocumentTypes(): void { // get list of types $list = new DocType\Listing(); @@ -153,30 +54,17 @@ private function installDocumentTypes() $type = DocType::create(); - $data = [ + $type->setValues([ 'name' => $elementName, - 'module' => 'ToolboxBundle', - 'controller' => 'Snippet', - 'action' => 'teaser', - 'template' => '', + 'controller' => 'ToolboxBundle\Controller\SnippetController::teaserAction', 'type' => 'snippet', 'priority' => 0 - ]; - - $type->setValues($data); + ]); try { $type->getDao()->save(); } catch (\Exception $e) { - throw new AbortMigrationException(sprintf('Failed to save document type "%s". Error was: "%s"', $elementName, $e->getMessage())); + throw new InstallationException(sprintf('Failed to save document type "%s". Error was: "%s"', $elementName, $e->getMessage())); } } - - /** - * @return string - */ - protected function getInstallSourcesPath() - { - return __DIR__ . '/../Resources/install'; - } } diff --git a/src/ToolboxBundle/ToolboxBundle.php b/src/ToolboxBundle/ToolboxBundle.php index 9b59f6c6..5da36459 100644 --- a/src/ToolboxBundle/ToolboxBundle.php +++ b/src/ToolboxBundle/ToolboxBundle.php @@ -4,7 +4,10 @@ use Pimcore\Extension\Bundle\AbstractPimcoreBundle; use Pimcore\Extension\Bundle\Traits\PackageVersionTrait; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; +use ToolboxBundle\DependencyInjection\Compiler\AreaBrickAutoloadWatcherPass; +use ToolboxBundle\DependencyInjection\Compiler\AreaBrickRegistryPass; use ToolboxBundle\DependencyInjection\Compiler\CalculatorRegistryPass; use ToolboxBundle\DependencyInjection\Compiler\MembersBundlePass; use ToolboxBundle\DependencyInjection\Compiler\StoreProviderPass; @@ -14,30 +17,26 @@ class ToolboxBundle extends AbstractPimcoreBundle { use PackageVersionTrait; - const PACKAGE_NAME = 'dachcom-digital/toolbox'; + public const PACKAGE_NAME = 'dachcom-digital/toolbox'; /** * {@inheritdoc} */ public function build(ContainerBuilder $container) { + $container->addCompilerPass(new AreaBrickRegistryPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 255); + $container->addCompilerPass(new AreaBrickAutoloadWatcherPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -255); $container->addCompilerPass(new MembersBundlePass()); $container->addCompilerPass(new CalculatorRegistryPass()); $container->addCompilerPass(new StoreProviderPass()); } - /** - * {@inheritdoc} - */ - public function getInstaller() + public function getInstaller(): Install { return $this->container->get(Install::class); } - /** - * @return string[] - */ - public function getJsPaths() + public function getJsPaths(): array { return [ '/admin/toolbox-ckeditor-object-style.js', @@ -47,66 +46,28 @@ public function getJsPaths() ]; } - /** - * @return string[] - */ - public function getEditmodeJsPaths() + public function getEditmodeJsPaths(): array { - $legacyVersion = version_compare(self::getPimcoreVersion(), '6.8.0', '<'); - - $routeJsPaths = [ - sprintf('/bundles/toolbox/js/document/%s/_route.js', $legacyVersion ? 'tags' : 'editables') - ]; - - $alwaysPaths = [ + return [ '/bundles/toolbox/js/backend/toolbox.js', '/bundles/toolbox/js/toolbox-ckeditor-plugins.js', - '/bundles/toolbox/js/document/editables/dynamiclink.js', + '/bundles/toolbox/js/document/editables/areablock.js', '/bundles/toolbox/js/document/editables/googlemap.js', '/bundles/toolbox/js/document/editables/parallaximage.js', '/bundles/toolbox/js/document/editables/columnadjuster.js', '/bundles/toolbox/js/document/editables/vhs.js', '/bundles/toolbox/js/document/editables/vhs/editor.js', ]; - - $dynamicPaths = $legacyVersion ? [ - '/bundles/toolbox/js/document/tags/areablock.js', - '/bundles/toolbox/js/document/tags/dynamiclink.js', - '/bundles/toolbox/js/document/tags/googlemap.js', - '/bundles/toolbox/js/document/tags/parallaximage.js', - '/bundles/toolbox/js/document/tags/columnadjuster.js', - '/bundles/toolbox/js/document/tags/vhs.js', - ] : [ - '/bundles/toolbox/js/document/editables/areablock.js' - ]; - - return array_merge($routeJsPaths, $alwaysPaths, $dynamicPaths); } - /** - * @return string[] - */ - public function getEditmodeCssPaths() + public function getEditmodeCssPaths(): array { - $cssFiles = [ + return [ '/bundles/toolbox/css/admin.css', '/bundles/toolbox/css/admin_uikit.css' ]; - - if (version_compare(self::getPimcoreVersion(), '5.3.0', '>=')) { - $cssFiles[] = '/bundles/toolbox/css/admin_53.css'; - } - - if (version_compare(self::getPimcoreVersion(), '5.4.4', '>=')) { - $cssFiles[] = '/bundles/toolbox/css/admin_544.css'; - } - - return $cssFiles; } - /** - * {@inheritdoc} - */ protected function getComposerPackageName(): string { return self::PACKAGE_NAME; diff --git a/src/ToolboxBundle/ToolboxConfig.php b/src/ToolboxBundle/ToolboxConfig.php index d56e1823..c259599e 100644 --- a/src/ToolboxBundle/ToolboxConfig.php +++ b/src/ToolboxBundle/ToolboxConfig.php @@ -4,7 +4,7 @@ final class ToolboxConfig { - const TOOLBOX_TYPES = [ + public const TOOLBOX_TYPES = [ 'accordion', 'anchor', 'columns', @@ -27,7 +27,7 @@ final class ToolboxConfig 'video' ]; - const CORE_TYPES = [ + public const CORE_TYPES = [ 'areablock', 'area', 'block', @@ -53,12 +53,11 @@ final class ToolboxConfig 'wysiwyg' ]; - const CUSTOM_TYPES = [ + public const CUSTOM_TYPES = [ 'additionalClasses', 'additionalClassesChained', 'parallaximage', 'googlemap', 'vhs', - 'dynamiclink', ]; } diff --git a/src/ToolboxBundle/Twig/Extension/AreaBlockConfigExtension.php b/src/ToolboxBundle/Twig/Extension/AreaBlockConfigExtension.php index 4bf17f7a..18fe041e 100644 --- a/src/ToolboxBundle/Twig/Extension/AreaBlockConfigExtension.php +++ b/src/ToolboxBundle/Twig/Extension/AreaBlockConfigExtension.php @@ -10,30 +10,16 @@ class AreaBlockConfigExtension extends AbstractExtension { - /** - * @var ConfigManagerInterface - */ - protected $configManager; - - /** - * @var AreaManagerInterface - */ - protected $areaManager; + protected ConfigManagerInterface $configManager; + protected AreaManagerInterface $areaManager; - /** - * @param ConfigManagerInterface $configManager - * @param AreaManagerInterface $areaManager - */ public function __construct(ConfigManagerInterface $configManager, AreaManagerInterface $areaManager) { $this->configManager = $configManager; $this->areaManager = $areaManager; } - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_areablock_config', [$this, 'getAreaBlockConfiguration'], [ @@ -43,17 +29,13 @@ public function getFunctions() } /** - * @param array $context - * @param null $type - * - * @return array - * * @throws \Exception */ - public function getAreaBlockConfiguration($context = [], $type = null) + public function getAreaBlockConfiguration(array $context = [], $type = null): array { $document = $context['document']; + $editMode = $context['editmode'] ?? false; - return $this->areaManager->getAreaBlockConfiguration($type, $document instanceof Snippet); + return $this->areaManager->getAreaBlockConfiguration($type, $document instanceof Snippet, $editMode); } } diff --git a/src/ToolboxBundle/Twig/Extension/CkEditorExtension.php b/src/ToolboxBundle/Twig/Extension/CkEditorExtension.php index 9a031b47..8d87702f 100644 --- a/src/ToolboxBundle/Twig/Extension/CkEditorExtension.php +++ b/src/ToolboxBundle/Twig/Extension/CkEditorExtension.php @@ -8,10 +8,7 @@ class CkEditorExtension extends AbstractExtension { - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_get_ckeditor_config_path', [$this, 'getConfigPath'], [ @@ -20,12 +17,7 @@ public function getFunctions() ]; } - /** - * @param array $context - * - * @return string - */ - public function getConfigPath(array $context) + public function getConfigPath(array $context): string { $document = $context['document']; $documentId = 0; diff --git a/src/ToolboxBundle/Twig/Extension/DataAttributesExtension.php b/src/ToolboxBundle/Twig/Extension/DataAttributesExtension.php index 7aa24ee0..960dbcae 100644 --- a/src/ToolboxBundle/Twig/Extension/DataAttributesExtension.php +++ b/src/ToolboxBundle/Twig/Extension/DataAttributesExtension.php @@ -8,23 +8,14 @@ class DataAttributesExtension extends AbstractExtension { - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected ConfigManagerInterface $configManager; - /** - * @param ConfigManagerInterface $configManager - */ public function __construct(ConfigManagerInterface $configManager) { $this->configManager = $configManager; } - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_data_attributes_generator', [$this, 'generateDataAttributes']), diff --git a/src/ToolboxBundle/Twig/Extension/DocumentTagExtension.php b/src/ToolboxBundle/Twig/Extension/DocumentEditableExtension.php similarity index 68% rename from src/ToolboxBundle/Twig/Extension/DocumentTagExtension.php rename to src/ToolboxBundle/Twig/Extension/DocumentEditableExtension.php index 344735d0..7c4c6c53 100644 --- a/src/ToolboxBundle/Twig/Extension/DocumentTagExtension.php +++ b/src/ToolboxBundle/Twig/Extension/DocumentEditableExtension.php @@ -4,15 +4,12 @@ use Twig\TwigFunction; -class DocumentTagExtension extends \Pimcore\Twig\Extension\DocumentTagExtension +class DocumentEditableExtension extends \Pimcore\Twig\Extension\DocumentEditableExtension { - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ - new TwigFunction('toolbox_document_tag', [$this, 'renderTag'], [ + new TwigFunction('toolbox_document_tag', [$this, 'renderEditable'], [ 'needs_context' => true, 'is_safe' => ['html'], ]), diff --git a/src/ToolboxBundle/Twig/Extension/DownloadExtension.php b/src/ToolboxBundle/Twig/Extension/DownloadExtension.php index 1de848a8..d98d21f5 100644 --- a/src/ToolboxBundle/Twig/Extension/DownloadExtension.php +++ b/src/ToolboxBundle/Twig/Extension/DownloadExtension.php @@ -11,26 +11,10 @@ class DownloadExtension extends AbstractExtension { - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected ConfigManagerInterface $configManager; + protected BundleConnector $bundleConnector; + protected Translator $translator; - /** - * @var BundleConnector - */ - protected $bundleConnector; - - /** - * @var Translator - */ - protected $translator; - - /** - * @param ConfigManagerInterface $configManager - * @param BundleConnector $bundleConnector - * @param Translator $translator - */ public function __construct(ConfigManagerInterface $configManager, BundleConnector $bundleConnector, Translator $translator) { $this->configManager = $configManager; @@ -38,10 +22,7 @@ public function __construct(ConfigManagerInterface $configManager, BundleConnect $this->translator = $translator; } - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_download_info', [$this, 'getDownloadInfo']), @@ -81,7 +62,7 @@ public function getDownloadTracker($areaType, $element = null) $str = 'data-tracking="active" '; - $str .= join(' ', array_map(function ($key) use ($trackerInfo, $element) { + $str .= implode(' ', array_map(function ($key) use ($trackerInfo, $element) { $val = $trackerInfo[$key]; if (is_bool($val)) { @@ -133,23 +114,23 @@ public function getDownloadInfo($download, $showPreviewImage = false, $fileSizeU $dType = \Pimcore\File::getFileExtension($download->getFilename()); $downloadTitle = $showFileNameIfTitleEmpty ? $download->getFilename() : $this->translator->trans('Download', [], 'admin'); - $dName = ($download->getMetadata('title')) ? $download->getMetadata('title') : $downloadTitle; - $dAltText = $download->getMetadata('alt') ? $download->getMetadata('alt') : ''; + $dName = ($download->getMetadata('title')) ?: $downloadTitle; + $dAltText = $download->getMetadata('alt') ?: ''; $dImageAltText = !empty($dAltText) ? $dAltText : $dName; $dPreviewImage = null; $previewThumbName = $this->configManager->getImageThumbnailFromConfig('download_preview_thumbnail'); if ($showPreviewImage) { - $dPreviewImage = $download->getMetadata('previewImage') instanceof Asset\Image - ? $download->getMetadata('previewImage')->getThumbnail($previewThumbName) - : ( - $download instanceof Asset\Image - ? $download->getThumbnail($previewThumbName) - : ($download instanceof Asset\Document - ? $download->getImageThumbnail($previewThumbName) - : null) - ); + /** @var Asset|null $metaPreviewImage */ + $metaPreviewImage = $download->getMetadata('previewImage'); + if ($metaPreviewImage instanceof Asset\Image) { + $dPreviewImage = $metaPreviewImage->getThumbnail($previewThumbName); + } elseif ($download instanceof Asset\Image) { + $dPreviewImage = $download->getThumbnail($previewThumbName); + } elseif ($download instanceof Asset\Document) { + $dPreviewImage = $download->getImageThumbnail($previewThumbName); + } } $dPreviewImagePath = null; diff --git a/src/ToolboxBundle/Twig/Extension/GoogleAPIKeysExtension.php b/src/ToolboxBundle/Twig/Extension/GoogleAPIKeysExtension.php index 0dce5bc2..36491f25 100644 --- a/src/ToolboxBundle/Twig/Extension/GoogleAPIKeysExtension.php +++ b/src/ToolboxBundle/Twig/Extension/GoogleAPIKeysExtension.php @@ -8,20 +8,9 @@ class GoogleAPIKeysExtension extends AbstractExtension { - /** - * @var string - */ - protected $fallbackBrowserKey; - - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected ?string $fallbackBrowserKey; + protected ConfigManagerInterface $configManager; - /** - * @param string|null $fallbackBrowserKey - * @param ConfigManagerInterface $configManager - */ public function __construct( ?string $fallbackBrowserKey, ConfigManagerInterface $configManager @@ -30,10 +19,7 @@ public function __construct( $this->configManager = $configManager; } - /** - * @return array|\Twig_Function[] - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_google_map_api_key', [$this, 'getGoogleMapAPIKey']) @@ -52,7 +38,9 @@ public function getGoogleMapAPIKey() if (!empty($configNode) && isset($configNode['map_api_key']) && !empty($configNode['map_api_key'])) { return $configNode['map_api_key']; - } elseif (!empty($this->fallbackBrowserKey)) { + } + + if (!empty($this->fallbackBrowserKey)) { return $this->fallbackBrowserKey; } diff --git a/src/ToolboxBundle/Twig/Extension/ImageThumbnailExtension.php b/src/ToolboxBundle/Twig/Extension/ImageThumbnailExtension.php index 4d9afd8c..e2c34732 100644 --- a/src/ToolboxBundle/Twig/Extension/ImageThumbnailExtension.php +++ b/src/ToolboxBundle/Twig/Extension/ImageThumbnailExtension.php @@ -8,23 +8,14 @@ class ImageThumbnailExtension extends AbstractExtension { - /** - * @var ConfigManagerInterface - */ - protected $configManager; + protected ConfigManagerInterface $configManager; - /** - * @param ConfigManagerInterface $configManager - */ public function __construct(ConfigManagerInterface $configManager) { $this->configManager = $configManager; } - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_get_image_thumbnail', [$this, 'getImageThumbnail']) diff --git a/src/ToolboxBundle/Twig/Extension/LayoutExtension.php b/src/ToolboxBundle/Twig/Extension/LayoutExtension.php index 3dce12e5..99c5cb15 100644 --- a/src/ToolboxBundle/Twig/Extension/LayoutExtension.php +++ b/src/ToolboxBundle/Twig/Extension/LayoutExtension.php @@ -8,31 +8,22 @@ class LayoutExtension extends AbstractExtension { - /** - * @var LayoutManager - */ - protected $layoutManager; + protected LayoutManager $layoutManager; - /** - * @param LayoutManager $layoutManager - */ public function __construct(LayoutManager $layoutManager) { $this->layoutManager = $layoutManager; } - /** - * {@inheritdoc} - */ - public function getFunctions() + public function getFunctions(): array { return [ new TwigFunction('toolbox_area_path', [$this, 'getAreaPath']) ]; } - public function getAreaPath($areaId, $viewName = 'view') + public function getAreaPath($areaId, $areaTemplateDir, $viewName = 'view'): string { - return $this->layoutManager->getAreaTemplatePath($areaId, $viewName); + return $this->layoutManager->getAreaTemplatePath($areaId, $areaTemplateDir, $viewName); } } diff --git a/tests/_etc/config.yml b/tests/_etc/config.yml index 48ccbfa1..1bc9c045 100644 --- a/tests/_etc/config.yml +++ b/tests/_etc/config.yml @@ -1,8 +1,9 @@ bundles: - { namespace: \ToolboxBundle\ToolboxBundle } setup_files: - - { path: app/config.yml, dest: ./app/config/config.yml } + - { path: app/config.yml, dest: ./config/config.yaml } - { path: app/system.yml, dest: ./var/config/system.yml } - - { path: app/controller/DefaultController.php, dest: ./src/AppBundle/Controller/DefaultController.php } - - { path: app/views/default.html.twig, dest: ./app/Resources/views/Default/default.html.twig } - - { path: app/views/snippet.html.twig, dest: ./app/Resources/views/Default/snippet.html.twig } + - { path: app/image-thumbnails.php, dest: ./var/config/image-thumbnails.php } + - { path: app/controller/DefaultController.php, dest: ./src/Controller/DefaultController.php } + - { path: app/templates/default.html.twig, dest: ./templates/default/default.html.twig } + - { path: app/templates/snippet.html.twig, dest: ./templates/default/snippet.html.twig } diff --git a/tests/_etc/config/app/config.yml b/tests/_etc/config/app/config.yml index f77720bb..e86621e0 100755 --- a/tests/_etc/config/app/config.yml +++ b/tests/_etc/config/app/config.yml @@ -1,22 +1,21 @@ imports: - - { resource: parameters.yml } - - { resource: security.yml } - - { resource: services.yml } + - { resource: services.yaml } - { resource: 'local/' } services: - AppBundle\Controller\DefaultController: + App\Controller\DefaultController: public: true autowire: true autoconfigure: true calls: - [setContainer, ['@service_container']] -# don't send real emails in functional tests -swiftmailer: - disable_delivery: true - framework: profiler: enabled: true - collect: false \ No newline at end of file + collect: false + # don't send real emails in functional tests + mailer: + transports: + main: 'null://null' + newsletter: 'null://null' \ No newline at end of file diff --git a/tests/_etc/config/app/controller/DefaultController.php b/tests/_etc/config/app/controller/DefaultController.php index 7171050e..f55f4b96 100644 --- a/tests/_etc/config/app/controller/DefaultController.php +++ b/tests/_etc/config/app/controller/DefaultController.php @@ -1,23 +1,20 @@ setViewAutoRender($event->getRequest(), true, 'twig'); + return $this->renderTemplate('default/default.html.twig'); } - public function defaultAction(Request $request) - { - } - - public function snippetAction(Request $request) + public function snippetAction(Request $request): Response { + return $this->renderTemplate('default/snippet.html.twig'); } } diff --git a/tests/_etc/config/app/image-thumbnails.php b/tests/_etc/config/app/image-thumbnails.php new file mode 100644 index 00000000..0b4c76b1 --- /dev/null +++ b/tests/_etc/config/app/image-thumbnails.php @@ -0,0 +1,256 @@ + [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "downloadPreviewImage", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1604413615, + "creationDate" => 1604413601, + "forcePictureTag" => FALSE, + "id" => "downloadPreviewImage" + ], + "parallaxImage" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "parallaxImage", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => NULL, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632325543, + "creationDate" => 1632325543, + "preserveAnimation" => FALSE, + "id" => "parallaxImage" + ], + "parallaxSectionBackground" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "parallaxSectionBackground", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "parallaxSectionBackground" + ], + "lightBoxImage" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "lightBoxImage", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "lightBoxImage" + ], + "videoPoster" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "videoPoster", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "videoPoster" + ], + "standardTeaser" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "standardTeaser", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "standardTeaser" + ], + "contentImage" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "contentImage", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "contentImage" + ], + "galleryImage" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "galleryImage", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "galleryImage" + ], + "galleryThumb" => [ + "items" => [ + [ + "method" => "scaleByWidth", + "arguments" => [ + "width" => 500, + "forceResize" => FALSE + ] + ] + ], + "medias" => [ + + ], + "name" => "galleryThumb", + "description" => "", + "group" => "", + "format" => "JPEG", + "quality" => 85, + "highResolution" => 0.0, + "preserveColor" => FALSE, + "preserveMetaData" => FALSE, + "rasterizeSVG" => FALSE, + "downloadable" => FALSE, + "modificationDate" => 1632481410, + "creationDate" => 1632406242, + "preserveAnimation" => FALSE, + "id" => "galleryThumb" + ], +]; diff --git a/tests/_etc/config/app/system.yml b/tests/_etc/config/app/system.yml index 39c61367..45732b19 100755 --- a/tests/_etc/config/app/system.yml +++ b/tests/_etc/config/app/system.yml @@ -3,24 +3,22 @@ pimcore: timezone: Europe/Berlin language: en valid_languages: 'en,de' - path_variable: '' - domain: 'localhost' - redirect_to_maindomain: false fallback_languages: en: '' de: '' + path_variable: '' + domain: 'localhost' + redirect_to_maindomain: false default_language: en disable_usage_statistics: true debug_admin_translations: false instance_identifier: '' - show_cookie_notice: false documents: versions: steps: 10 days: null error_pages: default: /404 - create_redirect_when_moved: false allow_trailing_slash: 'no' generate_preview: false objects: @@ -41,9 +39,9 @@ pimcore: email: '' simple_api_key: '' browser_api_key: '' - cache: + full_page_cache: exclude_cookie: '' - enabled: true + enabled: false lifetime: null exclude_patterns: '' httpclient: @@ -52,29 +50,6 @@ pimcore: proxy_port: '' proxy_user: '' proxy_pass: '' - email: - sender: - name: '' - email: '' - return: - name: '' - email: '' - method: sendmail - debug: - email_addresses: null - newsletter: - sender: - name: '' - email: '' - return: - name: '' - email: '' - method: sendmail - use_specific: false - debug: - email_addresses: null - webservice: - enabled: false applicationlog: mail_notification: send_log_summary: false @@ -82,29 +57,10 @@ pimcore: mail_receiver: '' archive_treshold: '30' archive_alternative_database: '' + delete_archive_threshold: '6' pimcore_admin: branding: color_login_screen: '' color_admin_interface: '' login_screen_custom_image: '' login_screen_invert_colors: false -swiftmailer: - mailers: - pimcore_mailer: - transport: sendmail - delivery_addresses: { } - host: '' - username: '' - password: '' - port: '' - encryption: null - auth_mode: null - newsletter_mailer: - transport: sendmail - delivery_addresses: { } - host: '' - username: '' - password: '' - port: '' - encryption: null - auth_mode: null diff --git a/tests/_etc/config/app/views/default.html.twig b/tests/_etc/config/app/templates/default.html.twig similarity index 100% rename from tests/_etc/config/app/views/default.html.twig rename to tests/_etc/config/app/templates/default.html.twig diff --git a/tests/_etc/config/app/views/snippet.html.twig b/tests/_etc/config/app/templates/snippet.html.twig similarity index 100% rename from tests/_etc/config/app/views/snippet.html.twig rename to tests/_etc/config/app/templates/snippet.html.twig diff --git a/tests/_etc/config/bundle/config_default.yml b/tests/_etc/config/bundle/config_default.yml index 22e781dc..0e38536b 100755 --- a/tests/_etc/config/bundle/config_default.yml +++ b/tests/_etc/config/bundle/config_default.yml @@ -3,19 +3,15 @@ toolbox: grid: grid_size: 12 breakpoints: - - - identifier: 'xs' + - identifier: 'xs' name: 'Breakpoint: XS' description: 'Your Description' - - - identifier: 'sm' + - identifier: 'sm' name: 'Breakpoint: SM' description: 'Your Description' - - - identifier: 'md' + - identifier: 'md' name: 'Breakpoint: MD' description: 'Your Description' - - - identifier: 'lg' + - identifier: 'lg' name: 'Breakpoint: LG' description: 'Your Description' diff --git a/tests/_support/Services/ContextResolverTestClass.php b/tests/_support/Services/ContextResolverTestClass.php index fe8125ea..939ae684 100644 --- a/tests/_support/Services/ContextResolverTestClass.php +++ b/tests/_support/Services/ContextResolverTestClass.php @@ -4,15 +4,12 @@ use ToolboxBundle\Resolver\ContextResolverInterface; -/** - * @group dataTypeOut - */ class ContextResolverTestClass implements ContextResolverInterface { - public function getCurrentContextIdentifier() + public function getCurrentContextIdentifier(): ?string { $requestStack = \Pimcore::getContainer()->get('request_stack'); - $mainRequest = $requestStack->getMasterRequest(); + $mainRequest = $requestStack->getMainRequest(); if ($mainRequest->query->has('mock_toolbox_context')) { if ($mainRequest->query->get('mock_toolbox_context') === 'disabled') { diff --git a/tests/acceptance.default/AreaPositionCest.php b/tests/acceptance.default/AreaPositionCest.php index 3366af6d..7c35ef64 100644 --- a/tests/acceptance.default/AreaPositionCest.php +++ b/tests/acceptance.default/AreaPositionCest.php @@ -42,15 +42,17 @@ public function testAreaButtonsPosition(AcceptanceTester $I) $I->submitForm('form', ['username' => 'backendTester', 'password' => 'backendTester']); // wait for pimcore gui - $I->waitForElement('div#pimcore_panel_tree_objects', 20); + $I->waitForElement('div#pimcore_panel_tree_objects', 30); // wait for document gui $I->waitForElement('div.x-panel .x-tab-inner', 20); // switch to document edit iframe $I->switchToIFrame('document_iframe_' . $document->getId()); // wait for input element - $I->waitForElement('.toolbox-element.toolbox-headline .pimcore_tag_input', 10); + $I->waitForElement('.toolbox-element.toolbox-headline .pimcore_editable_input', 10); + // focus input + $I->clickWithLeftButton('.toolbox-element.toolbox-headline .pimcore_editable_input'); // click "add element above" symbol in area buttons block - $I->clickWithLeftButton('.toolbox-element.toolbox-headline .pimcore_tag_input', 5, -75); + $I->clickWithLeftButton('.pimcore_icon_plus_up'); // i want to see an dropdown containing "accordion" $I->waitForText('Accordion', 10, '.x-menu .x-menu-item'); } diff --git a/tests/functional.default/Controller/SnippetControllerCest.php b/tests/functional.default/Controller/SnippetControllerCest.php index 3af5aeee..f3f984cb 100644 --- a/tests/functional.default/Controller/SnippetControllerCest.php +++ b/tests/functional.default/Controller/SnippetControllerCest.php @@ -12,9 +12,8 @@ class SnippetControllerCest public function testSnippetController(FunctionalTester $I) { $snippetParams = [ - 'module' => 'ToolboxBundle', - 'controller' => 'Snippet', - 'action' => 'teaser' + 'controller' => 'ToolboxBundle\Controller\SnippetController', + 'action' => 'teaserAction' ]; $I->haveAUserWithAdminRights('dachcom_test'); @@ -32,9 +31,8 @@ public function testSnippetController(FunctionalTester $I) public function testSnippetWithDefaultTeaserController(FunctionalTester $I) { $snippetParams = [ - 'module' => 'ToolboxBundle', - 'controller' => 'Snippet', - 'action' => 'teaser' + 'controller' => 'ToolboxBundle\Controller\SnippetController', + 'action' => 'teaserAction' ]; $snippetEditables = [ @@ -73,6 +71,6 @@ public function testSnippetWithDefaultTeaserController(FunctionalTester $I) $I->seeElement('.single-teaser.default'); $I->seeElement('.teaser-headline'); $I->seeElement('.teaser-text'); - $I->seeElement('.pimcore_tag_link'); + $I->seeElement('.pimcore_editable_link'); } } diff --git a/tests/unit.default/Areas/AbstractAreaTest.php b/tests/unit.default/Areas/AbstractAreaTest.php index 5ecdc19c..7079cf93 100644 --- a/tests/unit.default/Areas/AbstractAreaTest.php +++ b/tests/unit.default/Areas/AbstractAreaTest.php @@ -4,9 +4,9 @@ use Codeception\Exception\ModuleException; use Dachcom\Codeception\Test\BundleTestCase; -use Dachcom\Codeception\Util\VersionHelper; -use Pimcore\Document\Editable\EditableHandlerInterface; -use Pimcore\Model\Document\Tag\Area; +use Pimcore\Extension\Document\Areabrick\EditableDialogBoxConfiguration; +use Pimcore\Model\Document\Editable; +use Pimcore\Model\Document\Editable\Area; use Pimcore\Tests\Util\TestHelper; use Symfony\Component\HttpFoundation\Request; use ToolboxBundle\Builder\BrickConfigBuilder; @@ -28,109 +28,102 @@ public function getToolboxConfig() } /** - * @param $id - * @param $documentElements - * @param array $infoParams + * @param string $id + * @param array $editables + * @param array $infoParams * * @return string */ - public function generateRenderedArea($id, $documentElements, $infoParams = []) + public function generateRenderedArea($id, $editables, $infoParams = []) { - $info = $this->generateAreaInfo($id, $infoParams); - $info->getView()->getParameters()->add(['editmode' => false]); - $info->getTag()->getView()->get('document')->setElements($documentElements); + $index = 1; + + $document = TestHelper::createEmptyDocumentPage('', false); + $document->setMissingRequiredEditable(false); + + $blockData = []; + $blockData[] = [ + 'key' => $index, + 'type' => $id, + 'hidden' => false + ]; + + $infoParams['document'] = $document; + $infoParams['editmode'] = false; + + $area = new Editable\Areablock(); + $area->setName('test'); + $area->setRealName('test'); + $area->setDocument($document); + $area->setEditmode(false); + $area->setDataFromResource(serialize($blockData)); + $area->setConfig([ + 'indexes' => [], + 'globalParams' => $infoParams + ]); - return $this->getAreaOutput($info); - } + $editables[] = $area; - /** - * @param $id - * - * @return mixed - * @throws \Exception - */ - public function generateBackendArea($id) - { - $info = $this->generateAreaInfo($id); - $info->getView()->getParameters()->add(['editmode' => true]); + $indexedEditables = []; - $builder = $this->getContainer()->get(BrickConfigBuilder::class); - $configManager = $this->getContainer()->get(ConfigManager::class); - $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL); + foreach ($editables as $editableName => $editable) { - $configNode = $configManager->getAreaConfig($info->getId()); - $themeOptions = $configManager->getConfig('theme'); + if ($editable instanceof Editable\Areablock) { + $indexedEditables[$editable->getName()] = $editable; + continue; + } - return $builder->buildElementConfigArguments($info->getId(), $info->getTag()->getName(), $info, $configNode, $themeOptions); + $key = sprintf('test:%d.%s', $index, $editableName); + + $editable->setName($key); + $indexedEditables[$key] = $editable; + } + + $document->setEditables($indexedEditables); + + return $area->renderIndex(0, true); } /** - * @param $id - * @param array $infoParams + * @param string $id * - * @return Area\Info + * @return EditableDialogBoxConfiguration + * @throws \Exception */ - public function generateAreaInfo($id, $infoParams = []) + public function generateBackendArea($id) { - $document = TestHelper::createEmptyDocumentPage('', true); - - if (VersionHelper::pimcoreVersionIsGreaterOrEqualThan('6.8.0')) { - $areaClass = '\Pimcore\Model\Document\Editable\Area'; - $infoClass = '\Pimcore\Model\Document\Editable\Area\Info'; - } else { - $areaClass = '\Pimcore\Model\Document\Tag\Area'; - $infoClass = '\Pimcore\Model\Document\Tag\Area\Info'; - } - - $view = new \Pimcore\Templating\Model\ViewModel([ - 'editmode' => false, - 'document' => $document - ]); + $document = TestHelper::createEmptyDocumentPage('', false); + $document->setMissingRequiredEditable(false); - $area = new $areaClass(); + $area = new Area(); $area->setName($id); - $area->setView($view); + $area->setDocument($document); - $info = new $infoClass(); + $info = new Area\Info(); $info->setId($id); $info->setIndex(1); - $info->setParams($infoParams); - $info->setTag($area); - $info->setView($view); - - return $info; - } - - /** - * @param Area\Info $info - * - * @return string - */ - public function getAreaOutput(Area\Info $info) - { - if (VersionHelper::pimcoreVersionIsGreaterOrEqualThan('6.8.0')) { - $tagHandler = \Pimcore::getContainer()->get(EditableHandlerInterface::class); - } else { - $tagHandler = \Pimcore::getContainer()->get('pimcore.document.tag.handler'); - } + $info->setParams(['editmode' => true]); + $info->setEditable($area); - ob_start(); - $tagHandler->renderAreaFrontend($info); - $output = ob_get_contents(); - ob_end_clean(); + $builder = $this->getContainer()->get(BrickConfigBuilder::class); + $configManager = $this->getContainer()->get(ConfigManager::class); + $configManager->setAreaNameSpace(ConfigManagerInterface::AREABRICK_NAMESPACE_INTERNAL); - return $output; + $configNode = $configManager->getAreaConfig($info->getId()); + $themeOptions = $configManager->getConfig('theme'); + return $builder->buildDialogBoxConfiguration($info, $info->getId(), $configNode, $themeOptions)->getItems(); } /** - * @param $output + * @param string $output * * @return string */ public function filter($output) { $output = preg_replace('/\r|\n/', '', $output); + return trim(preg_replace('/(\>)\s*(\<)/m', '$1$2', $output)); } diff --git a/tests/unit.default/Areas/AccordionTest.php b/tests/unit.default/Areas/AccordionTest.php index 1618976a..3efe19b5 100644 --- a/tests/unit.default/Areas/AccordionTest.php +++ b/tests/unit.default/Areas/AccordionTest.php @@ -2,25 +2,24 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Select; +use Pimcore\Model\Document\Editable\Select; class AccordionTest extends AbstractAreaTest { - const TYPE = 'accordion'; + public const TYPE = 'accordion'; public function testAccordionBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(2, $configElements); - $this->assertEquals('select', $configElements[0]['additional_config']['type']); - $this->assertEquals('type', $configElements[0]['additional_config']['name']); + $this->assertEquals('select', $configElements[0]['type']); + $this->assertEquals('type', $configElements[0]['name']); - $this->assertEquals('select', $configElements[1]['additional_config']['type']); - $this->assertEquals('component', $configElements[1]['additional_config']['name']); + $this->assertEquals('select', $configElements[1]['type']); + $this->assertEquals('component', $configElements[1]['name']); } public function testAccordion() diff --git a/tests/unit.default/Areas/AnchorTest.php b/tests/unit.default/Areas/AnchorTest.php index 7ed6f310..cc844e9e 100644 --- a/tests/unit.default/Areas/AnchorTest.php +++ b/tests/unit.default/Areas/AnchorTest.php @@ -2,7 +2,7 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Input; +use Pimcore\Model\Document\Editable\Input; class AnchorTest extends AbstractAreaTest { @@ -12,15 +12,14 @@ public function testAnchorBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(2, $configElements); - $this->assertEquals('input', $configElements[0]['additional_config']['type']); - $this->assertEquals('anchor_name', $configElements[0]['additional_config']['name']); + $this->assertEquals('input', $configElements[0]['type']); + $this->assertEquals('anchor_name', $configElements[0]['name']); - $this->assertEquals('input', $configElements[1]['additional_config']['type']); - $this->assertEquals('anchor_title', $configElements[1]['additional_config']['name']); + $this->assertEquals('input', $configElements[1]['type']); + $this->assertEquals('anchor_title', $configElements[1]['name']); } public function testAccordion() diff --git a/tests/unit.default/Areas/ColumnsTest.php b/tests/unit.default/Areas/ColumnsTest.php index 59553964..a9f449fe 100644 --- a/tests/unit.default/Areas/ColumnsTest.php +++ b/tests/unit.default/Areas/ColumnsTest.php @@ -2,30 +2,29 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Model\Document\Tag\Select; -use ToolboxBundle\Model\Document\Tag\ColumnAdjuster; +use Pimcore\Model\Document\Editable\Checkbox; +use Pimcore\Model\Document\Editable\Select; +use ToolboxBundle\Model\Document\Editable\ColumnAdjuster; class ColumnsTest extends AbstractAreaTest { - const TYPE = 'columns'; + public const TYPE = 'columns'; public function testColumnsBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(3, $configElements); - $this->assertEquals('select', $configElements[0]['additional_config']['type']); - $this->assertEquals('type', $configElements[0]['additional_config']['name']); + $this->assertEquals('select', $configElements[0]['type']); + $this->assertEquals('type', $configElements[0]['name']); - $this->assertEquals('columnadjuster', $configElements[1]['additional_config']['type']); - $this->assertEquals('columnadjuster', $configElements[1]['additional_config']['name']); + $this->assertEquals('columnadjuster', $configElements[1]['type']); + $this->assertEquals('columnadjuster', $configElements[1]['name']); - $this->assertEquals('checkbox', $configElements[2]['additional_config']['type']); - $this->assertEquals('equal_height', $configElements[2]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[2]['type']); + $this->assertEquals('equal_height', $configElements[2]['name']); } public function testDefaultColumns() diff --git a/tests/unit.default/Areas/ContainerTest.php b/tests/unit.default/Areas/ContainerTest.php index 6dd5aebf..4888084f 100644 --- a/tests/unit.default/Areas/ContainerTest.php +++ b/tests/unit.default/Areas/ContainerTest.php @@ -2,26 +2,22 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Model\Document\Tag\Image; -use Pimcore\Model\Document\Tag\Link; -use Pimcore\Model\Document\Tag\Select; -use Pimcore\Tests\Util\TestHelper; +use Pimcore\Model\Document\Editable\Checkbox; +use Pimcore\Model\Document\Editable\Select; class ContainerTest extends AbstractAreaTest { - const TYPE = 'container'; + public const TYPE = 'container'; public function testContainerBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(1, $configElements); - $this->assertEquals('checkbox', $configElements[0]['additional_config']['type']); - $this->assertEquals('full_width_container', $configElements[0]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[0]['type']); + $this->assertEquals('full_width_container', $configElements[0]['name']); } public function testImage() diff --git a/tests/unit.default/Areas/ContentTest.php b/tests/unit.default/Areas/ContentTest.php index d4d3f525..05651dbc 100644 --- a/tests/unit.default/Areas/ContentTest.php +++ b/tests/unit.default/Areas/ContentTest.php @@ -2,18 +2,17 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Select; +use Pimcore\Model\Document\Editable\Select; class ContentTest extends AbstractAreaTest { - const TYPE = 'content'; + public const TYPE = 'content'; public function testContentBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(0, $configElements); } diff --git a/tests/unit.default/Areas/DownloadTest.php b/tests/unit.default/Areas/DownloadTest.php index c78869bf..4dde35af 100644 --- a/tests/unit.default/Areas/DownloadTest.php +++ b/tests/unit.default/Areas/DownloadTest.php @@ -2,31 +2,30 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Model\Document\Tag\Relations; -use Pimcore\Model\Document\Tag\Select; +use Pimcore\Model\Document\Editable\Checkbox; +use Pimcore\Model\Document\Editable\Relations; +use Pimcore\Model\Document\Editable\Select; use Pimcore\Tests\Util\TestHelper; class DownloadTest extends AbstractAreaTest { - const TYPE = 'download'; + public const TYPE = 'download'; public function testDownloadBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(3, $configElements); - $this->assertEquals('relations', $configElements[0]['additional_config']['type']); - $this->assertEquals('downloads', $configElements[0]['additional_config']['name']); + $this->assertEquals('relations', $configElements[0]['type']); + $this->assertEquals('downloads', $configElements[0]['name']); - $this->assertEquals('checkbox', $configElements[1]['additional_config']['type']); - $this->assertEquals('show_preview_images', $configElements[1]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[1]['type']); + $this->assertEquals('show_preview_images', $configElements[1]['name']); - $this->assertEquals('checkbox', $configElements[2]['additional_config']['type']); - $this->assertEquals('show_file_info', $configElements[2]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[2]['type']); + $this->assertEquals('show_file_info', $configElements[2]['name']); } public function testDownload() @@ -86,7 +85,7 @@ public function testDownloadWithPreviewImage() ]; $this->assertEquals( - $this->filter($this->getCompareWithPreviewImage($asset1->getFullPath(), $asset2->getFullPath())), + $this->filter($this->getCompareWithPreviewImage($asset1, $asset2)), $this->filter($this->generateRenderedArea(self::TYPE, $elements)) ); } @@ -177,20 +176,20 @@ private function getCompare($path1, $path2)
'; } - private function getCompareWithPreviewImage($path1, $path2) + private function getCompareWithPreviewImage($asset1, $asset2) { return '
  • - - Download + + Download Download
  • - - Download + + Download Download
  • diff --git a/tests/unit.default/Areas/GalleryTest.php b/tests/unit.default/Areas/GalleryTest.php index 2842f31e..336f75b6 100644 --- a/tests/unit.default/Areas/GalleryTest.php +++ b/tests/unit.default/Areas/GalleryTest.php @@ -2,31 +2,30 @@ namespace DachcomBundle\Test\UnitDefault\Areas; -use Pimcore\Model\Document\Tag\Checkbox; -use Pimcore\Model\Document\Tag\Relations; -use Pimcore\Model\Document\Tag\Select; +use Pimcore\Model\Document\Editable\Checkbox; +use Pimcore\Model\Document\Editable\Relations; +use Pimcore\Model\Document\Editable\Select; use Pimcore\Tests\Util\TestHelper; class GalleryTest extends AbstractAreaTest { - const TYPE = 'gallery'; + public const TYPE = 'gallery'; public function testGalleryBackendConfig() { $this->setupRequest(); - $areaConfig = $this->generateBackendArea(self::TYPE); - $configElements = $areaConfig['config_elements']; + $configElements = $this->generateBackendArea(self::TYPE); $this->assertCount(3, $configElements); - $this->assertEquals('relations', $configElements[0]['additional_config']['type']); - $this->assertEquals('images', $configElements[0]['additional_config']['name']); + $this->assertEquals('relations', $configElements[0]['type']); + $this->assertEquals('images', $configElements[0]['name']); - $this->assertEquals('checkbox', $configElements[1]['additional_config']['type']); - $this->assertEquals('use_light_box', $configElements[1]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[1]['type']); + $this->assertEquals('use_light_box', $configElements[1]['name']); - $this->assertEquals('checkbox', $configElements[2]['additional_config']['type']); - $this->assertEquals('use_thumbnails', $configElements[2]['additional_config']['name']); + $this->assertEquals('checkbox', $configElements[2]['type']); + $this->assertEquals('use_thumbnails', $configElements[2]['name']); } public function testGallery() @@ -53,7 +52,7 @@ public function testGallery() ]; $this->assertEquals( - $this->filter($this->getCompare($asset1->getFullPath(), $asset2->getFullPath())), + $this->filter($this->getCompare($asset1, $asset2)), $this->filter($this->generateRenderedArea(self::TYPE, $elements, ['toolboxGalleryId' => 'test'])) ); } @@ -86,7 +85,7 @@ public function testGalleryWithLightBox() ]; $this->assertEquals( - $this->filter($this->getCompareWithLightBox($asset1->getFullPath(), $asset2->getFullPath())), + $this->filter($this->getCompareWithLightBox($asset1, $asset2)), $this->filter($this->generateRenderedArea(self::TYPE, $elements, ['toolboxGalleryId' => 'test'])) ); } @@ -119,7 +118,7 @@ public function testGalleryWithThumbnails() ]; $this->assertEquals( - $this->filter($this->getCompareWithThumbnails($asset1->getFullPath(), $asset2->getFullPath())), + $this->filter($this->getCompareWithThumbnails($asset1, $asset2)), $this->filter($this->generateRenderedArea(self::TYPE, $elements, ['toolboxGalleryId' => 'test'])) ); } @@ -157,17 +156,17 @@ public function testGalleryWithAdditionalClass() ); } - private function getCompare($path1, $path2) + private function getCompare(\Pimcore\Model\Asset\Image $asset1, \Pimcore\Model\Asset\Image $asset2) { return '