Skip to content

Commit

Permalink
Merge pull request #27 from magento-tango/Tango_Pull_Request_Bug_Fixing
Browse files Browse the repository at this point in the history
[Tango] Bugfixes
  • Loading branch information
vpelipenko committed Jan 14, 2015
2 parents 1f4cf42 + 733006d commit c92a39f
Show file tree
Hide file tree
Showing 23 changed files with 794 additions and 106 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Backend/view/adminhtml/requirejs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var config = {
map: {
'*': {
editTrigger: 'mage/edit-trigger',
translateInline: 'mage/translate-inline',
form: 'mage/backend/form',
button: 'mage/backend/button',
Expand Down Expand Up @@ -37,4 +38,4 @@ var config = {
paths: {
"jquery/ui": "jquery/jquery-ui-1.9.2"
}
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@ public function execute()
{
$directive = $this->getRequest()->getParam('___directive');
$directive = $this->urlDecoder->decode($directive);
$url = $this->_objectManager->create('Magento\Email\Model\Template\Filter')->filter($directive);
$imagePath = $this->_objectManager->create('Magento\Cms\Model\Template\Filter')->filter($directive);
/** @var \Magento\Framework\Image\Adapter\AdapterInterface $image */
$image = $this->_objectManager->get('Magento\Framework\Image\AdapterFactory')->create();
$response = $this->getResponse();
try {
$image->open($url);
$image->open($imagePath);
$response->setHeader('Content-Type', $image->getMimeType())->setBody($image->getImage());
} catch (\Exception $e) {
$image->open($this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config')->getSkinImagePlaceholderUrl());
$imagePath = $this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config')->getSkinImagePlaceholderPath();
$image->open($imagePath);
$response->setHeader('Content-Type', $image->getMimeType())->setBody($image->getImage());
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
}
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Cms/Model/Template/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ public function setUseSessionInUrl($flag)
$this->_useSessionInUrl = (bool)$flag;
return $this;
}

/**
* Retrieve media file URL directive
*
* @param string[] $construction
* @return string
*/
public function mediaDirective($construction)
{
$params = $this->_getIncludeParameters($construction[2]);
return $this->_storeManager->getStore()->getBaseMediaDir() . '/' . $params['url'];
}
}
21 changes: 18 additions & 3 deletions app/code/Magento/Cms/Model/Wysiwyg/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Config extends \Magento\Framework\Object
*/
const WYSIWYG_STATUS_CONFIG_PATH = 'cms/wysiwyg/enabled';

/**
*
*/
const WYSIWYG_SKIN_IMAGE_PLACEHOLDER_ID = 'Magento_Cms::images/wysiwyg_skin_image.png';

/**
* Wysiwyg status hidden
*/
Expand Down Expand Up @@ -79,6 +84,11 @@ class Config extends \Magento\Framework\Object
*/
protected $_backendUrl;

/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected $_storeManager;

/**
* @param \Magento\Backend\Model\UrlInterface $backendUrl
* @param \Magento\Framework\Event\ManagerInterface $eventManager
Expand All @@ -87,6 +97,7 @@ class Config extends \Magento\Framework\Object
* @param \Magento\Core\Model\Variable\Config $variableConfig
* @param \Magento\Widget\Model\Widget\Config $widgetConfig
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param array $windowSize
* @param array $data
*/
Expand All @@ -98,6 +109,7 @@ public function __construct(
\Magento\Core\Model\Variable\Config $variableConfig,
\Magento\Widget\Model\Widget\Config $widgetConfig,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager,
array $windowSize = [],
array $data = []
) {
Expand All @@ -109,6 +121,7 @@ public function __construct(
$this->_variableConfig = $variableConfig;
$this->_widgetConfig = $widgetConfig;
$this->_windowSize = $windowSize;
$this->_storeManager = $storeManager;
parent::__construct($data);
}

Expand Down Expand Up @@ -184,13 +197,15 @@ public function getConfig($data = [])
}

/**
* Return URL for skin images placeholder
* Return path for skin images placeholder
*
* @return string
*/
public function getSkinImagePlaceholderUrl()
public function getSkinImagePlaceholderPath()
{
return $this->_assetRepo->getUrl('Magento_Cms::images/wysiwyg_skin_image.png');
$staticPath = $this->_storeManager->getStore()->getBaseStaticDir();
$placeholderPath = $this->_assetRepo->createAsset(self::WYSIWYG_SKIN_IMAGE_PLACEHOLDER_ID)->getPath();
return $staticPath . '/' . $placeholderPath;
}

/**
Expand Down
17 changes: 17 additions & 0 deletions app/code/Magento/PageCache/Controller/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@

class Block extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\Translate\InlineInterface
*/
protected $translateInline;

/**
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\Translate\InlineInterface $translateInline
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\Translate\InlineInterface $translateInline
) {
parent::__construct($context);
$this->translateInline = $translateInline;
}

/**
* Get blocks from layout by handles
*
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/PageCache/Controller/Block/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function execute()
$response->setHeader('X-Magento-Tags', implode(',', $blockInstance->getIdentities()));
}
}
$this->translateInline->processResponseBody($html);
$response->appendBody($html);
$response->setPublicHeaders($ttl);
}
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/PageCache/Controller/Block/Render.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function execute()
}

$this->getResponse()->setPrivateHeaders(\Magento\PageCache\Helper\Data::PRIVATE_MAX_AGE_CACHE);
$this->translateInline->processResponseBody($data);
$this->getResponse()->appendBody(json_encode($data));
}
}
10 changes: 7 additions & 3 deletions app/code/Magento/Reports/Model/Event/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ public function catalogProductCompareClear(\Magento\Framework\Event\Observer $ob
public function catalogProductCompareAddProduct(\Magento\Framework\Event\Observer $observer)
{
$productId = $observer->getEvent()->getProduct()->getId();

$this->_productCompFactory->create()->setProductId($productId)->save()->calculate();

$viewData = ['product_id' => $productId];
if ($this->_customerSession->isLoggedIn()) {
$viewData['customer_id'] = $this->_customerSession->getCustomerId();
} else {
$viewData['visitor_id'] = $this->_customerVisitor->getId();
}
$this->_productCompFactory->create()->setData($viewData)->save()->calculate();
return $this->_event(\Magento\Reports\Model\Event::EVENT_PRODUCT_COMPARE, $productId);
}

Expand Down
20 changes: 20 additions & 0 deletions app/code/Magento/Store/Model/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,26 @@ public function getBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LIN
return $this->_baseUrlCache[$cacheKey];
}

/**
* Retrieve base media directory path
*
* @return string
*/
public function getBaseMediaDir()
{
return $this->filesystem->getUri(DirectoryList::MEDIA);
}

/**
* Retrieve base static directory path
*
* @return string
*/
public function getBaseStaticDir()
{
return $this->filesystem->getUri(DirectoryList::STATIC_VIEW);
}

/**
* Append script file name to url in case when server rewrites are disabled
*
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Translation/Block/Js.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function __construct(
*/
public function getTranslatedJson()
{
$json = \Zend_Json::encode($this->dataProvider->getTranslateData());
$this->translateInline->processResponseBody($json, false);
return $json;
$data = $this->dataProvider->getTranslateData();
$this->translateInline->processResponseBody($data);
return \Zend_Json::encode($data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
class Properties extends \Magento\Widget\Block\Adminhtml\Widget\Options implements
\Magento\Backend\Block\Widget\Tab\TabInterface
{
/**
* Widget config parameters
*
* @var array
*/
protected $hiddenParameters = [
'template'
];

/**
* Prepare label for tab
*
Expand Down Expand Up @@ -47,11 +56,21 @@ public function canShowTab()
/**
* Returns status flag about this tab hidden or not
*
* @return true
* @return bool
*/
public function isHidden()
{
return false;
$widgetConfig = $this->getWidgetInstance()->getWidgetConfigAsArray();

if (isset($widgetConfig['parameters'])) {
foreach ($widgetConfig['parameters'] as $key => $parameter) {
if ($parameter['visible'] == 1 && !in_array($key, $this->hiddenParameters)) {
return false;
}
}
}

return true;
}

/**
Expand Down Expand Up @@ -88,7 +107,7 @@ protected function _preparelayout()
*/
protected function _addField($parameter)
{
if ($parameter->getKey() != 'template') {
if (!in_array($parameter->getKey(), $this->hiddenParameters)) {
return parent::_addField($parameter);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2016,9 +2016,10 @@
['getLinksConfig', 'Magento\Downloadable\Block\Catalog\Product\Links'],
['getAuthorizationAmounts', 'Magento\Paypal\Model\Config'],
['cleanTransactions', 'Magento\Paypal\Model\Observer'],
['getSkinImagePlaceholderUrl', 'Magento\Cms\Model\Wysiwyg\Config'],
['compareIndexColumnProperties', 'Magento\Catalog\Model\Resource\Helper'],
['getIsNullNotNullCondition', 'Magento\Catalog\Model\Resource\Helper'],
['_getCategoryPath', 'Magento\Catalog\Model\Resource\Setup'],
['_getCategoryEntityRow', 'Magento\Catalog\Model\Resource\Setup'],
['createEavAttributeResource', 'Magento\Catalog\Model\Resource\Setup'],
['createEavAttributeResource', 'Magento\Catalog\Model\Resource\Setup']
];
Loading

0 comments on commit c92a39f

Please sign in to comment.