Skip to content

Commit b92395e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-95532
2 parents c08bdbd + 9450fa6 commit b92395e

File tree

574 files changed

+20643
-16696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

574 files changed

+20643
-16696
lines changed
Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Contributing to Magento 2 code
22

3+
<!--{% comment %}-->
34
## Navigation
45

56
1. [Introduction]
@@ -13,34 +14,14 @@
1314
5. [Roadmap and known issues]
1415
6. [How to create custom PageBuilder content type container]
1516

16-
[Introduction]: README.md
17-
[Contribution guide]: CONTRIBUTING.md
18-
[Installation guide]: install.md
19-
[Developer documentation]: developer-documentation.md
20-
[Architecture overview]: architecture-overview.md
21-
[BlueFoot to PageBuilder data migration]: bluefoot-data-migration.md
22-
[Third-party content type migration]: new-content-type-example.md
23-
[Iconography]: iconography.md
24-
[Add image uploader to content type]: image-uploader.md
25-
[Module integration]: module-integration.md
26-
[Additional data configuration]: custom-configuration.md
27-
[Content type configuration]: content-type-configuration.md
28-
[How to add a new content type]: how-to-add-new-content-type.md
29-
[Events]: events.md
30-
[Bindings]: bindings.md
31-
[Master format]: master-format.md
32-
[Visual select]: visual-select.md
33-
[Reuse product conditions in content types]: product-conditions.md
34-
[Store component master format as widget directive]: widget-directive.md
35-
[Use the block chooser UI component]: block-chooser-component.md
36-
[Use the inline text editing component]: inline-editing-component.md
37-
[Render a backend content type preview]: content-type-preview.md
38-
[Custom Toolbar]: toolbar.md
39-
[Full width page layouts]: full-width-page-layouts.md
40-
[Add custom logic to content types]: add-custom-logic.md
41-
[Roadmap and Known Issues]: roadmap.md
42-
[How to create custom PageBuilder content type container]: how-to-create-custom-content-type-container.md
17+
[Introduction]: docs/introduction.md
18+
[Installation guide]: docs/install.md
19+
[Developer documentation]: docs/developer-documentation.md
20+
[Roadmap and Known Issues]: docs/roadmap.md
21+
[How to create custom PageBuilder content type container]: docs/how-to-create-custom-content-type-container.md
22+
<!--{% endcomment %}-->
4323

24+
<!-- {% raw %} -->
4425
## Overview
4526

4627
Contributions to the Magento 2 codebase are done using the fork & pull model.
@@ -67,8 +48,8 @@ The Magento 2 development team will review all issues and contributions submitte
6748

