Skip to content

Commit 3e60b9c

Browse files
author
Vadim Zubovich
committed
Merge branch 'master3' of git.epam.com:magn-vid into master3
2 parents ca48d02 + 1a46d9f commit 3e60b9c

File tree

10 files changed

+122
-49
lines changed

10 files changed

+122
-49
lines changed

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,6 @@ public function __construct(CategorySetupFactory $categorySetupFactory)
4040
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
4141
{
4242
$setup->startSetup();
43-
if (version_compare($context->getVersion(), '2.0.1') < 0) {
44-
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
45-
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
46-
47-
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
48-
$attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
49-
50-
$attributeGroup = $categorySetup->getAttributeGroup(
51-
$entityTypeId,
52-
$attributeSetId,
53-
'Images',
54-
'attribute_group_name'
55-
);
56-
if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Images') {
57-
// update General Group
58-
$categorySetup->updateAttributeGroup(
59-
$entityTypeId,
60-
$attributeSetId,
61-
$attributeGroup['attribute_group_id'],
62-
'attribute_group_name',
63-
'Images and Videos'
64-
);
65-
}
66-
}
67-
6843
if ($context->getVersion()
6944
&& version_compare($context->getVersion(), '2.0.1') < 0
7045
) {

app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ protected function retrieveRemoteImage($fileUrl, $localFilePath)
131131
$this->curl->setConfig(['header' => false]);
132132
$this->curl->write('GET', $fileUrl);
133133
$image = $this->curl->read();
134+
if (empty($image)) {
135+
throw new \InvalidArgumentException(__('Couldn\'t retrive a remote preview image file. Service is inaccessible.'));
136+
}
134137
$this->fileUtility->saveFile($localFilePath, $image);
135138
}
136139

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\ProductVideo\Setup;
8+
9+
use Magento\Catalog\Setup\CategorySetupFactory;
10+
use Magento\Framework\Setup\UpgradeDataInterface;
11+
use Magento\Framework\Setup\ModuleContextInterface;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
14+
/**
15+
* Upgrade Data script
16+
* @codeCoverageIgnore
17+
*/
18+
class UpgradeData implements UpgradeDataInterface
19+
{
20+
/**
21+
* Category setup factory
22+
*
23+
* @var CategorySetupFactory
24+
*/
25+
private $categorySetupFactory;
26+
27+
/**
28+
* Init
29+
*
30+
* @param CategorySetupFactory $categorySetupFactory
31+
*/
32+
public function __construct(CategorySetupFactory $categorySetupFactory)
33+
{
34+
$this->categorySetupFactory = $categorySetupFactory;
35+
}
36+
37+
/**
38+
* {@inheritdoc}
39+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
40+
*/
41+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
42+
{
43+
$setup->startSetup();
44+
if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
45+
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
46+
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
47+
48+
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
49+
$attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
50+
51+
$attributeGroup = $categorySetup->getAttributeGroup(
52+
$entityTypeId,
53+
$attributeSetId,
54+
'Image Management'
55+
);
56+
if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Image Management') {
57+
// update General Group
58+
$categorySetup->updateAttributeGroup(
59+
$entityTypeId,
60+
$attributeSetId,
61+
$attributeGroup['attribute_group_id'],
62+
'attribute_group_name',
63+
'Images and Videos'
64+
);
65+
}
66+
67+
}
68+
69+
$setup->endSetup();
70+
}
71+
}

app/code/Magento/ProductVideo/Test/Unit/Block/Adminhtml/Product/Edit/NewVideoTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class NewVideoTest extends \PHPUnit_Framework_TestCase
3737
*/
3838
protected $jsonEncoderMock;
3939

