Skip to content

Commit

Permalink
merge magento/2.3-develop into magento-arcticfoxes/MC-22958
Browse files Browse the repository at this point in the history
  • Loading branch information
magento-mts-svc authored Nov 14, 2019
2 parents abfe4b0 + 8f73566 commit be7125c
Show file tree
Hide file tree
Showing 16 changed files with 225 additions and 36 deletions.
14 changes: 8 additions & 6 deletions app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ private function getWatermark(string $type, int $scopeId = null): array
);

if ($file) {
$size = $this->scopeConfig->getValue(
"design/watermark/{$type}_size",
ScopeInterface::SCOPE_STORE,
$scopeId
$size = explode(
'x',
$this->scopeConfig->getValue(
"design/watermark/{$type}_size",
ScopeInterface::SCOPE_STORE
)
);
$opacity = $this->scopeConfig->getValue(
"design/watermark/{$type}_imageOpacity",
Expand All @@ -145,8 +147,8 @@ private function getWatermark(string $type, int $scopeId = null): array
ScopeInterface::SCOPE_STORE,
$scopeId
);
$width = !empty($size['width']) ? $size['width'] : null;
$height = !empty($size['height']) ? $size['height'] : null;
$width = !empty($size['0']) ? $size['0'] : null;
$height = !empty($size['1']) ? $size['1'] : null;

return [
'watermark_file' => $file,
Expand Down
7 changes: 4 additions & 3 deletions app/code/Magento/MediaStorage/Service/ImageResize.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ private function resize(array $imageParams, string $originalImagePath, string $o
]
);

if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
$image->resize($imageParams['image_width'], $imageParams['image_height']);
}

if (isset($imageParams['watermark_file'])) {
if ($imageParams['watermark_height'] !== null) {
$image->setWatermarkHeight($imageParams['watermark_height']);
Expand All @@ -331,9 +335,6 @@ private function resize(array $imageParams, string $originalImagePath, string $o
$image->watermark($this->getWatermarkFilePath($imageParams['watermark_file']));
}

if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) {
$image->resize($imageParams['image_width'], $imageParams['image_height']);
}
$image->save($imageAsset->getPath());

if ($this->fileStorageDatabase->checkDbUsage()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function getFormatedOptionValue($optionValue)

if ($this->string->strlen($optionValue) > 55) {
$result['value'] = $result['value']
. ' <a href="#" class="dots tooltip toggle" onclick="return false">...</a>';
. ' ...';
$optionValue = nl2br($optionValue);
$result = array_merge($result, ['full_view' => $optionValue]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<?php if (!$block->getPrintStatus()) : ?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
<?= $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
<?php if (isset($_formatedOptionValue['full_view'])) : ?>
<div class="tooltip content">
<dl class="item options">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<?php if (!$block->getPrintStatus()) : ?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
<?= $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
<?php if (isset($_formatedOptionValue['full_view'])) : ?>
<div class="tooltip content">
<dl class="item options">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ $_item = $block->getItem();
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<?php if (!$block->getPrintStatus()) : ?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dd>
<dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
<?= $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
<?php if (isset($_formatedOptionValue['full_view'])) : ?>
<?= $block->escapeHtml($_formatedOptionValue['full_view'], ['a']) ?>
<?php else : ?>
<?=$block->escapeHtml($_formatedOptionValue['value'], ['a']) ?>
<div class="tooltip content">
<dl class="item options">
<dt><?= $block->escapeHtml($_option['label']) ?></dt>
<dd><?= $block->escapeHtml($_formatedOptionValue['full_view']) ?></dd>
</dl>
</div>
<?php endif; ?>
</dd>
<?php else : ?>
<dd>
<?= /* @noEscape */ nl2br($block->escapeHtml($_option['print_value'] ?? $_option['value'])) ?>
</dd>
<dd><?= $block->escapeHtml((isset($_option['print_value']) ? $_option['print_value'] : $_option['value'])) ?></dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<?php if (!$block->getPrintStatus()) : ?>
<?php $_formatedOptionValue = $block->getFormatedOptionValue($_option) ?>
<dd<?= (isset($_formatedOptionValue['full_view']) ? ' class="tooltip wrapper"' : '') ?>>
<?= $block->escapeHtml($_formatedOptionValue['value']) ?>
<?= $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
<?php if (isset($_formatedOptionValue['full_view'])) : ?>
<div class="tooltip content">
<dl class="item options">
Expand Down
25 changes: 25 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ define([

return Column.extend({
defaults: {
bodyTmpl: 'ui/grid/columns/image-preview',
previewImageSelector: '[data-image-preview]',
visibleRecord: null,
height: 0,
displayedRecord: {},
lastOpenedImage: null,
fields: {
previewUrl: 'preview_url',
title: 'title'
},
modules: {
masonry: '${ $.parentName }',
thumbnailComponent: '${ $.parentName }.thumbnail_url'
Expand Down Expand Up @@ -154,6 +159,26 @@ define([
return this.visibleRecord() === record._rowIndex || false;
},

/**
* Returns preview image url for a given record.
*
* @param {Object} record
* @return {String}
*/
getUrl: function (record) {
return record[this.fields.previewUrl];
},

/**
* Returns image title for a given record.
*
* @param {Object} record
* @return {String}
*/
getTitle: function (record) {
return record[this.fields.title];
},

/**
* Get styles for preview
*
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define([

return Column.extend({
defaults: {
bodyTmpl: 'ui/grid/columns/image',
modules: {
previewComponent: '${ $.parentName }.preview'
},
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ define([
'use strict';

return Column.extend({
defaults: {
bodyTmpl: 'ui/grid/columns/overlay'
},

/**
* If overlay should be visible
*
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/grid/masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define([

return Listing.extend({
defaults: {
template: 'Magento_Ui/grid/masonry',
template: 'ui/grid/masonry',
imports: {
rows: '${ $.provider }:data.items',
errorMessage: '${ $.provider }:data.errorMessage'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
// */

@import 'module/_data-grid.less';
@import 'module/_masonry-grid.less';
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// /**
// * Copyright © Magento, Inc. All rights reserved.
// * See COPYING.txt for license details.
// */
@admin__masonry_grid_image__space: 20px;
@admin__masonry_grid_background_color: #fff;
@admin__masonry_overlay_background_color: #507dc8;

& when (@media-common = true) {
.masonry-image {
&-grid {
margin: @admin__masonry_grid_image__space/2 -(@admin__masonry_grid_image__space/2);
overflow: hidden;
position: relative;

.no-data-message-container,
.error-message-container {
font-size: @data-grid__no-records__font-size;
padding: @data-grid__no-records__padding;
text-align: center;
}
}

&-column {
background-color: @admin__masonry_grid_background_color;
float: left;
margin: @admin__masonry_grid_image__space/2;
overflow: hidden;

img {
cursor: pointer;
height: 100%;
width: 100%;
}
}

&-overlay {
background-color: @admin__masonry_overlay_background_color;
color: @admin__masonry_grid_background_color;
opacity: 1;
padding: .5rem;
position: absolute;
text-align: center;
width: 80px;
z-index: 10;
}

&-preview {
background-color: @admin__masonry_grid_background_color;
display: table;
left: 0;
position: absolute;
right: 0;
width: 100%;

.container {
margin: auto;
max-width: 880px;
padding-top: 10px;

.action-buttons {
text-align: right;

.action {
&-close {
padding: 30px;
position: static;
}

&-previous,
&-next {
background: transparent;
border: none;
margin: 0;
white-space: nowrap;
}

&-close,
&-previous,
&-next {
font-size: 2rem;
}
}
}

.preview-row-content {
display: flex;

&:after {
clear: both;
content: '';
display: table;
}

img.preview {
display: block;
flex-basis: 300px;
float: left;
margin-bottom: 20px;
max-height: 500px;
max-width: 60%;
width: auto;
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function readIndexes($tableName, $resource)
$indexes = [];
$adapter = $this->resourceConnection->getConnection($resource);
$condition = sprintf('`Non_unique` = 1');
$sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
$sql = sprintf('SHOW INDEXES FROM `%s` WHERE %s', $tableName, $condition);
$stmt = $adapter->query($sql);

// Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
Expand All @@ -147,9 +147,10 @@ public function readIndexes($tableName, $resource)
}

/**
* Read references (foreign keys) from Magento tables.
*
* As MySQL has bug and do not show foreign keys during DESCRIBE and other directives required
* to take it from SHOW CREATE TABLE ...
* command
* to take it from "SHOW CREATE TABLE ..." command.
*
* @inheritdoc
*/
Expand All @@ -170,13 +171,14 @@ public function readReferences($tableName, $resource)
public function getCreateTableSql($tableName, $resource)
{
$adapter = $this->resourceConnection->getConnection($resource);
$sql = sprintf('SHOW CREATE TABLE %s', $tableName);
$sql = sprintf('SHOW CREATE TABLE `%s`', $tableName);
$stmt = $adapter->query($sql);
return $stmt->fetch(\Zend_Db::FETCH_ASSOC);
}

/**
* Reading DB constraints.
*
* Primary and unique constraints are always non_unique=0.
*
* @inheritdoc
Expand All @@ -186,7 +188,7 @@ public function readConstraints($tableName, $resource)
$constraints = [];
$adapter = $this->resourceConnection->getConnection($resource);
$condition = sprintf('`Non_unique` = 0');
$sql = sprintf('SHOW INDEXES FROM %s WHERE %s', $tableName, $condition);
$sql = sprintf('SHOW INDEXES FROM `%s` WHERE %s', $tableName, $condition);
$stmt = $adapter->query($sql);

// Use FETCH_NUM so we are not dependent on the CASE attribute of the PDO connection
Expand Down
19 changes: 9 additions & 10 deletions lib/internal/Magento/Framework/View/Page/Config/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,19 +349,18 @@ protected function getGroupAttributes($group)
*/
protected function addDefaultAttributes($contentType, $attributes)
{
switch ($contentType) {
case 'js':
$attributes = ' type="text/javascript" ' . $attributes;
break;
if ($contentType === 'js') {
return ' type="text/javascript" ' . $attributes;
}

case 'css':
$attributes = ' rel="stylesheet" type="text/css" ' . ($attributes ?: ' media="all"');
break;
if ($contentType === 'css') {
return ' rel="stylesheet" type="text/css" ' . ($attributes ?: ' media="all"');
}

case $this->canTypeBeFont($contentType):
$attributes = 'rel="preload" as="font" crossorigin="anonymous"';
break;
if ($this->canTypeBeFont($contentType)) {
return 'rel="preload" as="font" crossorigin="anonymous"';
}

return $attributes;
}

Expand Down
Loading

0 comments on commit be7125c

Please sign in to comment.