Skip to content

Commit

Permalink
Merge pull request #354 from mageplaza/2.4-develop
Browse files Browse the repository at this point in the history
2.4 develop
  • Loading branch information
phutx authored Feb 9, 2023
2 parents c40b9e2 + bb82467 commit 7d9f340
Show file tree
Hide file tree
Showing 22 changed files with 804 additions and 804 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected function _getNodeJson($node, $level = 0)
$node = new Node($node, 'category_id', new \Magento\Framework\Data\Tree());
}

$storeIds = $node->getStoreIds() ? explode(',', $node->getStoreIds()) : [];
$storeIds = $node->getStoreIds() ? explode(',', $node->getStoreIds() ?? '') : [];
if (!($this->_blogStore === null)
&& !empty($storeIds)
&& !in_array(0, $storeIds, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function render(DataObject $row)
{
if (!empty($row->getData($this->getColumn()->getIndex()))) {
$text = '';
$CategoryIds = explode(',', $row->getData($this->getColumn()->getIndex()));
$CategoryIds = explode(',', $row->getData($this->getColumn()->getIndex()) ?? '');
foreach ($CategoryIds as $categoryId) {
$category = $this->_helperData->getFactoryByType('category')->create()->load($categoryId);
$text .= $category->getName() . ',';
Expand Down
2 changes: 1 addition & 1 deletion Block/Author/SignupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getAuthor()
*/
public function getVersion()
{
$array = explode('/', $this->helperData->getConfigValue('cms/wysiwyg/editor'));
$array = explode('/', $this->helperData->getConfigValue('cms/wysiwyg/editor') ?? '');
if ($array[count($array) - 1] === 'tinymce4Adapter') {
return 4;
}
Expand Down
8 changes: 5 additions & 3 deletions Block/Listpost.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getPostCollection()
$pager = $this->getLayout()->createBlock(Pager::class, 'mpblog.post.pager');

$perPageValues = (string)$this->helperData->getConfigGeneral('pagination');
$perPageValues = explode(',', $perPageValues);
$perPageValues = explode(',', $perPageValues ?? '');
$perPageValues = array_combine($perPageValues, $perPageValues);

$pager->setAvailableLimit($perPageValues)
Expand Down Expand Up @@ -166,9 +166,11 @@ public function applySeoCode()
$robots = $object ? $object->getMetaRobots() : $this->helperData->getSeoConfig('meta_robots');
$this->pageConfig->setRobots($robots);

if ($this->getRequest()->getFullActionName() === 'mpblog_post_view') {
$url = $object ? $object->getUrl() : $this->helperData->getSeoConfig('url_key');

if ($this->getRequest()->getFullActionName() === 'mpblog_post_view' && $url) {
$this->pageConfig->addRemotePageAsset(
$object->getUrl(),
$url,
'canonical',
['attributes' => ['rel' => 'canonical']]
);
Expand Down
4 changes: 2 additions & 2 deletions Block/Post/AuthorPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getPostCollection()
if ($collection && $collection->getSize()) {
$pager = $this->getLayout()->createBlock(Pager::class, 'mpblog.post.pager');
$perPageValues = (string) $this->helperData->getConfigGeneral('pagination');
$perPageValues = explode(',', $perPageValues);
$perPageValues = explode(',', $perPageValues ?? '');
$perPageValues = array_combine($perPageValues, $perPageValues);

$pager->setAvailableLimit($perPageValues)->setCollection($collection);
Expand Down Expand Up @@ -95,7 +95,7 @@ public function getStatusHtmlById($statusId)
*/
public function getVersion()
{
$array = explode('/', $this->helperData->getConfigValue('cms/wysiwyg/editor'));
$array = explode('/', $this->helperData->getConfigValue('cms/wysiwyg/editor') ?? '');
if ($array[count($array) - 1] === 'tinymce4Adapter') {
return 4;
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/History/Restore.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ protected function prepareData($history)
{
$history->setUpdatedAt($this->date->date());
$history->setData('categories_ids', empty($history->getCategoryIds())
? [] : explode(',', $history->getCategoryIds()));
$history->setData('tags_ids', empty($history->getTagIds()) ? [] : explode(',', $history->getTagIds()));
$history->setData('topics_ids', empty($history->getTopicIds()) ? [] : explode(',', $history->getTopicIds()));
? [] : explode(',', $history->getCategoryIds() ?? ''));
$history->setData('tags_ids', empty($history->getTagIds()) ? [] : explode(',', $history->getTagIds() ?? ''));
$history->setData('topics_ids', empty($history->getTopicIds()) ? [] : explode(',', $history->getTopicIds() ?? ''));
$history->setData('products_data', empty($history->getProductIds())
? [] : Data::jsonDecode($history->getProductIds()));
$data = $history->getData();
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/History/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ protected function prepareData($post, $data = [])
$data['modifier_id'] = $this->_auth->getUser()->getId();
$data['categories_ids'] = (isset($data['categories_ids']) && $data['categories_ids']) ? explode(
',',
$data['categories_ids']
$data['categories_ids'] ?? ''
) : [];
$data['tags_ids'] = (isset($data['tags_ids']) && $data['tags_ids'])
? explode(',', $data['tags_ids']) : [];
? explode(',', $data['tags_ids'] ?? '') : [];
$data['topics_ids'] = (isset($data['topics_ids']) && $data['topics_ids']) ? explode(
',',
$data['topics_ids']
$data['topics_ids'] ?? ''
) : [];

if ($post->getCreatedAt() === null) {
Expand Down
6 changes: 3 additions & 3 deletions Controller/Adminhtml/Post/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,13 +284,13 @@ protected function prepareData($post, $data = [])
$data['modifier_id'] = $this->_auth->getUser()->getId();
$data['categories_ids'] = (isset($data['categories_ids']) && $data['categories_ids']) ? explode(
',',
$data['categories_ids']
$data['categories_ids'] ?? ''
) : [];
$data['tags_ids'] = (isset($data['tags_ids']) && $data['tags_ids'])
? explode(',', $data['tags_ids']) : [];
? explode(',', $data['tags_ids'] ?? '') : [];
$data['topics_ids'] = (isset($data['topics_ids']) && $data['topics_ids']) ? explode(
',',
$data['topics_ids']
$data['topics_ids'] ?? ''
) : [];

if ($post->getCreatedAt() == null) {
Expand Down
6 changes: 3 additions & 3 deletions Controller/Post/Manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public function execute()

$data['categories_ids'] = (isset($data['categories_ids']) && $data['categories_ids']) ? explode(
',',
$data['categories_ids']
$data['categories_ids'] ?? ''
) : [];
$data['tags_ids'] = (isset($data['tags_ids']) && $data['tags_ids'])
? explode(',', $data['tags_ids']) : [];
? explode(',', $data['tags_ids'] ?? '') : [];
$data['topics_ids'] = (isset($data['topics_ids']) && $data['topics_ids']) ? explode(
',',
$data['topics_ids']
$data['topics_ids'] ?? ''
) : [];

$data['author_id'] = $author->getId();
Expand Down
4 changes: 2 additions & 2 deletions Controller/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ public function match(RequestInterface $request)
*/
public function isRss($identifier)
{
$routePath = explode('/', $identifier);
$routePath = explode('/', $identifier ?? '');
$routePath = array_pop($routePath);
$routePath = explode('.', $routePath);
$routePath = explode('.', $routePath ?? '');
$action = array_shift($routePath);

return $action === 'rss';
Expand Down
9 changes: 6 additions & 3 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function getReviewMode()
$login = $this->_httpContext->getValue(CustomerContext::CONTEXT_AUTH);

if (!$login
&& in_array('0', explode(',', $this->getConfigGeneral('review_mode')), true)
&& in_array('0', explode(',', $this->getConfigGeneral('review_mode') ?? ''), true)
) {
return '0';
}
Expand Down Expand Up @@ -431,20 +431,23 @@ public function getPostCollection($type = null, $id = null, $storeId = null)
'main_table.post_id=category.post_id AND category.category_id=' . $id,
['position']
);
$collection->getSelect()->order('position asc');
break;
case self::TYPE_TAG:
$collection->join(
['tag' => $collection->getTable('mageplaza_blog_post_tag')],
'main_table.post_id=tag.post_id AND tag.tag_id=' . $id,
['position']
);
$collection->getSelect()->order('position asc');
break;
case self::TYPE_TOPIC:
$collection->join(
['topic' => $collection->getTable('mageplaza_blog_post_topic')],
'main_table.post_id=topic.post_id AND topic.topic_id=' . $id,
['position']
);
$collection->getSelect()->order('position asc');
break;
case self::TYPE_MONTHLY:
$collection->addFieldToFilter('publish_date', ['like' => $id . '%']);
Expand Down Expand Up @@ -565,7 +568,7 @@ public function getBlogUrl($urlKey = null, $type = null, $store = null)

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

return rtrim($url, '/') . $this->getUrlSuffix($store);
Expand Down Expand Up @@ -719,7 +722,7 @@ public function getUrl($route, $params = [])
*/
public function checkStore($object)
{
$storeEnable = explode(',', $object->getStoreIds());
$storeEnable = explode(',', $object->getStoreIds() ?? '');

return in_array('0', $storeEnable, true)
|| in_array((string)$this->storeManager->getStore()->getId(), $storeEnable, true);
Expand Down
6 changes: 3 additions & 3 deletions Model/Api/BlogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,13 @@ public function getConfig()
protected function prepareData(&$data)
{
if (!empty($data['categories_ids'])) {
$data['categories_ids'] = explode(',', $data['categories_ids']);
$data['categories_ids'] = explode(',', $data['categories_ids'] ?? '');
}
if (!empty($data['tags_ids'])) {
$data['tags_ids'] = explode(',', $data['tags_ids']);
$data['tags_ids'] = explode(',', $data['tags_ids'] ?? '');
}
if (!empty($data['topics_ids'])) {
$data['topics_ids'] = explode(',', $data['topics_ids']);
$data['topics_ids'] = explode(',', $data['topics_ids'] ?? '');
}
if (empty($data['enabled'])) {
$data['enabled'] = 0;
Expand Down
1 change: 1 addition & 0 deletions Model/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ public function getSelectedPostsCollection()
'main_table.post_id=cat.post_id AND cat.category_id=' . $this->getId(),
['position']
);
$collection->setOrder('post_id','DESC');
$this->postCollection = $collection;
}

Expand Down
3 changes: 1 addition & 2 deletions Model/ResourceModel/Category/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Mageplaza\Blog\Api\Data\SearchResult\CategorySearchResultInterface;
use Mageplaza\Blog\Model\Category;
use Mageplaza\Blog\Model\ResourceModel\Category as CategoryResourceModel;
use Zend_Db_Select;

/**
* Class Collection
Expand Down Expand Up @@ -134,7 +133,7 @@ public function addAttributeToSelect($attribute, $joinType = false)
public function getSelectCountSql()
{
$countSelect = parent::getSelectCountSql();
$countSelect->reset(Zend_Db_Select::GROUP);
$countSelect->reset(Select::GROUP);

return $countSelect;
}
Expand Down
6 changes: 1 addition & 5 deletions Model/ResourceModel/Category/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\Blog\Model\ResourceModel\Category;
use Mageplaza\Blog\Model\Category as CategoryModel;
use Zend_Db_Select;

/**
* Class Tree
Expand Down Expand Up @@ -506,11 +505,8 @@ public function loadBreadcrumbsArray($path, $addCollectionData = true, $withRoot
}

/**
* Obtain select for Categories
*
* @param bool $sorted
*
* @return Zend_Db_Select
* @return Select
*/
public function createCollectionDataSelect($sorted = true)
{
Expand Down
3 changes: 1 addition & 2 deletions Model/ResourceModel/Post/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use Magento\Sales\Model\ResourceModel\Collection\AbstractCollection;
use Mageplaza\Blog\Api\Data\SearchResult\PostSearchResultInterface;
use Mageplaza\Blog\Model\Post;
use Zend_Db_Select;

/**
* Class Collection
Expand Down Expand Up @@ -73,7 +72,7 @@ protected function _construct()
public function getSelectCountSql()
{
$countSelect = parent::getSelectCountSql();
$countSelect->reset(Zend_Db_Select::GROUP);
$countSelect->reset(Select::GROUP);

return $countSelect;
}
Expand Down
6 changes: 2 additions & 4 deletions Model/ResourceModel/Tag/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Mageplaza\Blog\Api\Data\SearchResult\TagSearchResultInterface;
use Mageplaza\Blog\Model\Tag;
use Mageplaza\Blog\Model\ResourceModel\Tag as TagResourceModel;
use Zend_Db_Select;

/**
* Class Collection
Expand Down Expand Up @@ -74,7 +73,7 @@ protected function _construct()
public function getSelectCountSql()
{
$countSelect = parent::getSelectCountSql();
$countSelect->reset(Zend_Db_Select::GROUP);
$countSelect->reset(Select::GROUP);

return $countSelect;
}
Expand All @@ -83,7 +82,6 @@ public function getSelectCountSql()
* @param null $valueField
* @param string $labelField
* @param array $additional
*
* @return array
*/
protected function _toOptionArray($valueField = null, $labelField = 'name', $additional = [])
Expand All @@ -94,7 +92,7 @@ protected function _toOptionArray($valueField = null, $labelField = 'name', $add
}

/**
* add if filter
* Add if filter
*
* @param array|int|string $tagIds
*
Expand Down
3 changes: 1 addition & 2 deletions Model/ResourceModel/Topic/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Mageplaza\Blog\Api\Data\SearchResult\TopicSearchResultInterface;
use Mageplaza\Blog\Model\Topic;
use Mageplaza\Blog\Model\ResourceModel\Topic as TopicResourceModel;
use Zend_Db_Select;

/**
* Class Collection
Expand Down Expand Up @@ -74,7 +73,7 @@ protected function _construct()
public function getSelectCountSql()
{
$countSelect = parent::getSelectCountSql();
$countSelect->reset(Zend_Db_Select::GROUP);
$countSelect->reset(Select::GROUP);

return $countSelect;
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "mageplaza/magento-2-blog-extension",
"description": "Magento 2 Blog extension",
"require": {
"mageplaza/module-core": "^1.4.12"
"mageplaza/module-core": "^1.5.2"
},
"type": "magento2-module",
"version": "4.1.5",
"version": "4.1.6",
"license": "proprietary",
"keywords": [
"magento 2",
Expand Down
Loading

0 comments on commit 7d9f340

Please sign in to comment.