Skip to content

Commit 5e34e2b

Browse files
authored
Merge pull request #106 from magefan/Comments
Build in Comments
2 parents 6c92dc3 + 565c77c commit 5e34e2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2952
-108
lines changed

Block/Adminhtml/Comment.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © 2015-2017 Ihor Vansach ([email protected]). All rights reserved.
4+
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\Blog\Block\Adminhtml;
10+
11+
/**
12+
* Admin blog post
13+
*/
14+
class Comment extends \Magento\Backend\Block\Widget\Grid\Container
15+
{
16+
/**
17+
* Constructor
18+
*
19+
* @return void
20+
*/
21+
protected function _construct()
22+
{
23+
$this->_controller = 'adminhtml_Blog';
24+
$this->_blockGroup = 'Magefan_Blog';
25+
//$this->_addButtonLabel = __('Add New Comment');
26+
parent::_construct();
27+
$this->removeButton('add');
28+
}
29+
}

Block/Adminhtml/Grid/Column/Statuses.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ public function getFrameCallback()
3535
public function decorateStatus($value, $row, $column, $isExport)
3636
{
3737
if ($row->getIsActive() || $row->getStatus()) {
38-
$cell = '<span class="grid-severity-notice"><span>' . $value . '</span></span>';
38+
if ($row->getStatus() == 2) {
39+
$cell = '<span class="grid-severity-minor"><span>' . $value . '</span></span>';
40+
} else {
41+
$cell = '<span class="grid-severity-notice"><span>' . $value . '</span></span>';
42+
}
3943
} else {
4044
$cell = '<span class="grid-severity-critical"><span>' . $value . '</span></span>';
4145
}

Block/Index.php

+36
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,40 @@ protected function _getConfigValue($param)
4747
);
4848
}
4949

50+
51+
/**
52+
* Prepare breadcrumbs
53+
*
54+
* @param string $title
55+
* @param string $key
56+
* @throws \Magento\Framework\Exception\LocalizedException
57+
* @return void
58+
*/
59+
protected function _addBreadcrumbs($title = null, $key = null)
60+
{
61+
if ($breadcrumbsBlock = $this->getBreadcrumbsBlock()) {
62+
$breadcrumbsBlock->addCrumb(
63+
'home',
64+
[
65+
'label' => __('Home'),
66+
'title' => __('Go to Home Page'),
67+
'link' => $this->_storeManager->getStore()->getBaseUrl()
68+
]
69+
);
70+
71+
$blogTitle = $this->_scopeConfig->getValue(
72+
'mfblog/index_page/title',
73+
ScopeInterface::SCOPE_STORE
74+
);
75+
$breadcrumbsBlock->addCrumb(
76+
'blog',
77+
[
78+
'label' => __($blogTitle),
79+
'title' => __($blogTitle),
80+
'link' => null,
81+
]
82+
);
83+
}
84+
}
85+
5086
}

Block/Post/Info.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Info extends \Magento\Framework\View\Element\Template
1919
* Block template file
2020
* @var string
2121
*/
22-
protected $_template = 'post/info.phtml';
22+
protected $_template = 'Magefan_Blog::post/info.phtml';
2323

2424
/**
2525
* DEPRECATED METHOD!!!!
@@ -56,4 +56,16 @@ public function authorPageEnabled()
5656
);
5757
}
5858

59+
/**
60+
* Retrieve true if magefan comments are enabled
61+
* @return bool
62+
*/
63+
public function magefanCommentsEnabled()
64+
{
65+
return $this->_scopeConfig->getValue(
66+
'mfblog/post_view/comments/type',
67+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
68+
) == \Magefan\Blog\Model\Config\Source\CommetType::MAGEFAN;
69+
}
70+
5971
}

