Skip to content

Commit

Permalink
Merge pull request #346 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
haitv282 authored Sep 12, 2022
2 parents e6eb186 + 1996968 commit e055750
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
6 changes: 4 additions & 2 deletions Block/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,11 @@ public function getPageFilter($content)
public function getImageUrl($image, $type = Image::TEMPLATE_MEDIA_TYPE_POST)
{
$imageHelper = $this->helperData->getImageHelper();
$imageFile = $imageHelper->getMediaPath($image, $type);
if ($image) {
$imageFile = $imageHelper->getMediaPath($image, $type);
}

return $this->helperData->getImageHelper()->getMediaUrl($imageFile);
return $image ? $this->helperData->getImageHelper()->getMediaUrl($imageFile) : '';
}

/**
Expand Down
10 changes: 5 additions & 5 deletions Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
Data $helper
) {
$this->actionFactory = $actionFactory;
$this->helper = $helper;
$this->helper = $helper;
}

/**
Expand All @@ -70,9 +70,9 @@ public function match(RequestInterface $request)
return null;
}

$rssAction = "rss.xml";
$rssAction = "rss.xml";
$identifier = trim($request->getPathInfo(), '/');
$urlSuffix = $this->helper->getUrlSuffix();
$urlSuffix = $this->helper->getUrlSuffix();

if ($length = strlen($urlSuffix)) {
if (substr($identifier, -$length) === $urlSuffix && !$this->isRss($identifier)) {
Expand All @@ -84,7 +84,7 @@ public function match(RequestInterface $request)
$identifier = $this->checkRssIdentifier($identifier);
}

$routePath = explode('/', $identifier);
$routePath = explode('/', (string)$identifier);
$routeSize = count($routePath);
if (!$routeSize || ($routeSize > 3) || (array_shift($routePath) !== $this->helper->getRoute())) {
return null;
Expand Down Expand Up @@ -166,7 +166,7 @@ public function isRss($identifier)
$routePath = explode('/', $identifier);
$routePath = array_pop($routePath);
$routePath = explode('.', $routePath);
$action = array_shift($routePath);
$action = array_shift($routePath);

return $action === 'rss';
}
Expand Down
44 changes: 22 additions & 22 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
class Data extends CoreHelper
{
const CONFIG_MODULE_PATH = 'blog';
const TYPE_POST = 'post';
const TYPE_CATEGORY = 'category';
const TYPE_TAG = 'tag';
const TYPE_TOPIC = 'topic';
const TYPE_HISTORY = 'history';
const TYPE_AUTHOR = 'author';
const TYPE_MONTHLY = 'month';
const TYPE_POST = 'post';
const TYPE_CATEGORY = 'category';
const TYPE_TAG = 'tag';
const TYPE_TOPIC = 'topic';
const TYPE_HISTORY = 'history';
const TYPE_AUTHOR = 'author';
const TYPE_MONTHLY = 'month';

/**
* @var PostFactory
Expand Down Expand Up @@ -161,17 +161,17 @@ public function __construct(
HttpContext $httpContext,
DateTime $dateTime
) {
$this->postFactory = $postFactory;
$this->categoryFactory = $categoryFactory;
$this->tagFactory = $tagFactory;
$this->topicFactory = $topicFactory;
$this->authorFactory = $authorFactory;
$this->postFactory = $postFactory;
$this->categoryFactory = $categoryFactory;
$this->tagFactory = $tagFactory;
$this->topicFactory = $topicFactory;
$this->authorFactory = $authorFactory;
$this->postHistoryFactory = $postHistoryFactory;
$this->translitUrl = $translitUrl;
$this->dateTime = $dateTime;
$this->customerSession = $customerSession;
$this->_httpContext = $httpContext;
$this->_productMetadata = $productMetadata;
$this->translitUrl = $translitUrl;
$this->dateTime = $dateTime;
$this->customerSession = $customerSession;
$this->_httpContext = $httpContext;
$this->_productMetadata = $productMetadata;

parent::__construct($context, $objectManager, $storeManager);
}
Expand All @@ -184,7 +184,7 @@ public function isEnabledReview()
$groupId = (string)$this->_httpContext->getValue(CustomerContext::CONTEXT_GROUP);

if ($this->getConfigGeneral('is_review')
&& in_array($groupId, explode(',', $this->getConfigGeneral('review_mode')), true)
&& in_array($groupId, explode(',', (string) $this->getConfigGeneral('review_mode')), true)
) {
return true;
}
Expand Down Expand Up @@ -564,9 +564,9 @@ public function getBlogUrl($urlKey = null, $type = null, $store = null)
}

$urlKey = ($type ? $type . '/' : '') . $urlKey;
$url = $this->getUrl($this->getRoute($store) . '/' . $urlKey);
$url = explode('?', $url);
$url = $url[0];
$url = $this->getUrl($this->getRoute($store) . '/' . $urlKey);
$url = explode('?', $url);
$url = $url[0];

return rtrim($url, '/') . $this->getUrlSuffix($store);
}
Expand Down Expand Up @@ -658,7 +658,7 @@ public function checkUrlKey($resource, $object, $urlKey)
}

$adapter = $resource->getConnection();
$select = $adapter->select()
$select = $adapter->select()
->from($resource->getMainTable(), '*')
->where('url_key = :url_key');

Expand Down
2 changes: 1 addition & 1 deletion Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function getPathIds()
{
$ids = $this->getData('path_ids');
if ($ids === null) {
$ids = explode('/', $this->getPath());
$ids = explode('/', (string) $this->getPath());
$this->setData('path_ids', $ids);
}

Expand Down
1 change: 0 additions & 1 deletion Model/ResourceModel/Category/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Magento\Framework\Data\Collection\AbstractDb;
use Magento\Framework\DB\Select;
use Magento\Sales\Model\ResourceModel\Collection\AbstractCollection;
use Magento\Tests\NamingConvention\true\mixed;
use Mageplaza\Blog\Api\Data\SearchResult\CategorySearchResultInterface;
use Mageplaza\Blog\Model\Category;
use Mageplaza\Blog\Model\ResourceModel\Category as CategoryResourceModel;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.12"
},
"type": "magento2-module",
"version": "4.1.4",
"version": "4.1.5",
"license": "proprietary",
"keywords": [
"magento 2",
Expand Down
12 changes: 6 additions & 6 deletions view/frontend/templates/product/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ $_helper = $block->getHelper();
<?= $block->getProductDetailsHtml($_product) ?>
<div class="product-item-inner">
<div class="product actions product-item-actions"
<?= strpos($pos, $viewMode . '-actions')
<?= strpos((string) $pos, $viewMode . '-actions')
? $block->escapeHtmlAttr($position) : '' ?>>
<div class="actions-primary"
<?= strpos($pos, $viewMode . '-primary')
<?= strpos((string) $pos, $viewMode . '-primary')
? $block->escapeHtmlAttr($position) : '' ?>>
<?php if ($_product->isSaleable()) : ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
Expand Down Expand Up @@ -123,7 +123,7 @@ $_helper = $block->getHelper();
<?php endif; ?>
</div>
<div data-role="add-to-links" class="actions-secondary"
<?= strpos($pos, $viewMode . '-secondary')
<?= strpos((string) $pos, $viewMode . '-secondary')
? $block->escapeHtmlAttr($position) : '' ?>>
<?php if ($addToBlock = $block->getChildBlock('addto')) : ?>
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
Expand Down Expand Up @@ -183,10 +183,10 @@ $_helper = $block->getHelper();
<?= $block->getProductDetailsHtml($_product) ?>
<div class="product-item-inner">
<div class="product actions product-item-actions"
<?= strpos($pos, $viewMode . '-actions')
<?= strpos((string) $pos, $viewMode . '-actions')
? $block->escapeHtmlAttr($position) : '' ?>>
<div class="actions-primary"
<?= strpos($pos, $viewMode . '-primary')
<?= strpos((string) $pos, $viewMode . '-primary')
? $block->escapeHtmlAttr($position) : '' ?>>
<?php if ($_product->isSaleable()) : ?>
<?php $postParams = $block->getAddToCartPostParams($_product); ?>
Expand Down Expand Up @@ -218,7 +218,7 @@ $_helper = $block->getHelper();
<?php endif; ?>
</div>
<div data-role="add-to-links" class="actions-secondary"
<?= strpos($pos, $viewMode . '-secondary')
<?= strpos((string) $pos, $viewMode . '-secondary')
? $block->escapeHtmlAttr($position) : '' ?>>
<?php if ($addToBlock = $block->getChildBlock('addto')) : ?>
<?= $addToBlock->setProduct($_product)->getChildHtml() ?>
Expand Down

0 comments on commit e055750

Please sign in to comment.