Skip to content

Commit 1270d25

Browse files
author
Roman Lytvynenko
committed
Merge branch 'develop' of https://github.com/magento/magento2-page-builder into magento-tango-MC-23252
� Conflicts: � app/code/Magento/PageBuilder/Model/Catalog/ProductTotals.php
2 parents 2615639 + f41f238 commit 1270d25

File tree

92 files changed

+3094
-633
lines changed

Some content is hidden

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

92 files changed

+3094
-633
lines changed

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,12 @@ public function execute()
5454
$conditions = $this->getRequest()->getParam('conditionValue');
5555

5656
try {
57-
$totals = $this->productTotals->getProductTotals($conditions);
58-
$response = [
59-
'total' => $totals['total'],
60-
'disabled' => $totals['disabled'],
61-
'notVisible' => $totals['notVisible'],
62-
'outOfStock' => $totals['outOfStock'],
63-
];
57+
$response = $this->productTotals->getProductTotals($conditions);
6458
} catch (Exception $e) {
6559
$response = [
6660
'total' => 0,
6761
'disabled' => 0,
6862
'notVisible' => 0,
69-
'outOfStock' => 0,
7063
];
7164
}
7265

app/code/Magento/PageBuilder/Model/Catalog/ProductTotals.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Magento\Catalog\Model\Product\Visibility;
1414
use Magento\Catalog\Model\ResourceModel\Product\Collection;
1515
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
16-
use Magento\CatalogInventory\Helper\Stock;
1716
use Magento\CatalogWidget\Model\Rule;
1817
use Magento\Framework\Exception\LocalizedException;
1918
use Magento\Framework\Exception\NoSuchEntityException;
@@ -49,11 +48,6 @@ class ProductTotals
4948
*/
5049
private $conditionsHelper;
5150

52-
/**
53-
* @var Stock
54-
*/
55-
private $stockFilter;
56-
5751
/**
5852
* @var CategoryRepositoryInterface
5953
*/
@@ -64,22 +58,19 @@ class ProductTotals
6458
* @param Builder $sqlBuilder
6559
* @param Rule $rule
6660
* @param Conditions $conditionsHelper
67-
* @param Stock $stockFilter
6861
* @param CategoryRepositoryInterface $categoryRepository
6962
*/
7063
public function __construct(
7164
CollectionFactory $productCollectionFactory,
7265
Builder $sqlBuilder,
7366
Rule $rule,
7467
Conditions $conditionsHelper,
75-
Stock $stockFilter,
7668
CategoryRepositoryInterface $categoryRepository
7769
) {
7870
$this->productCollectionFactory = $productCollectionFactory;
7971
$this->sqlBuilder = $sqlBuilder;
8072
$this->rule = $rule;
8173
$this->conditionsHelper = $conditionsHelper;
82-
$this->stockFilter = $stockFilter;
8374
$this->categoryRepository = $categoryRepository;
8475
}
8576

@@ -199,34 +190,6 @@ private function getNotVisibleCount(Collection $baseCollection): int
199190
return $notVisibleCollection->getSize();
200191
}
201192

