init
This commit is contained in:
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Author;
|
||||
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\AuthorFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Author
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @var AuthorFactory
|
||||
*/
|
||||
protected $_author;
|
||||
|
||||
/**
|
||||
* Override this function to apply collection for each type
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
if ($author = $this->getAuthor()) {
|
||||
return $this->helperData->getPostCollection(Data::TYPE_AUTHOR, $author->getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getAuthor()
|
||||
{
|
||||
if (!$this->_author) {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
if ($id) {
|
||||
$author = $this->helperData->getObjectByParam($id, null, Data::TYPE_AUTHOR);
|
||||
if ($author && $author->getId()) {
|
||||
$this->_author = $author;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_author;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$author = $this->getAuthor();
|
||||
if ($author) {
|
||||
$breadcrumbs->addCrumb($author->getUrlKey(), [
|
||||
'label' => __('Author'),
|
||||
'title' => __('Author')
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $meta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
$author = $this->getAuthor();
|
||||
if (!$author) {
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
array_push($blogTitle, ucfirst($author->getName()));
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return ucfirst($author->getName());
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Author;
|
||||
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
|
||||
/**
|
||||
* Class SignupForm
|
||||
* @package Mageplaza\Blog\Block\Author
|
||||
*/
|
||||
class SignupForm extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrlSuffix()
|
||||
{
|
||||
return $this->helperData->getUrlSuffix();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
$author = $this->coreRegistry->registry('mp_author');
|
||||
|
||||
if ($author) {
|
||||
return [
|
||||
'name' => $author->getName(),
|
||||
'status' => $this->authorStatusType->toArray()[$author->getStatus()],
|
||||
'url_key' => $author->getUrlKey(),
|
||||
'short_description' => $author->getShortDescription(),
|
||||
'image' => $author->getImage(),
|
||||
'facebook_link' => $author->getFacebookLink(),
|
||||
'twitter_link' => $author->getTwitterLink(),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => '',
|
||||
'url_key' => '',
|
||||
'short_description' => '',
|
||||
'image' => '',
|
||||
'facebook_link' => '',
|
||||
'twitter_link' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
$array = explode('/', $this->helperData->getConfigValue('cms/wysiwyg/editor') ?? '');
|
||||
if ($array[count($array) - 1] === 'tinymce4Adapter') {
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMagentoVersion()
|
||||
{
|
||||
return (int)$this->helperData->versionCompare('2.4.0', '>=') ? '' : '4';
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Mageplaza
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Mageplaza.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.mageplaza.com/LICENSE.txt
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Mageplaza
|
||||
* @package Mageplaza_Blog
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Author;
|
||||
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\Author
|
||||
*/
|
||||
class Widget extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCurrentAuthor()
|
||||
{
|
||||
$authorId = $this->getRequest()->getParam('id');
|
||||
if ($authorId) {
|
||||
$author = $this->helperData->getObjectByParam($authorId, null, Data::TYPE_AUTHOR);
|
||||
if ($author && $author->getId()) {
|
||||
return $author;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user