Skip to content

Commit 5b06088

Browse files
author
Ivan Gavryshko
committed
Merge remote-tracking branch 'origin/MAGETWO-43691-custom-admin-hostname-2' into PR_Branch
2 parents b69a601 + 70bc364 commit 5b06088

File tree

11 files changed

+61
-17
lines changed

11 files changed

+61
-17
lines changed

app/code/Magento/Backend/App/Area/FrontNameResolver.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
namespace Magento\Backend\App\Area;
99

1010
use Magento\Backend\Setup\ConfigOptionsList;
11+
use Magento\Framework\App\Config\ScopeConfigInterface;
1112
use Magento\Framework\App\DeploymentConfig;
13+
use Magento\Store\Model\ScopeInterface;
14+
use Magento\Store\Model\Store;
1215

1316
class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolverInterface
1417
{
@@ -38,27 +41,51 @@ class FrontNameResolver implements \Magento\Framework\App\Area\FrontNameResolver
3841
*/
3942
protected $deploymentConfig;
4043

44+
/** @var ScopeConfigInterface */
45+
private $configInterface;
46+
4147
/**
4248
* @param \Magento\Backend\App\Config $config
4349
* @param DeploymentConfig $deploymentConfig
50+
* @param ScopeConfigInterface $configInterface
4451
*/
45-
public function __construct(\Magento\Backend\App\Config $config, DeploymentConfig $deploymentConfig)
46-
{
52+
public function __construct(
53+
\Magento\Backend\App\Config $config,
54+
DeploymentConfig $deploymentConfig,
55+
ScopeConfigInterface $configInterface
56+
) {
4757
$this->config = $config;
4858
$this->defaultFrontName = $deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME);
59+
$this->configInterface = $configInterface;
4960
}
5061

5162
/**
5263
* Retrieve area front name
5364
*
54-
* @return string
65+
* @param bool $checkHost If true, verify front name is valid for this url (hostname is correct)
66+
* @return string|bool
5567
*/
56-
public function getFrontName()
68+
public function getFrontName($checkHost = false)
5769
{
70+
if ($checkHost && !$this->isHostBackend()) {
71+
return false;
72+
}
5873
$isCustomPathUsed = (bool)(string)$this->config->getValue(self::XML_PATH_USE_CUSTOM_ADMIN_PATH);
5974
if ($isCustomPathUsed) {
6075
return (string)$this->config->getValue(self::XML_PATH_CUSTOM_ADMIN_PATH);
6176
}
6277
return $this->defaultFrontName;
6378
}
79+
80+
/**
81+
* Return whether the host from request is the backend host
82+
* @return bool
83+
*/
84+
public function isHostBackend()
85+
{
86+
$backendUrl = $this->configInterface->getValue(Store::XML_PATH_UNSECURE_BASE_URL, ScopeInterface::SCOPE_STORE);
87+
$backendHost = parse_url(trim($backendUrl), PHP_URL_HOST);
88+
$host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
89+
return (strcasecmp($backendHost, $host) === 0);
90+
}
6491
}

app/code/Magento/Backend/App/Router/NoRouteHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function process(\Magento\Framework\App\RequestInterface $request)
4242
$requestPathParams = explode('/', trim($request->getPathInfo(), '/'));
4343
$areaFrontName = array_shift($requestPathParams);
4444

45-
if ($areaFrontName == $this->helper->getAreaFrontName()) {
45+
if ($areaFrontName === $this->helper->getAreaFrontName(true)) {
4646
$moduleName = $this->routeConfig->getRouteFrontName('adminhtml');
4747
$actionNamespace = 'noroute';
4848
$actionName = 'index';

app/code/Magento/Backend/Helper/Data.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,11 @@ public function getHomePageUrl()
198198
/**
199199
* Return Backend area front name
200200
*
201-
* @return string
201+
* @param bool $checkHost
202+
* @return bool|string
202203
*/
203-
public function getAreaFrontName()
204+
public function getAreaFrontName($checkHost = false)
204205
{
205-
return $this->_frontNameResolver->getFrontName();
206+
return $this->_frontNameResolver->getFrontName($checkHost);
206207
}
207208
}

app/code/Magento/Backend/Test/Unit/App/Area/FrontNameResolverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ protected function setUp()
3333
->with(ConfigOptionsList::CONFIG_PATH_BACKEND_FRONTNAME)
3434
->will($this->returnValue($this->_defaultFrontName));
3535
$this->_configMock = $this->getMock('\Magento\Backend\App\Config', [], [], '', false);
36-
$this->_model = new FrontNameResolver($this->_configMock, $deploymentConfigMock);
36+
$configMock = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false);
37+
$this->_model = new FrontNameResolver($this->_configMock, $deploymentConfigMock, $configMock);
3738
}
3839