202-
/**
203-
* Retrieve count of all out of stock products
204-
*
205-
* @param Collection $baseCollection
206-
* @return int number of out of stock products
207-
* @throws Zend_Db_Select_Exception
208-
*/
209-
private function getOutOfStockCount(Collection $baseCollection): int
210-
{
211-
// Retrieve in stock products, then subtract them from the total
212-
$outOfStockCollection = clone $baseCollection;
213-
$this->stockFilter->addIsInStockFilterToCollection($outOfStockCollection);
214-
// Remove existing stock_status where condition from query
215-
$outOfStockWhere = $outOfStockCollection->getSelect()->getPart('where');
216-
$outOfStockWhere = array_filter(
217-
$outOfStockWhere,
218-
function ($whereCondition) {
219-
return !stristr($whereCondition, 'stock_status');
220-
}
221-
);
222-
$outOfStockCollection->getSelect()->setPart('where', $outOfStockWhere);
223-
$outOfStockCollection->getSelect()->where(
224-
'stock_status_index.stock_status = ?',
225-
\Magento\CatalogInventory\Model\Stock\Status::STATUS_OUT_OF_STOCK
226-
);
227-
return $outOfStockCollection->getSize();
228-
}
229-
230193
/**
231194
* Retrieve product totals for collection
232195
*
@@ -253,13 +216,11 @@ public function getProductTotals(string $conditions): array
253216

254217
$disabledCount = $this->getDisabledCount($collection);
255218
$notVisibleCount = $this->getNotVisibleCount($collection);
256-
$outOfStockCount = $this->getOutOfStockCount($collection);
257219

258220
return [
259221
'total' => $collection->getSize(),
260222
'disabled' => $disabledCount,
261223
'notVisible' => $notVisibleCount,
262-
'outOfStock' => $outOfStockCount,
263224
];
264225
}
265226
}

app/code/Magento/PageBuilder/Model/Catalog/Sorting.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ public function getSortingOptions(): array
6262
* Get the instance of the first option which is None
6363
*
6464
* @param string $sortOption
65-
* @return Sorting\OptionInterface
65+
* @return Sorting\OptionInterface|null
6666
*/
67-
public function getSortingInstance($sortOption): Sorting\OptionInterface
67+
public function getSortingInstance($sortOption): ?Sorting\OptionInterface
6868
{
6969
if (isset($this->sortInstances[$sortOption])) {
7070
return $this->sortInstances[$sortOption];
7171
}
72+
73+
return null;
7274
}
7375

7476
/**
@@ -83,12 +85,14 @@ public function applySorting(
8385
\Magento\Catalog\Model\ResourceModel\Product\Collection $collection
8486
): \Magento\Catalog\Model\ResourceModel\Product\Collection {
8587
$sortBuilder = $this->getSortingInstance($option);
86-
$_collection = $sortBuilder->sort($collection);
88+
if ($sortBuilder) {
89+
$collection = $sortBuilder->sort($collection);
90+
}
8791

88-
if ($_collection->isLoaded()) {
89-
$_collection->clear();
92+
if ($collection->isLoaded()) {
93+
$collection->clear();
9094
}
9195

92-
return $_collection;
96+
return $collection;
9397
}
9498
}

app/code/Magento/PageBuilder/Model/Filter/Template.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ public function filter(string $result) : string
9191
if (!empty($matches)) {
9292
$docHtml = $matches[1];
9393

94+
// restore any encoded directives
95+
$docHtml = preg_replace_callback(
96+
'/=\"(%7B%7B[^"]*%7D%7D)\"/m',
97+
function ($matches) {
98+
return urldecode($matches[0]);
99+
},
100+
$docHtml
101+
);
102+
94103
if (isset($uniqueNodeNameToDecodedOuterHtmlMap)) {
95104
foreach ($uniqueNodeNameToDecodedOuterHtmlMap as $uniqueNodeName => $decodedOuterHtml) {
96105
$docHtml = str_replace(

app/code/Magento/PageBuilder/Model/Stage/Config.php

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
use Magento\Framework\UrlInterface;
1212

1313
/**
14-
* Class Config
14+
* Provide configuration to the admin JavaScript app
15+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1516
*
1617
* @api
1718
*/
@@ -80,9 +81,18 @@ class Config
8081
*/
8182
private $rootContainerConfig;
8283