Block/Post/PostList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected function _addBreadcrumbs($title = null, $key = null)
124124
[
125125
'label' => __($blogTitle),
126126
'title' => __($blogTitle),
127-
'link' => $title ? $this->_url->getBaseUrl() : null,
127+
'link' => $this->_url->getBaseUrl(),
128128
]
129129
);
130130

Block/Post/PostList/AbstractList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected function _preparePostCollection()
9494
*/
9595
public function getPostCollection()
9696
{
97-
if (is_null($this->_postCollection)) {
97+
if (null === $this->_postCollection) {
9898
$this->_preparePostCollection();
9999
}
100100

Block/Post/View/Comments.php

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Copyright © 2015 Ihor Vansach ([email protected]). All rights reserved.
3+
* Copyright © 2015-2017 Ihor Vansach ([email protected]). All rights reserved.
44
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
55
*
66
* Glory to Ukraine! Glory to the heroes!
@@ -26,16 +26,16 @@ class Comments extends \Magento\Framework\View\Element\Template
2626
protected $_coreRegistry;
2727

2828
/**
29-
* Construct
30-
*
31-
* @param \Magento\Framework\View\Element\Context $context
32-
* @param \Magento\Framework\Registry $coreRegistry,
33-
* @param \Magento\Cms\Model\Page $post
34-
* @param \Magento\Framework\Registry $coreRegistry,
35-
* @param \Magento\Cms\Model\Template\FilterProvider $filterProvider
36-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
37-
* @param \Magento\Cms\Model\PageFactory $postFactory
38-
* @param array $data
29+
* @var string
30+
*/
31+
protected $commetType;
32+
33+
/**
34+
* Constructor
35+
* @param \Magento\Framework\View\Element\Template\Context $context
36+
* @param \Magento\Framework\Registry $coreRegistry
37+
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
38+
* @param array $data
3939
*/
4040
public function __construct(
4141
\Magento\Framework\View\Element\Template\Context $context,
@@ -121,4 +121,18 @@ public function getPost()
121121
}
122122
return $this->getData('post');
123123
}
124+
125+
/**
126+
* Render block HTML
127+
*
128+
* @return string
129+
*/
130+
protected function _toHtml()
131+
{
132+
if ($this->commetType && $this->commetType != $this->getCommentsType()) {
133+
return '';
134+
}
135+
136+
return parent::_toHtml();
137+
}
124138
}

Block/Post/View/Comments/Disqus.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © 2015-2017 Ihor Vansach ([email protected]). All rights reserved.
4+
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\Blog\Block\Post\View\Comments;
10+
11+
use Magefan\Blog\Model\Config\Source\CommetType;
12+
13+
/**
14+
* Blog post Disqus comments block
15+
*/
16+
class Disqus extends \Magefan\Blog\Block\Post\View\Comments
17+
{
18+
protected $commetType = CommetType::DISQUS;
19+
}

Block/Post/View/Comments/Facebook.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © 2015-2017 Ihor Vansach ([email protected]). All rights reserved.
4+
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\Blog\Block\Post\View\Comments;
10+
11+
use Magefan\Blog\Model\Config\Source\CommetType;
12+
13+
/**
14+
* Blog post Facebook comments block
15+
*/
16+
class Facebook extends \Magefan\Blog\Block\Post\View\Comments
17+
{
18+
protected $commetType = CommetType::FACEBOOK;
19+
}

Block/Post/View/Comments/Google.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © 2015-2017 Ihor Vansach ([email protected]). All rights reserved.
4+
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php).
5+
*
6+
* Glory to Ukraine! Glory to the heroes!
7+
*/
8+
9+
namespace Magefan\Blog\Block\Post\View\Comments;
10+
11+
use Magefan\Blog\Model\Config\Source\CommetType;
12+
13+
/**
14+
* Blog post Google comments block
15+
*/
16+
class Google extends \Magefan\Blog\Block\Post\View\Comments
17+
{
18+
protected $commetType = CommetType::GOOGLE;
19+
}

0 commit comments

Comments
 (0)