40+
/**
41+
* @var \Magento\ProductVideo\Helper\Media|\PHPUnit_Framework_MockObject_MockObject
42+
*/
43+
protected $mediaHelper;
44+
4045
/**
4146
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
4247
* |\Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo
@@ -46,6 +51,7 @@ class NewVideoTest extends \PHPUnit_Framework_TestCase
4651
public function setUp()
4752
{
4853
$this->contextMock = $this->getMock('\Magento\Backend\Block\Template\Context', [], [], '', false);
54+
$this->mediaHelper = $this->getMock('\Magento\ProductVideo\Helper\Media', [], [], '', false);
4955
$this->mathRandom = $this->getMock('\Magento\Framework\Math\Random', [], [], '', false);
5056
$this->urlBuilder = $this->getMock('\Magento\Framework\UrlInterface', [], [], '', false);
5157
$this->contextMock->expects($this->any())->method('getMathRandom')->willReturn($this->mathRandom);
@@ -60,9 +66,11 @@ public function setUp()
6066
'\Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo',
6167
[
6268
'context' => $this->contextMock,
69+
'mediaHelper' => $this->mediaHelper,
70+
'urlBuilder' => $this->urlBuilder,
71+
'jsonEncoder' => $this->jsonEncoderMock,
6372
'registry' => $this->registryMock,
6473
'formFactory' => $this->formFactoryMock,
65-
'jsonEncoder' => $this->jsonEncoderMock
6674
]
6775
);
6876
}

app/code/Magento/ProductVideo/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_ProductVideo" setup_version="2.0.0.1">
9+
<module name="Magento_ProductVideo" setup_version="2.0.0.2">
1010
<sequence>
1111
<module name="Magento_Catalog"/>
1212
<module name="Magento_Backend"/>

app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,8 +569,8 @@ require([
569569
type = 'youtube';
570570
} else if (href.host.match(/vimeo\.com/)) {
571571
type = 'vimeo';
572-
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
573-
'?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)'
572+
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
573+
'?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|video\\/|)(\\d+)(?:$|\\/|\\?)'
574574
].join(''));
575575
id = href.href.match(vimeoRegex)[3];
576576
}

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ define([
1111
], function ($) {
1212
'use strict';
1313

14+
/**
15+
* @private
16+
*/
17+
var allowBase = true; //global var is needed because fotorama always fully reloads events in case of fullscreen
18+
1419
/**
1520
* @private
1621
*/
@@ -68,8 +73,8 @@ define([
6873
type = 'youtube';
6974
} else if (href.host.match(/vimeo\.com/)) {
7075
type = 'vimeo';
71-
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
72-
'?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)'
76+
vimeoRegex = new RegExp(['https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/(?:channels\\/(?:\\w+\\/)',
77+
'?|groups\\/([^\\/]*)\\/videos\\/|album\\/(\\d+)\\/video\\/|video\\/|)(\\d+)(?:$|\\/|\\?)'
7378
].join(''));
7479
id = href.href.match(vimeoRegex)[3];
7580
}
@@ -309,13 +314,16 @@ define([
309314

310315
if (
311316
videoItem.mediaType === this.VID && videoItem.isBase &&
312-
this.options.VideoSettings[0].playIfBase
317+
this.options.VideoSettings[0].playIfBase && allowBase
313318
) {
314319
this.Base = true;
320+
allowBase = false;
315321
}
316322
}
317323

318-
this._createCloseVideo($(this.element).data('fotorama'), this.Base);
324+
if (!this.isFullscreen) {
325+
this._createCloseVideo($(this.element).data('fotorama'), this.Base);
326+
}
319327
},
320328

321329
/**
@@ -327,7 +335,7 @@ define([
327335
scriptTag = document.getElementsByTagName('script')[0];
328336

329337
element.async = true;
330-
element.src = 'https://f.vimeocdn.com/js/froogaloop2.min.js';
338+
element.src = 'https://secure-a.vimeocdn.com/js/froogaloop2.min.js';
331339
scriptTag.parentNode.insertBefore(element, scriptTag);
332340
},
333341

@@ -523,9 +531,11 @@ define([
523531
this.Base = false;
524532
}
525533
}, this), 50);
526-
} else { //if not a vimeo - play it immediately
527-
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
528-
this.Base = false;
534+
} else { //if not a vimeo - play it immediately with a little lag in case for fotorama fullscreen
535+
setTimeout($.proxy(function () {
536+
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
537+
this.Base = false;
538+
}, this), 50);
529539
}
530540
}
531541
},

app/design/frontend/Magento/blank/Magento_ProductVideo/web/css/source/_module.less

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@
6363
}
6464
}
6565

66+
@media only screen
67+
and (min-device-width : 320px)
68+
and (max-device-width : 780px)
69+
and (orientation : landscape) {
70+
.product-video {
71+
height: 100%;
72+
width: 81%;
73+
}
74+
}
75+
6676
.fotorama__arr.hidden-video {
6777
z-index: -1;
6878
}

dev/tests/integration/testsuite/Magento/Test/Integrity/Modular/ViewConfigFilesTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class ViewConfigFilesTest extends \PHPUnit_Framework_TestCase
1313
*/
1414
public function testViewConfigFile($file)
1515
{
16-
/** @var \Magento\Framework\View\Xsd\Reader $reader */
17-
$reader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
18-
'Magento\Framework\View\Xsd\Reader'
19-
);
20-
$mergeXsd = $reader->read();
2116
$domConfig = new \Magento\Framework\Config\Dom($file);
17+
$urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
2218
$result = $domConfig->validate(
23-
$mergeXsd,
19+
$urnResolver->getRealPath('urn:magento:framework:Config/etc/view.xsd'),
2420
$errors
2521
);
26-
$this->assertTrue($result, "Invalid XML-file: {$file}\n" . join("\n", $errors));
22+
$message = "Invalid XML-file: {$file}\n";
23+
foreach ($errors as $error) {
24+
$message .= "{$error->message} Line: {$error->line}\n";
25+
}
26+
$this->assertTrue($result, $message);
2727
}
2828

2929
/**

lib/internal/Magento/Framework/Config/Dom.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,7 @@ public static function validateDomDocument(
274274
$schema = self::$urnResolver->getRealPath($schema);
275275
libxml_use_internal_errors(true);
276276
try {
277-
if (file_exists($schema)) {
278-
$result = $dom->schemaValidate($schema);
279-
} else {
280-
$result = $dom->schemaValidateSource($schema);
281-
}
277+
$result = $dom->schemaValidate($schema);
282278
$errors = [];
283279
if (!$result) {
284280
$validationErrors = libxml_get_errors();

0 commit comments

Comments
 (0)