84+
/**
85+
* @var \Magento\Widget\Model\Widget\Config
86+
*/
87+
private $widgetConfig;
88+
89+
/**
90+
* @var \Magento\Variable\Model\Variable\Config
91+
*/
92+
private $variableConfig;
93+
8394
/**
8495
* Config constructor.
85-
*
8696
* @param \Magento\PageBuilder\Model\ConfigInterface $config
8797
* @param Config\UiComponentConfig $uiComponentConfig
8898
* @param UrlInterface $urlBuilder
@@ -94,6 +104,8 @@ class Config
94104
* @param \Magento\PageBuilder\Model\WidgetInitializerConfig $widgetInitializerConfig
95105
* @param array $rootContainerConfig
96106
* @param array $data
107+
* @param \Magento\Widget\Model\Widget\Config|null $widgetConfig
108+
* @param \Magento\Variable\Model\Variable\Config|null $variableConfig
97109
*
98110
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
99111
*/
@@ -108,7 +120,9 @@ public function __construct(
108120
\Magento\PageBuilder\Model\Wysiwyg\InlineEditingSupportedAdapterList $inlineEditingChecker,
109121
\Magento\PageBuilder\Model\WidgetInitializerConfig $widgetInitializerConfig,
110122
array $rootContainerConfig = [],
111-
array $data = []
123+
array $data = [],
124+
\Magento\Widget\Model\Widget\Config $widgetConfig = null,
125+
\Magento\Variable\Model\Variable\Config $variableConfig = null
112126
) {
113127
$this->config = $config;
114128
$this->uiComponentConfig = $uiComponentConfig;
@@ -121,6 +135,10 @@ public function __construct(
121135
$this->widgetInitializerConfig = $widgetInitializerConfig;
122136
$this->rootContainerConfig = $rootContainerConfig;
123137
$this->data = $data;
138+
$this->widgetConfig = $widgetConfig ?? \Magento\Framework\App\ObjectManager::getInstance()
139+
->get(\Magento\Widget\Model\Widget\Config::class);
140+
$this->variableConfig = $variableConfig ?? \Magento\Framework\App\ObjectManager::getInstance()
141+
->get(\Magento\Variable\Model\Variable\Config::class);
124142
}
125143

126144
/**
@@ -134,15 +152,46 @@ public function getConfig()
134152
'menu_sections' => $this->getMenuSections(),
135153
'content_types' => $this->getContentTypes(),
136154
'stage_config' => $this->data,
137-
'media_url' => $this->urlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]),
155+
'media_url' => $this->frontendUrlBuilder->getBaseUrl(['_type' => UrlInterface::URL_TYPE_MEDIA]),
138156
'preview_url' => $this->urlBuilder->getUrl('pagebuilder/stage/preview'),
139157
'render_url' => $this->urlBuilder->getUrl('pagebuilder/stage/render'),
140158
'column_grid_default' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_DEFAULT),
141159
'column_grid_max' => $this->scopeConfig->getValue(self::XML_PATH_COLUMN_GRID_MAX),
142160
'can_use_inline_editing_on_stage' => $this->isWysiwygProvisionedForEditingOnStage(),
143161
'widgets' => $this->widgetInitializerConfig->getConfig(),
144-
'breakpoints' => $this->widgetInitializerConfig->getBreakpoints()
162+
'breakpoints' => $this->widgetInitializerConfig->getBreakpoints(),
163+
'tinymce' => $this->getTinyMceConfig(),
164+
];
165+
}
166+
167+
/**
168+
* Retrieve the TinyMCE required configuration
169+
*
170+
* @return array
171+
*/
172+
private function getTinyMceConfig()
173+
{
174+
$config = [
175+
'widgets' => [],
176+
'variables' => []
145177
];
178+
179+
// Retrieve widget configuration
180+
$widgetConfig = $this->widgetConfig->getConfig(new \Magento\Framework\DataObject());
181+
$options = $widgetConfig->getData('plugins');
182+
if (isset($options[0]) && $options[0]['name'] === 'magentowidget') {
183+
$config['widgets'] = $options[0]['options'];
184+
}
185+
186+
// Retrieve variable configuration
187+
$variableConfig = $this->variableConfig->getWysiwygPluginSettings(new \Magento\Framework\DataObject());
188+
if (isset($variableConfig['plugins']) && isset($variableConfig['plugins'][0])
189+
&& $variableConfig['plugins'][0]['name'] === 'magentovariable'
190+
) {
191+
$config['variables'] = $variableConfig['plugins'][0]['options'];
192+
}
193+
194+
return $config;
146195
}
147196

148197
/**

app/code/Magento/PageBuilder/Model/Stage/HtmlFilter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ public function __construct(
4040
*/
4141
public function filterHtml(string $content): string
4242
{
43-
$dom = new \DOMDocument();
43+
$dom = new \DOMDocument('1.0', 'UTF-8');
4444
try {
4545
//this code is required because of https://bugs.php.net/bug.php?id=60021
4646
$previous = libxml_use_internal_errors(true);
47-
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
47+
$string = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8');
48+
$dom->loadHTML($string, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
4849
} catch (\Exception $e) {
4950
$this->loggerInterface->critical($e->getMessage());
5051
}

app/code/Magento/PageBuilder/Model/Wysiwyg/DefaultConfigProvider.php

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,41 +39,43 @@ public function __construct(
3939
*/
4040
public function getConfig(\Magento\Framework\DataObject $config): \Magento\Framework\DataObject
4141
{
42-
$config->addData([
43-
'tinymce4' => [
44-
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
45-
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
46-
'| link image table charmap',
42+
$config->addData(
43+
[
44+
'tinymce4' => [
45+
'toolbar' => 'undo redo | styleselect | fontsizeselect | lineheightselect | forecolor backcolor ' .
46+
'| bold italic underline | alignleft aligncenter alignright | numlist bullist ' .
47+
'| link image table charmap',
4748

48-
'plugins' => implode(
49-
' ',
50-
[
51-
'advlist',
52-
'autolink',
53-
'lists',
54-
'link',
55-
'charmap',
56-
'media',
57-
'noneditable',
58-
'table',
59-
'contextmenu',
60-
'paste',
61-
'code',
62-
'help',
63-
'table',
64-
'textcolor',
65-
'image',
66-
'colorpicker',
67-
'lineheight'
49+
'plugins' => implode(
50+
' ',
51+
[
52+
'advlist',
53+
'autolink',
54+
'lists',
55+
'link',
56+
'charmap',
57+
'media',
58+
'noneditable',
59+
'table',
60+
'contextmenu',
61+
'paste',
62+
'code',
63+
'help',
64+
'table',
65+
'textcolor',
66+
'image',
67+
'colorpicker',
68+
'lineheight'
69+
]
70+
),
71+
'content_css' => [
72+
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
73+
$this->assetRepo->getUrl('Magento_PageBuilder::css/source/form/element/tinymce.css')
6874
]
69-
),
70-
'content_css' => [
71-
$this->assetRepo->getUrl('mage/adminhtml/wysiwyg/tiny_mce/themes/ui.css'),
72-
$this->assetRepo->getUrl('Magento_PageBuilder/css/source/form/element/tinymce.css')
73-
]
74-
],
75-
'settings' => $this->additionalSettings
76-
]);
75+
],
76+
'settings' => $this->additionalSettings
77+
]
78+
);
7779
return $config;
7880
}
7981
}

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class TemplatePlugin
1414
{
15-
const BACKGROUND_IMAGE_PATTERN = '/data-background-images/si';
15+
const BACKGROUND_IMAGE_PATTERN = '/data-background-images=(?:\'|"){.+}(?:\'|")/si';
1616

1717
const HTML_CONTENT_TYPE_PATTERN = '/data-content-type="html"/si';
1818

app/code/Magento/PageBuilder/Test/Mftf/ActionGroup/OverlayActionGroup.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@
161161
</arguments>
162162
<!-- Validate bottom edge of overlay -->
163163
<comment userInput="Validate bottom edge of overlay" stepKey="commentValidateBottomEdgeOfOverlay"/>
164-
<executeJS function="return {{page.wrapperJS(index)}}.getBoundingClientRect().top+{{padding.paddingTop}}+120" stepKey="wrapperTopPaddingContent"/>
164+
<!-- 30px padding top, 50px min height, 30px padding bottom -->
165+
<executeJS function="return {{page.wrapperJS(index)}}.getBoundingClientRect().top+{{padding.paddingTop}}+30+50+30" stepKey="wrapperTopPaddingContent"/>
165166
<executeJS function="return {{page.overlayJS(index)}}.getBoundingClientRect().bottom" stepKey="overlayBottomPosition"/>
166167
<executeJS function="return Math.round(({$wrapperTopPaddingContent}/{$overlayBottomPosition})*100)/100" stepKey="overlayBottomRatio"/>
167168
<assertEquals stepKey="assertOverlayBottomRatio">

0 commit comments

Comments
 (0)