6849
If you are a new GitHub user, we recommend that you create your own [free github account](https://github.com/signup/free). By doing that, you will be able to collaborate with the Magento 2 development team, “fork” the Magento 2 project and be able to easily send “pull requests”.
6950

70-
1. Search current [listed issues](https://github.com/magento/magento2-page-builder/issues) on GitHub (open or closed) and [list of known issues](roadmap.md#Known Issues) on our roadmap for similar proposals of intended contribution before starting work on a new contribution.
71-
2. Please contact us in Slack chanel if you want to work on issue from [list of known issues](roadmap.md#Known Issues).
51+
1. Search current [listed issues](https://github.com/magento/magento2-page-builder/issues) on GitHub (open or closed) and [list of known issues](docs/roadmap.md#Known Issues) on our roadmap for similar proposals of intended contribution before starting work on a new contribution.
52+
2. Please contact us in Slack chanel if you want to work on issue from [list of known issues](docs/roadmap.md#Known Issues).
7253
2. Review the [Contributor License Agreement](https://magento.com/legaldocuments/mca) if this is your first time contributing.
7354
3. Create and test your work.
7455
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request). Instructions written for `https://github.com/magento/magento2` repository, but they also apply to `https://github.com/magento/magento2-page-builder`.
@@ -78,3 +59,5 @@ If you are a new GitHub user, we recommend that you create your own [free github
7859

7960
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
8061
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).
62+
63+
<!-- {% endraw %} -->

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# magento2-page-builder
22

3+
<!-- {% raw %} -->
4+
35
## PageBuilder Early Access Program
46

57
The PageBuilder Early Access Program (EAP) gives partners the following perks:
@@ -13,13 +15,13 @@ The PageBuilder Early Access Program (EAP) gives partners the following perks:
1315

1416
## Installation
1517

16-
We offer two methods for installing PageBuilder:
18+
We offer one method for installing PageBuilder:
19+
1720

18-
* As a [Composer package] - use this option if you do not plan to contribute to the PageBuilder code repository
1921
* Using the [GitHub repository] - use this option to install PageBuilder from the GitHub repository and contribute to the code
2022

21-
[Composer package]: app/code/Magento/PageBuilder/docs/install.md#composer-installation
22-
[GitHub repository]: app/code/Magento/PageBuilder/docs/install.md#github-installation
23+
[Composer package]: docs/install.md#composer-installation
24+
[GitHub repository]: docs/install.md#github-installation
2325

2426
## Developer documentation
2527

@@ -39,19 +41,19 @@ This project repository contains PageBuilder developer documentation on the foll
3941
1. [Visual select]
4042
1. [Custom Toolbar]
4143

42-
[Architecture overview]: app/code/Magento/PageBuilder/docs/architecture-overview.md
43-
[BlueFoot to PageBuilder data migration]: app/code/Magento/PageBuilder/docs/bluefoot-data-migration.md
44-
[Third-party content type migration]: app/code/Magento/PageBuilder/docs/new-content-type-example.md
45-
[Iconography]: app/code/Magento/PageBuilder/docs/iconography.md
46-
[Module integration]: app/code/Magento/PageBuilder/docs/module-integration.md
47-
[Additional data configuration]: app/code/Magento/PageBuilder/docs/custom-configuration.md
48-
[Content type configuration]: app/code/Magento/PageBuilder/docs/content-type-configuration.md
49-
[How to add a new content type]: app/code/Magento/PageBuilder/docs/how-to-add-new-content-type.md
50-
[Events]: app/code/Magento/PageBuilder/docs/events.md
51-
[Bindings]: app/code/Magento/PageBuilder/docs/bindings.md
52-
[Master format]: app/code/Magento/PageBuilder/docs/master-format.md
53-
[Visual select]: app/code/Magento/PageBuilder/docs/visual-select.md
54-
[Custom Toolbar]: app/code/Magento/PageBuilder/docs/toolbar.md
44+
[Architecture overview]: docs/architecture-overview.md
45+
[BlueFoot to PageBuilder data migration]: docs/bluefoot-data-migration.md
46+
[Third-party content type migration]: docs/new-content-type-example.md
47+
[Iconography]: docs/iconography.md
48+
[Module integration]: docs/module-integration.md
49+
[Additional data configuration]: docs/custom-configuration.md
50+
[Content type configuration]: docs/content-type-configuration.md
51+
[How to add a new content type]: docs/how-to-add-new-content-type.md
52+
[Events]: docs/events.md
53+
[Bindings]: docs/bindings.md
54+
[Master format]: docs/master-format.md
55+
[Visual select]: docs/visual-select.md
56+
[Custom Toolbar]: docs/toolbar.md
5557

5658
## Contribute to PageBuilder
5759

@@ -60,9 +62,9 @@ A good place to start is by looking at our [features roadmap] and list of [known
6062

6163
If you are interested in contributing to this repository, please see our [Contribution Guide].
6264

63-
[Contribution Guide]: app/code/Magento/PageBuilder/docs/CONTRIBUTING.md
64-
[features roadmap]: app/code/Magento/PageBuilder/docs/roadmap.md#planned-features-and-functionality
65-
[known issues]: app/code/Magento/PageBuilder/docs/roadmap.md#known-issues
65+
[Contribution Guide]: CONTRIBUTING.md
66+
[features roadmap]: docs/roadmap.md#planned-features-and-functionality
67+
[known issues]: docs/roadmap.md#known-issues
6668

6769
## PageBuilder updates from the Magento core team
6870

@@ -71,7 +73,7 @@ The PageBuilder team updates the code every 2 weeks.
7173

7274
To help you prepare for these changes, we are publishing a [roadmap] of features and issues that we are going to work on in the following months.
7375

74-
[roadmap]: app/code/Magento/PageBuilder/docs/roadmap.md
76+
[roadmap]: docs/roadmap.md
7577

7678
## Provide feedback
7779

@@ -86,4 +88,6 @@ To participate in technical discussions and ask questions, join us in [Slack].
8688
For all other questions or requests, contact [Olena Tkacheva].
8789

8890
[Slack]: https://magentocommeng.slack.com/
89-
[Olena Tkacheva]: https://magentocommeng.slack.com/messages/@UAFV915FB
91+
[Olena Tkacheva]: https://magentocommeng.slack.com/messages/@UAFV915FB
92+
93+
<!-- {% endraw %} -->

app/code/Magento/PageBuilder/Block/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private function getConfig(): array
5252
{
5353
$formNamespace = $this->getData('formNamespace');
5454
$attribute = $this->getData('attribute');
55+
$jsObjectName = $formNamespace . '_' . $attribute;
5556

5657
return [
5758
'formNamespace' => $formNamespace,
@@ -60,14 +61,16 @@ private function getConfig(): array
6061
[
6162
'form_namespace' => $formNamespace,
6263
'prefix' => $attribute,
64+
'js_object_name' => $jsObjectName,
6365
]
6466
),
65-
'jsObjectName' => $formNamespace . '_' . $attribute,
67+
'jsObjectName' => $jsObjectName,
6668
'childComponentUrl' => $this->getUrl(
6769
'pagebuilder/form/element_productconditions_child',
6870
[
6971
'form_namespace' => $formNamespace,
7072
'prefix' => $attribute,
73+
'js_object_name' => $jsObjectName,
7174
]
7275
),
7376
'attribute' => $attribute,

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function execute()
5454
$this->rule->loadPost(['conditions' => $this->serializer->unserialize($conditionsEncoded)]);
5555
$formName = $this->getRequest()->getParam('form_namespace');
5656
// Combine class recursively sets jsFormObject so we don't need to
57-
$conditions->setJsFormObject($formName);
57+
$conditions->setJsFormObject($this->getRequest()->getParam('js_object_name'));
5858
// The Combine class doesn't need the data attribute on children but we do.
5959
$this->configureConditionsFormName($conditions, $formName);
6060
$result = $conditions->asHtmlRecursive();

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions/Child.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function execute()
3939
{
4040
$id = $this->getRequest()->getParam('id');
4141
$formName = $this->getRequest()->getParam('form_namespace');
42+
$jsObjectName = $this->getRequest()->getParam('js_object_name');
4243

4344
$typeData = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
4445
$className = $typeData[0];
@@ -55,7 +56,7 @@ public function execute()
5556

5657
$result = '';
5758
if ($model instanceof AbstractCondition) {
58-
$model->setJsFormObject($formName);
59+
$model->setJsFormObject($jsObjectName);
5960
$model->setFormName($formName);
6061
$result = $model->asHtmlRecursive();
6162
}

app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/Provider/Uploader/MaxFileSize.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

app/code/Magento/PageBuilder/Model/Stage/Renderer/CmsStaticBlock.php

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,29 @@ class CmsStaticBlock implements \Magento\PageBuilder\Model\Stage\RendererInterfa
3232
*/
3333
private $loggerInterface;
3434

35+
/**
36+
* @var \Magento\PageBuilder\Model\Stage\ScriptFilter
37+
*/
38+
private $scriptFilter;
39+
3540
/**
3641
* CmsStaticBlock constructor.
3742
*
3843
* @param \Magento\Cms\Model\ResourceModel\Block\CollectionFactory $blockCollectionFactory
3944
* @param WidgetDirective $widgetDirectiveRenderer
4045
* @param LoggerInterface $loggerInterface
46+
* @param \Magento\PageBuilder\Model\Stage\ScriptFilter $scriptFilter
4147
*/
4248
public function __construct(
4349
\Magento\Cms\Model\ResourceModel\Block\CollectionFactory $blockCollectionFactory,
4450
WidgetDirective $widgetDirectiveRenderer,
45-
LoggerInterface $loggerInterface
51+
LoggerInterface $loggerInterface,
52+
\Magento\PageBuilder\Model\Stage\ScriptFilter $scriptFilter
4653
) {
4754
$this->blockCollectionFactory = $blockCollectionFactory;
4855
$this->widgetDirectiveRenderer = $widgetDirectiveRenderer;
4956
$this->loggerInterface = $loggerInterface;
57+
$this->scriptFilter = $scriptFilter;
5058
}
5159

5260
/**
@@ -88,34 +96,11 @@ public function render(array $params): array
8896

8997
if ($block->isActive()) {
9098
$directiveResult = $this->widgetDirectiveRenderer->render($params);
91-
$result['content'] = $this->removeScriptTags($directiveResult['content']);
99+
$result['content'] = $this->scriptFilter->removeScriptTags($directiveResult['content']);
92100
} else {
93101
$result['error'] = __('Block disabled');
94102
}
95103

96104
return $result;
97105
}
98-
99-
/**
100-
* Remove script tag from html
101-
*
102-
* @param string $content
103-
* @return string
104-
*/
105-
private function removeScriptTags(string $content): string
106-
{
107-
$dom = new \DOMDocument();
108-
try {
109-
//this code is required because of https://bugs.php.net/bug.php?id=60021
110-
$previous = libxml_use_internal_errors(true);
111-
$dom->loadHTML($content);
112-
} catch (\Exception $e) {
113-
$this->loggerInterface->critical($e->getMessage());
114-
}
115-
libxml_use_internal_errors($previous);
116-
foreach (iterator_to_array($dom->getElementsByTagName('script')) as $item) {
117-
$item->parentNode->removeChild($item);
118-
}
119-
return $dom->saveHTML();
120-
}
121106
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Model\Stage;
10+
11+
use Psr\Log\LoggerInterface;
12+
13+
/**
14+
* Filters script tags from stage output
15+
*
16+
* @api
17+
*/
18+
class ScriptFilter
19+
{
20+
/**
21+
* @var LoggerInterface
22+
*/
23+
private $loggerInterface;
24+
25+
/**
26+
* ScriptFilter constructor.
27+
* @param LoggerInterface $loggerInterface
28+
*/
29+
public function __construct(
30+
LoggerInterface $loggerInterface
31+
) {
32+
$this->loggerInterface = $loggerInterface;
33+
}
34+
35+
/**
36+
* Remove script tag from html
37+
*
38+
* @param string $content
39+
* @return string
40+
*/
41+
public function removeScriptTags(string $content): string
42+
{
43+
$dom = new \DOMDocument();
44+
try {
45+
//this code is required because of https://bugs.php.net/bug.php?id=60021
46+
$previous = libxml_use_internal_errors(true);
47+
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
48+
} catch (\Exception $e) {
49+
$this->loggerInterface->critical($e->getMessage());
50+
}
51+
libxml_use_internal_errors($previous);
52+
foreach (iterator_to_array($dom->getElementsByTagName('script')) as $item) {
53+
$item->parentNode->removeChild($item);
54+
}
55+
return $dom->saveHTML();
56+
}
57+
}

0 commit comments

Comments
 (0)