3940
public function testIfCustomPathUsed()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protected function retrieveRemoteImage($fileUrl, $localFilePath)
128128
$image = $this->curl->read();
129129
if (empty($image)) {
130130
throw new \Magento\Framework\Exception\LocalizedException(
131-
__('Could not get video information. Please check your connection and try again.')
131+
__('Could not get preview image information. Please check your connection and try again.')
132132
);
133133
}
134134
$this->fileUtility->saveFile($localFilePath, $image);

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
@@ -303,7 +303,7 @@ require([
303303
additionalParams += '&autoplay=1';
304304
}
305305

306-
src = 'http://player.vimeo.com/video/' +
306+
src = window.location.protocol + '//player.vimeo.com/video/' +
307307
this._code + '?api=1&player_id=vimeo' +
308308
this._code +
309309
timestamp +
@@ -483,7 +483,7 @@ require([
483483
}
484484
);
485485
} else if (type === 'vimeo') {
486-
$.getJSON('http://www.vimeo.com/api/v2/video/' + id + '.json?callback=?',
486+
$.getJSON(window.location.protocol + '//www.vimeo.com/api/v2/video/' + id + '.json?callback=?',
487487
{
488488
format: 'json'
489489
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,9 @@ define([
508508
$image.find('.magnify-lens').remove();
509509
$image.on('click', function () {
510510
if ($(this).hasClass('video-unplayed') && $(this).find('iframe').length === 0) {
511+
$('.fotorama__arr--next').hide();
512+
$('.fotorama__arr--prev').hide();
513+
511514
$(this).removeClass('video-unplayed');
512515
$(this).find('.' + PV).productVideoLoader();
513516

@@ -611,6 +614,8 @@ define([
611614
$(this).remove();
612615
$item.append(cloneVideoDiv);
613616
$item.addClass('video-unplayed');
617+
$('.fotorama__arr--next').show();
618+
$('.fotorama__arr--prev').show();
614619
self._hideCloseVideo();
615620

616621
});

app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ define(['jquery', 'jquery/ui'], function ($) {
327327
.attr('width', this._width)
328328
.attr('height', this._height)
329329
.attr('src', src)
330+
.attr('webkitallowfullscreen', '')
331+
.attr('mozallowfullscreen', '')
332+
.attr('allowfullscreen', '')
330333
);
331334
this._player = window.$f(this.element.children(':first')[0]);
332335

lib/internal/Magento/Framework/App/Area/FrontNameResolverInterface.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interface FrontNameResolverInterface
1616
/**
1717
* Retrieve front name
1818
*
19-
* @return string
19+
* @param bool if true, only return frontname if it is valid for the host
20+
* @return string|bool
2021
*/
21-
public function getFrontName();
22+
public function getFrontName($checkHost = false);
2223
}

lib/internal/Magento/Framework/App/AreaList.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ public function getCodeByFrontName($frontName)
6969
{
7070
foreach ($this->_areas as $areaCode => &$areaInfo) {
7171
if (!isset($areaInfo['frontName']) && isset($areaInfo['frontNameResolver'])) {
72-
$areaInfo['frontName'] = $this->_resolverFactory->create(
73-
$areaInfo['frontNameResolver']
74-
)->getFrontName();
72+
$resolver = $this->_resolverFactory->create($areaInfo['frontNameResolver']);
73+
$areaInfo['frontName'] = $resolver->getFrontName(true);
7574
}
7675
if ($areaInfo['frontName'] == $frontName) {
7776
return $areaCode;

0 commit comments

Comments
 (0)