init
This commit is contained in:
+407
@@ -0,0 +1,407 @@
|
||||
<?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\Api;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Exception\InputException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
|
||||
/**
|
||||
* Class PostInterface
|
||||
* @package Mageplaza\Blog\Api
|
||||
*/
|
||||
interface BlogRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getAllPost();
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\MonthlyArchiveInterface[]
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getMonthlyArchive();
|
||||
|
||||
/**
|
||||
* @param string $monthly
|
||||
* @param string $year
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostMonthlyArchive($monthly, $year);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getPostView($postId);
|
||||
|
||||
/**
|
||||
* @param string $authorName
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostViewByAuthorName($authorName);
|
||||
|
||||
/**
|
||||
* @param string $authorId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostViewByAuthorId($authorId);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CommentInterface[]
|
||||
*/
|
||||
public function getPostComment($postId);
|
||||
|
||||
/**
|
||||
* Get All Comment
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CommentInterface[]
|
||||
*/
|
||||
public function getAllComment();
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\SearchResult\CommentSearchResultInterface
|
||||
*/
|
||||
public function getCommentList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
|
||||
/**
|
||||
* @param string $commentId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CommentInterface
|
||||
*/
|
||||
public function getCommentView($commentId);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostLike($postId);
|
||||
|
||||
/**
|
||||
* @param string $tagName
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostByTagName($tagName);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return \Magento\Catalog\Api\Data\ProductInterface[]
|
||||
*/
|
||||
public function getProductByPost($postId);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function getPostRelated($postId);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
* @param \Mageplaza\Blog\Api\Data\CommentInterface $commentData
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CommentInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function addCommentInPost($postId, $commentData);
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\SearchResult\PostSearchResultInterface
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getPostList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
|
||||
/**
|
||||
* Create Post
|
||||
*
|
||||
* @param \Mageplaza\Blog\Api\Data\PostInterface $post
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createPost($post);
|
||||
|
||||
/**
|
||||
* Delete Post
|
||||
*
|
||||
* @param string $postId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deletePost($postId);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
* @param \Mageplaza\Blog\Api\Data\PostInterface $post
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface
|
||||
* @throws InputException
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updatePost($postId, $post);
|
||||
|
||||
/**
|
||||
* Get All Tag
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface[]
|
||||
*/
|
||||
public function getAllTag();
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\SearchResult\TagSearchResultInterface
|
||||
*/
|
||||
public function getTagList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
|
||||
/**
|
||||
* Create Post
|
||||
*
|
||||
* @param \Mageplaza\Blog\Api\Data\TagInterface $tag
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTag($tag);
|
||||
|
||||
/**
|
||||
* Delete Tag
|
||||
*
|
||||
* @param string $tagId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteTag($tagId);
|
||||
|
||||
/**
|
||||
* @param string $tagId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface
|
||||
*/
|
||||
public function getTagView($tagId);
|
||||
|
||||
/**
|
||||
* @param string $tagId
|
||||
* @param \Mageplaza\Blog\Api\Data\TagInterface $tag
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface
|
||||
* @throws InputException
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateTag($tagId, $tag);
|
||||
|
||||
/**
|
||||
* Get Topic List
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TopicInterface[]
|
||||
*/
|
||||
public function getAllTopic();
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\SearchResult\TopicSearchResultInterface
|
||||
*/
|
||||
public function getTopicList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
|
||||
/**
|
||||
* @param string $topicId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface
|
||||
*/
|
||||
public function getTopicView($topicId);
|
||||
|
||||
/**
|
||||
* @param string $topicId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostsByTopic($topicId);
|
||||
|
||||
/**
|
||||
* Create Topic
|
||||
*
|
||||
* @param \Mageplaza\Blog\Api\Data\TopicInterface $topic
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TopicInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createTopic($topic);
|
||||
|
||||
/**
|
||||
* Delete Topic
|
||||
*
|
||||
* @param string $topicId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteTopic($topicId);
|
||||
|
||||
/**
|
||||
* @param string $topicId
|
||||
* @param \Mageplaza\Blog\Api\Data\TopicInterface $topic
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\TopicInterface
|
||||
* @throws InputException
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateTopic($topicId, $topic);
|
||||
|
||||
/**
|
||||
* Get All Category
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface[]
|
||||
*/
|
||||
public function getAllCategory();
|
||||
|
||||
/**
|
||||
* Get Category List
|
||||
*
|
||||
* @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\SearchResult\CategorySearchResultInterface
|
||||
*/
|
||||
public function getCategoryList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria);
|
||||
|
||||
/**
|
||||
* @param string $categoryId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface
|
||||
*/
|
||||
public function getCategoryView($categoryId);
|
||||
|
||||
/**
|
||||
* @param string $categoryId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostsByCategoryId($categoryId);
|
||||
|
||||
/**
|
||||
* @param string $categoryKey
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getPostsByCategory($categoryKey);
|
||||
|
||||
/**
|
||||
* @param string $postId
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface[]
|
||||
*/
|
||||
public function getCategoriesByPostId($postId);
|
||||
|
||||
/**
|
||||
* Create Category
|
||||
*
|
||||
* @param \Mageplaza\Blog\Api\Data\CategoryInterface $category
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface
|
||||
* @throws Exception
|
||||
*/
|
||||
public function createCategory($category);
|
||||
|
||||
/**
|
||||
* Delete Category
|
||||
*
|
||||
* @param string $categoryId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteCategory($categoryId);
|
||||
|
||||
/**
|
||||
* @param string $categoryId
|
||||
* @param \Mageplaza\Blog\Api\Data\CategoryInterface $category
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface
|
||||
* @throws InputException
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateCategory($categoryId, $category);
|
||||
|
||||
/**
|
||||
* Get Author List
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\AuthorInterface[]
|
||||
*/
|
||||
public function getAuthorList();
|
||||
|
||||
/**
|
||||
* Create Author
|
||||
*
|
||||
* @param \Mageplaza\Blog\Api\Data\AuthorInterface $author
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\AuthorInterface
|
||||
* @throws NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\LocalizedException
|
||||
*/
|
||||
public function createAuthor($author);
|
||||
|
||||
/**
|
||||
* Delete Author
|
||||
*
|
||||
* @param string $authorId
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function deleteAuthor($authorId);
|
||||
|
||||
/**
|
||||
* @param string $authorId
|
||||
* @param \Mageplaza\Blog\Api\Data\AuthorInterface $author
|
||||
*
|
||||
* @return \Mageplaza\Blog\Api\Data\AuthorInterface
|
||||
* @throws InputException
|
||||
* @throws NoSuchEntityException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function updateAuthor($authorId, $author);
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\BlogConfigInterface
|
||||
*
|
||||
* @throws InputException
|
||||
*/
|
||||
public function getConfig();
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface AuthorInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface AuthorInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const AUTHOR_ID = 'user_id';
|
||||
const NAME = 'name';
|
||||
const URL_KEY = 'url_key';
|
||||
const SHORT_DESCRIPTION = 'short_description';
|
||||
const IMAGE = 'image';
|
||||
const CUSTOMER_ID = 'customer_id';
|
||||
const TYPE = 'type';
|
||||
const STATUS = 'status';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
const CREATED_AT = 'created_at';
|
||||
const FACEBOOK_LINK = 'facebook_link';
|
||||
const TWITTER_LINK = 'twitter_link';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::AUTHOR_ID,
|
||||
self::NAME,
|
||||
self::URL_KEY,
|
||||
self::SHORT_DESCRIPTION,
|
||||
self::IMAGE,
|
||||
self::CUSTOMER_ID,
|
||||
self::TYPE,
|
||||
self::STATUS,
|
||||
self::CREATED_AT,
|
||||
self::UPDATED_AT,
|
||||
self::FACEBOOK_LINK,
|
||||
self::TWITTER_LINK
|
||||
];
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getShortDescription();
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setShortDescription($content);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImage($content);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getUrlKey();
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrlKey($url);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param $createdAt
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setCreatedAt($createdAt);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* @param string $updatedAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdatedAt($updatedAt);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCustomerId();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCustomerId($id);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getType();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setType($id);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatus();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFacebookLink();
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFacebookLink($link);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTwitterLink();
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTwitterLink($link);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface BlogConfigInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface BlogConfigInterface
|
||||
{
|
||||
const GENERAL = 'general';
|
||||
const SIDEBAR = 'sidebar';
|
||||
const SEO = 'seo';
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\Config\GeneralInterface
|
||||
*/
|
||||
public function getGeneral();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\Config\GeneralInterface $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setGeneral($value);
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\Config\SidebarInterface
|
||||
*/
|
||||
public function getSidebar();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\Config\SidebarInterface $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSidebar($value);
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\Config\SeoInterface
|
||||
*/
|
||||
public function getSeo();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\Config\SeoInterface $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setSeo($value);
|
||||
}
|
||||
+337
@@ -0,0 +1,337 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface CategoryInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface CategoryInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const CATEGORY_ID = 'category_id';
|
||||
const NAME = 'name';
|
||||
const URL_KEY = 'url_key';
|
||||
const DESCRIPTION = 'description';
|
||||
const STORE_IDS = 'store_ids';
|
||||
const ENABLED = 'enabled';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
const CREATED_AT = 'created_at';
|
||||
const META_TITLE = 'meta_title';
|
||||
const META_DESCRIPTION = 'meta_description';
|
||||
const META_KEYWORDS = 'meta_keywords';
|
||||
const META_ROBOTS = 'meta_robots';
|
||||
const IMPORT_SOURCE = 'import_source';
|
||||
const PARENT_ID = 'parent_id';
|
||||
const PATH = 'path';
|
||||
const POSITION = 'position';
|
||||
const LEVEL = 'level';
|
||||
const CHILDREN_COUNT = 'children_count';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::CATEGORY_ID,
|
||||
self::NAME,
|
||||
self::DESCRIPTION,
|
||||
self::STORE_IDS,
|
||||
self::ENABLED,
|
||||
self::URL_KEY,
|
||||
self::META_TITLE,
|
||||
self::META_DESCRIPTION,
|
||||
self::META_KEYWORDS,
|
||||
self::META_ROBOTS,
|
||||
self::PARENT_ID,
|
||||
self::PATH,
|
||||
self::POSITION,
|
||||
self::LEVEL,
|
||||
self::CHILDREN_COUNT
|
||||
];
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get Post Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Set Post Short Description
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($content);
|
||||
|
||||
/**
|
||||
* Get Post Store Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getStoreIds();
|
||||
|
||||
/**
|
||||
* Set Post Store Id
|
||||
*
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreIds($storeId);
|
||||
|
||||
/**
|
||||
* Get Post Image
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* Set Post Image
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImage($content);
|
||||
|
||||
/**
|
||||
* Get Post Enabled
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getEnabled();
|
||||
|
||||
/**
|
||||
* Set Post Enabled
|
||||
*
|
||||
* @param int $enabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnabled($enabled);
|
||||
|
||||
/**
|
||||
* Get Post Url Key
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getUrlKey();
|
||||
|
||||
/**
|
||||
* Set Post Url Key
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrlKey($url);
|
||||
|
||||
/**
|
||||
* Get Post Meta Title
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaTitle();
|
||||
|
||||
/**
|
||||
* Set Post Meta Title
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaTitle($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaDescription();
|
||||
|
||||
/**
|
||||
* Set Post Meta Description
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaDescription($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Keywords
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaKeywords();
|
||||
|
||||
/**
|
||||
* Set Post Meta Keywords
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaKeywords($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Robots
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaRobots();
|
||||
|
||||
/**
|
||||
* Set Post Meta Robots
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaRobots($meta);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedAt($createdAt);
|
||||
|
||||
/**
|
||||
* Get Post updated date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* Set Post updated date
|
||||
*
|
||||
* @param string $updatedAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdatedAt($updatedAt);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImportSource();
|
||||
|
||||
/**
|
||||
* @param string $importSource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImportSource($importSource);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getParentId();
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParentId($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPath();
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPath($path);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPosition();
|
||||
|
||||
/**
|
||||
* @param int $position
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPosition($position);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getLevel();
|
||||
|
||||
/**
|
||||
* @param int $level
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLevel($level);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getChildrenCount();
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setChildrenCount($count);
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface CommentInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface CommentInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const COMMENT_ID = 'comment_id';
|
||||
const POST_ID = 'post_id';
|
||||
const CONTENT = 'content';
|
||||
const STORE_IDS = 'store_ids';
|
||||
const CREATED_AT = 'created_at';
|
||||
const STATUS = 'status';
|
||||
const IMPORT_SOURCE = 'import_source';
|
||||
const USER_NAME = 'user_name';
|
||||
const USER_EMAIL = 'user_email';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::COMMENT_ID,
|
||||
self::POST_ID,
|
||||
self::CONTENT,
|
||||
self::STORE_IDS,
|
||||
self::CREATED_AT,
|
||||
self::USER_EMAIL,
|
||||
self::USER_NAME,
|
||||
self::IMPORT_SOURCE
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Comment id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Set Comment Id
|
||||
*
|
||||
* @param int $commentId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($commentId);
|
||||
|
||||
/**
|
||||
* Get Post id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getPostId();
|
||||
|
||||
/**
|
||||
* Set Post Id
|
||||
*
|
||||
* @param int $postId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostId($postId);
|
||||
|
||||
/**
|
||||
* @return int|null
|
||||
*/
|
||||
public function getStatus();
|
||||
|
||||
/**
|
||||
* Set Status Id
|
||||
*
|
||||
* @param string $status
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($status);
|
||||
|
||||
/**
|
||||
* Get Comment content
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getContent();
|
||||
|
||||
/**
|
||||
* Set Content
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content);
|
||||
|
||||
/**
|
||||
* Get Post Store Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getStoreIds();
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreIds($id);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedAt($date);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImportSource();
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUserEmail();
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUserEmail($email);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUserName();
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUserName($name);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?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\Api\Data\Config;
|
||||
|
||||
/**
|
||||
* Interface GeneralInterface
|
||||
* @package Mageplaza\Blog\Api\Data\Config
|
||||
*/
|
||||
interface GeneralInterface
|
||||
{
|
||||
const BLOG_NAME = 'blog_name';
|
||||
const IS_LINK_IN_MENU = 'is_link_in_menu';
|
||||
const IS_DISPLAY_AUTHOR = 'is_display_author';
|
||||
const BLOG_MODE = 'blog_mode';
|
||||
const BLOG_COLOR = 'blog_color';
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getBlogName();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBlogName($value);
|
||||
|
||||
/**
|
||||
* @return boolean/null
|
||||
*/
|
||||
public function getIsLinkInMenu();
|
||||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsLinkInMenu($value);
|
||||
|
||||
/**
|
||||
* @return boolean/null
|
||||
*/
|
||||
public function getIsDisplayAuthor();
|
||||
|
||||
/**
|
||||
* @param boolean $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsDisplayAuthor($value);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getBlogMode();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBlogMode($value);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getBlogColor();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setBlogColor($value);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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\Api\Data\Config;
|
||||
|
||||
/**
|
||||
* Interface SeoInterface
|
||||
* @package Mageplaza\Blog\Api\Data\Config
|
||||
*/
|
||||
interface SeoInterface
|
||||
{
|
||||
const META_TITLE = 'meta_title';
|
||||
const META_DESCRIPTION = 'meta_description';
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaTitle();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaTitle($value);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaDescription();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaDescription($value);
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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\Api\Data\Config;
|
||||
|
||||
/**
|
||||
* Interface SidebarInterface
|
||||
* @package Mageplaza\Blog\Api\Data\Config
|
||||
*/
|
||||
interface SidebarInterface
|
||||
{
|
||||
const NUMBER_RECENT = 'number_recent';
|
||||
const NUMBER_MOST_VIEW = 'number_most_view';
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getNumberRecent();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNumberRecent($value);
|
||||
|
||||
/**
|
||||
* @return string/null
|
||||
*/
|
||||
public function getNumberMostView();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNumberMostView($value);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface MonthlyArchiveInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface MonthlyArchiveInterface
|
||||
{
|
||||
const LABEL = 'label';
|
||||
const POST_COUNT = 'post_count';
|
||||
const LINK = 'link';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLabel();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLabel($value);
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getPostCount();
|
||||
|
||||
/**
|
||||
* @param int $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostCount($value);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLink();
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLink($value);
|
||||
}
|
||||
+463
@@ -0,0 +1,463 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface PostInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface PostInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const POST_ID = 'post_id';
|
||||
const NAME = 'name';
|
||||
const SHORT_DESCRIPTION = 'short_description';
|
||||
const POST_CONTENT = 'post_content';
|
||||
const STORE_IDS = 'store_ids';
|
||||
const IMAGE = 'image';
|
||||
const ENABLED = 'enabled';
|
||||
const URL_KEY = 'url_key';
|
||||
const IN_RSS = 'in_rss';
|
||||
const ALLOW_COMMENT = 'allow_comment';
|
||||
const META_TITLE = 'meta_title';
|
||||
const META_DESCRIPTION = 'meta_description';
|
||||
const META_KEYWORDS = 'meta_keywords';
|
||||
const META_ROBOTS = 'meta_robots';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
const CREATED_AT = 'created_at';
|
||||
const AUTHOR_ID = 'author_id';
|
||||
const MODIFIER_ID = 'modifier_id';
|
||||
const PUBLISH_DATE = 'publish_date';
|
||||
const IMPORT_SOURCE = 'import_source';
|
||||
const LAYOUT = 'layout';
|
||||
const CATEGORY_IDS = 'category_ids';
|
||||
const TAG_IDS = 'tag_ids';
|
||||
const TOPIC_IDS = 'topic_ids';
|
||||
const AUTHOR_URL = 'author_url';
|
||||
const AUTHOR_NAME = 'author_name';
|
||||
const VIEW_TRAFFIC = 'view_traffic';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::POST_ID,
|
||||
self::NAME,
|
||||
self::SHORT_DESCRIPTION,
|
||||
self::POST_CONTENT,
|
||||
self::STORE_IDS,
|
||||
self::IMAGE,
|
||||
self::ENABLED,
|
||||
self::URL_KEY,
|
||||
self::IN_RSS,
|
||||
self::ALLOW_COMMENT,
|
||||
self::META_TITLE,
|
||||
self::META_DESCRIPTION,
|
||||
self::META_KEYWORDS,
|
||||
self::META_ROBOTS,
|
||||
self::AUTHOR_ID,
|
||||
self::MODIFIER_ID,
|
||||
self::PUBLISH_DATE,
|
||||
self::IMPORT_SOURCE,
|
||||
self::LAYOUT,
|
||||
self::CATEGORY_IDS,
|
||||
self::TAG_IDS,
|
||||
self::TOPIC_IDS,
|
||||
self::AUTHOR_NAME,
|
||||
self::AUTHOR_URL,
|
||||
self::VIEW_TRAFFIC
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Post id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Set Post id
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* Get Post Name
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set Post Name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get Post Short Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getShortDescription();
|
||||
|
||||
/**
|
||||
* Set Post Short Description
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setShortDescription($content);
|
||||
|
||||
/**
|
||||
* Get Post Content
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getPostContent();
|
||||
|
||||
/**
|
||||
* Set Post Content
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPostContent($content);
|
||||
|
||||
/**
|
||||
* Get Post Store Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getStoreIds();
|
||||
|
||||
/**
|
||||
* Set Post Store Id
|
||||
*
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreIds($storeId);
|
||||
|
||||
/**
|
||||
* Get Post Image
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* Set Post Image
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImage($content);
|
||||
|
||||
/**
|
||||
* Get Post Enabled
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getEnabled();
|
||||
|
||||
/**
|
||||
* Set Post Enabled
|
||||
*
|
||||
* @param int $enabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnabled($enabled);
|
||||
|
||||
/**
|
||||
* Get Post Url Key
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getUrlKey();
|
||||
|
||||
/**
|
||||
* Set Post Url Key
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrlKey($url);
|
||||
|
||||
/**
|
||||
* Get Post In RSS
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getInRss();
|
||||
|
||||
/**
|
||||
* Set Post Enabled
|
||||
*
|
||||
* @param int $inRss
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setInRss($inRss);
|
||||
|
||||
/**
|
||||
* Get Post Allow Comment
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getAllowComment();
|
||||
|
||||
/**
|
||||
* Set Post Allow Comment
|
||||
*
|
||||
* @param int $allow
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAllowComment($allow);
|
||||
|
||||
/**
|
||||
* Get Post Meta Title
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaTitle();
|
||||
|
||||
/**
|
||||
* Set Post Meta Title
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaTitle($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaDescription();
|
||||
|
||||
/**
|
||||
* Set Post Meta Description
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaDescription($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Keywords
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaKeywords();
|
||||
|
||||
/**
|
||||
* Set Post Meta Keywords
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaKeywords($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Robots
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaRobots();
|
||||
|
||||
/**
|
||||
* Set Post Meta Robots
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaRobots($meta);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedAt($createdAt);
|
||||
|
||||
/**
|
||||
* Get Post updated date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* Set Post updated date
|
||||
*
|
||||
* @param string $updatedAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdatedAt($updatedAt);
|
||||
|
||||
/**
|
||||
* Get Post Author Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getAuthorId();
|
||||
|
||||
/**
|
||||
* Set Post Store Id
|
||||
*
|
||||
* @param int $authorId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthorId($authorId);
|
||||
|
||||
/**
|
||||
* Get Post Modifier Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getModifierId();
|
||||
|
||||
/**
|
||||
* Set Post Modifier Id
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setModifierId($id);
|
||||
|
||||
/**
|
||||
* get Post Publish date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPublishDate();
|
||||
|
||||
/**
|
||||
* Set Post Publish date
|
||||
*
|
||||
* @param string $publishDate
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPublishDate($publishDate);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImportSource();
|
||||
|
||||
/**
|
||||
* @param string $importSource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImportSource($importSource);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLayout();
|
||||
|
||||
/**
|
||||
* @param string $layout
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLayout($layout);
|
||||
|
||||
/**
|
||||
* @return int[]|null
|
||||
*/
|
||||
public function getCategoryIds();
|
||||
|
||||
/**
|
||||
* @param int[] $array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategoryIds($array);
|
||||
|
||||
/**
|
||||
* @return int[]|null
|
||||
*/
|
||||
public function getTagIds();
|
||||
|
||||
/**
|
||||
* @param int[] $array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTagIds($array);
|
||||
|
||||
/**
|
||||
* @return int[]|null
|
||||
*/
|
||||
public function getTopicIds();
|
||||
|
||||
/**
|
||||
* @param int[] $array
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTopicIds($array);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthorName();
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthorUrl();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getViewTraffic();
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Api\Data\SearchResult;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
/**
|
||||
* Interface CategorySearchResultInterface
|
||||
* @package Mageplaza\Blog\Api\Data\SearchResult
|
||||
*/
|
||||
interface CategorySearchResultInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\CategoryInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\CategoryInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(?array $items = null);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Api\Data\SearchResult;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
/**
|
||||
* Interface CommentSearchResultInterface
|
||||
* @api
|
||||
*/
|
||||
interface CommentSearchResultInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\CommentInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\CommentInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(?array $items = null);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Api\Data\SearchResult;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
/**
|
||||
* Interface PostSearchResultInterface
|
||||
* @api
|
||||
*/
|
||||
interface PostSearchResultInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\PostInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\PostInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(?array $items = null);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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\Api\Data\SearchResult;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
/**
|
||||
* Interface TagSearchResultInterface
|
||||
* @package Mageplaza\Blog\Api\Data\SearchResult
|
||||
*/
|
||||
interface TagSearchResultInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\TagInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\TagInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(?array $items = null);
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?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\Api\Data\SearchResult;
|
||||
|
||||
use Magento\Framework\Api\SearchResultsInterface;
|
||||
|
||||
/**
|
||||
* Interface TopicSearchResultInterface
|
||||
* @package Mageplaza\Blog\Api\Data\SearchResult
|
||||
*/
|
||||
interface TopicSearchResultInterface extends SearchResultsInterface
|
||||
{
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Api\Data\TopicInterface[]
|
||||
*/
|
||||
public function getItems();
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Api\Data\TopicInterface[] $items
|
||||
* @return $this
|
||||
*/
|
||||
public function setItems(?array $items = null);
|
||||
}
|
||||
+276
@@ -0,0 +1,276 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface TagInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface TagInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const TAG_ID = 'tag_id';
|
||||
const NAME = 'name';
|
||||
const URL_KEY = 'url_key';
|
||||
const DESCRIPTION = 'description';
|
||||
const STORE_IDS = 'store_ids';
|
||||
const ENABLED = 'enabled';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
const CREATED_AT = 'created_at';
|
||||
const META_TITLE = 'meta_title';
|
||||
const META_DESCRIPTION = 'meta_description';
|
||||
const META_KEYWORDS = 'meta_keywords';
|
||||
const META_ROBOTS = 'meta_robots';
|
||||
const IMPORT_SOURCE = 'import_source';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::TAG_ID,
|
||||
self::NAME,
|
||||
self::DESCRIPTION,
|
||||
self::STORE_IDS,
|
||||
self::ENABLED,
|
||||
self::URL_KEY,
|
||||
self::META_TITLE,
|
||||
self::META_DESCRIPTION,
|
||||
self::META_KEYWORDS,
|
||||
self::META_ROBOTS,
|
||||
self::IMPORT_SOURCE
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Post id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Set Post id
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* Get Post Name
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set Post Name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get Post Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Set Post Short Description
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($content);
|
||||
|
||||
/**
|
||||
* Get Post Store Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getStoreIds();
|
||||
|
||||
/**
|
||||
* Set Post Store Id
|
||||
*
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreIds($storeId);
|
||||
|
||||
/**
|
||||
* Get Post Image
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* Set Post Image
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImage($content);
|
||||
|
||||
/**
|
||||
* Get Post Enabled
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getEnabled();
|
||||
|
||||
/**
|
||||
* Set Post Enabled
|
||||
*
|
||||
* @param int $enabled
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setEnabled($enabled);
|
||||
|
||||
/**
|
||||
* Get Post Url Key
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getUrlKey();
|
||||
|
||||
/**
|
||||
* Set Post Url Key
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrlKey($url);
|
||||
|
||||
/**
|
||||
* Get Post Meta Title
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaTitle();
|
||||
|
||||
/**
|
||||
* Set Post Meta Title
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaTitle($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaDescription();
|
||||
|
||||
/**
|
||||
* Set Post Meta Description
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaDescription($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Keywords
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaKeywords();
|
||||
|
||||
/**
|
||||
* Set Post Meta Keywords
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaKeywords($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Robots
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaRobots();
|
||||
|
||||
/**
|
||||
* Set Post Meta Robots
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaRobots($meta);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedAt($createdAt);
|
||||
|
||||
/**
|
||||
* Get Post updated date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* Set Post updated date
|
||||
*
|
||||
* @param string $updatedAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdatedAt($updatedAt);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImportSource();
|
||||
|
||||
/**
|
||||
* @param string $importSource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImportSource($importSource);
|
||||
}
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
<?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\Api\Data;
|
||||
|
||||
/**
|
||||
* Interface TopicInterface
|
||||
* @package Mageplaza\Blog\Api\Data
|
||||
*/
|
||||
interface TopicInterface
|
||||
{
|
||||
/**
|
||||
* Constants used as data array keys
|
||||
*/
|
||||
const TOPIC_ID = 'topic_id';
|
||||
const NAME = 'name';
|
||||
const DESCRIPTION = 'description';
|
||||
const STORE_IDS = 'store_ids';
|
||||
const URL_KEY = 'url_key';
|
||||
const META_TITLE = 'meta_title';
|
||||
const META_DESCRIPTION = 'meta_description';
|
||||
const META_KEYWORDS = 'meta_keywords';
|
||||
const META_ROBOTS = 'meta_robots';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
const CREATED_AT = 'created_at';
|
||||
const IMPORT_SOURCE = 'import_source';
|
||||
|
||||
const ATTRIBUTES = [
|
||||
self::TOPIC_ID,
|
||||
self::NAME,
|
||||
self::DESCRIPTION,
|
||||
self::STORE_IDS,
|
||||
self::URL_KEY,
|
||||
self::META_TITLE,
|
||||
self::META_DESCRIPTION,
|
||||
self::META_KEYWORDS,
|
||||
self::META_ROBOTS,
|
||||
self::IMPORT_SOURCE
|
||||
];
|
||||
|
||||
/**
|
||||
* Get Post id
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Set Post id
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id);
|
||||
|
||||
/**
|
||||
* Get Post Name
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* Set Post Name
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get Post Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Set Post Short Description
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDescription($content);
|
||||
|
||||
/**
|
||||
* Get Post Store Id
|
||||
*
|
||||
* @return int/null
|
||||
*/
|
||||
public function getStoreIds();
|
||||
|
||||
/**
|
||||
* Set Post Store Id
|
||||
*
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStoreIds($storeId);
|
||||
|
||||
/**
|
||||
* Get Post Image
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getImage();
|
||||
|
||||
/**
|
||||
* Set Post Image
|
||||
*
|
||||
* @param string $content
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImage($content);
|
||||
|
||||
/**
|
||||
* Get Post Url Key
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getUrlKey();
|
||||
|
||||
/**
|
||||
* Set Post Url Key
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUrlKey($url);
|
||||
|
||||
/**
|
||||
* Get Post Meta Title
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaTitle();
|
||||
|
||||
/**
|
||||
* Set Post Meta Title
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaTitle($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Description
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaDescription();
|
||||
|
||||
/**
|
||||
* Set Post Meta Description
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaDescription($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Keywords
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaKeywords();
|
||||
|
||||
/**
|
||||
* Set Post Meta Keywords
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaKeywords($meta);
|
||||
|
||||
/**
|
||||
* Get Post Meta Robots
|
||||
*
|
||||
* @return string/null
|
||||
*/
|
||||
public function getMetaRobots();
|
||||
|
||||
/**
|
||||
* Set Post Meta Robots
|
||||
*
|
||||
* @param string $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMetaRobots($meta);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCreatedAt();
|
||||
|
||||
/**
|
||||
* @param string $createdAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCreatedAt($createdAt);
|
||||
|
||||
/**
|
||||
* Get Post updated date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getUpdatedAt();
|
||||
|
||||
/**
|
||||
* Set Post updated date
|
||||
*
|
||||
* @param string $updatedAt
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setUpdatedAt($updatedAt);
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getImportSource();
|
||||
|
||||
/**
|
||||
* @param string $importSource
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setImportSource($importSource);
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?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_RewardPoints
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Author;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
|
||||
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
|
||||
use Magento\Framework\Registry;
|
||||
|
||||
/**
|
||||
* Class CustomerGrid
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Author
|
||||
*/
|
||||
class CustomerGrid extends Extended
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
* @var Registry
|
||||
*/
|
||||
protected $_coreRegistry = null;
|
||||
|
||||
/**
|
||||
* @var CustomerCollectionFactory
|
||||
*/
|
||||
protected $_customerCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $customerGroup;
|
||||
|
||||
/**
|
||||
* CustomerGrid constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $backendHelper
|
||||
* @param CustomerCollectionFactory $customerFactory
|
||||
* @param CollectionFactory $customerGroup
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $backendHelper,
|
||||
CustomerCollectionFactory $customerFactory,
|
||||
CollectionFactory $customerGroup,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_customerCollectionFactory = $customerFactory;
|
||||
$this->customerGroup = $customerGroup;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('customer-grid');
|
||||
$this->setDefaultSort('entity_id');
|
||||
$this->setUseAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Grid
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
$collection = $this->_customerCollectionFactory->create();
|
||||
$collection->getSelect()->joinLeft(
|
||||
['author' => $collection->getTable('mageplaza_blog_author')],
|
||||
'e.entity_id = author.customer_id',
|
||||
['author.user_id AS user_id']
|
||||
)->where('author.user_id IS NULL')->getConnection();
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Extended
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('customer_id', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'radio',
|
||||
'html_name' => 'customer_id',
|
||||
'align' => 'center',
|
||||
'index' => 'entity_id',
|
||||
'filter' => false,
|
||||
'sortable' => false
|
||||
]);
|
||||
$this->addColumn('entity_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'entity_id'
|
||||
]);
|
||||
$this->addColumn('firstname', [
|
||||
'header' => __('First Name'),
|
||||
'index' => 'firstname',
|
||||
'type' => 'text',
|
||||
'sortable' => true,
|
||||
]);
|
||||
$this->addColumn('lastname', [
|
||||
'header' => __('Last Name'),
|
||||
'index' => 'lastname',
|
||||
'type' => 'text',
|
||||
'sortable' => true,
|
||||
]);
|
||||
$this->addColumn('email', [
|
||||
'header' => __('Email'),
|
||||
'index' => 'email',
|
||||
'type' => 'text',
|
||||
'sortable' => true,
|
||||
]);
|
||||
$this->addColumn('group_id', [
|
||||
'header' => __('Group'),
|
||||
'index' => 'group_id',
|
||||
'type' => 'options',
|
||||
'options' => $this->customerGroup->create()->toOptionHash(),
|
||||
'sortable' => true,
|
||||
]);
|
||||
|
||||
return parent::_prepareColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/author/customergrid', ['_current' => true]);
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?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\Adminhtml\Author;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Author;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Author
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Post edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_objectId = 'user_id';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_author';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
$this->buttonList->add('save-and-continue', [
|
||||
'label' => __('Save And Continue Edit'),
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
], -100);
|
||||
|
||||
$this->buttonList->add(
|
||||
'delete',
|
||||
[
|
||||
'label' => __('Delete'),
|
||||
'class' => 'delete',
|
||||
'onclick' => "setLocation('{$this->getUrl('mageplaza_blog/author/delete', [
|
||||
'id' => $this->getCurrentAuthor()->getId(),
|
||||
'_current' => true,
|
||||
'back' => 'edit'
|
||||
])}')",
|
||||
],
|
||||
-101
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Author $author */
|
||||
$author = $this->getCurrentAuthor();
|
||||
if ($author->getId()) {
|
||||
return __("Edit Author '%1'", $this->escapeHtml($author->getName()));
|
||||
}
|
||||
|
||||
return __('New Author');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author
|
||||
*/
|
||||
public function getCurrentAuthor()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_author');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Adminhtml\Author\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Author\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,332 @@
|
||||
<?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\Adminhtml\Author\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Framework\Data\Form;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Store\Model\System\Store;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Renderer\Image;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Helper\Image as ImageHelper;
|
||||
use Mageplaza\Blog\Model\Config\Source\AuthorStatus;
|
||||
|
||||
/**
|
||||
* Class Author
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Author\Edit\Tab
|
||||
*/
|
||||
class Author extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
public $systemStore;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
public $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* @var ImageHelper
|
||||
*/
|
||||
protected $imageHelper;
|
||||
|
||||
/**
|
||||
* @var AuthorStatus
|
||||
*/
|
||||
protected $authorStatus;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* @var CustomerRepositoryInterface
|
||||
*/
|
||||
protected $customerRepository;
|
||||
|
||||
/**
|
||||
* Author constructor.
|
||||
*
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Store $systemStore
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param ImageHelper $imageHelper
|
||||
* @param AuthorStatus $authorStatus
|
||||
* @param Data $helperData
|
||||
* @param CustomerRepositoryInterface $customerRepository
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Config $wysiwygConfig,
|
||||
Store $systemStore,
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
ImageHelper $imageHelper,
|
||||
AuthorStatus $authorStatus,
|
||||
Data $helperData,
|
||||
CustomerRepositoryInterface $customerRepository,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->imageHelper = $imageHelper;
|
||||
$this->authorStatus = $authorStatus;
|
||||
$this->_helperData = $helperData;
|
||||
$this->customerRepository = $customerRepository;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Author $author */
|
||||
$author = $this->_coreRegistry->registry('mageplaza_blog_author');
|
||||
|
||||
/** @var Form $form */
|
||||
$form = $this->_formFactory->create();
|
||||
$form->setHtmlIdPrefix('author_');
|
||||
$form->setFieldNameSuffix('author');
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Author Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
if ($author->getId()) {
|
||||
$fieldset->addField('user_id', 'hidden', ['name' => 'user_id']);
|
||||
}
|
||||
|
||||
if ($this->checkCustomerId($author->getCustomerId())) {
|
||||
$fieldset->addField('customer_id', 'hidden', [
|
||||
'name' => 'customer_id',
|
||||
'value' => $author->getCustomerId()
|
||||
]);
|
||||
$customer = $this->customerRepository->getById($author->getCustomerId());
|
||||
|
||||
$fieldset->addField('customer', 'label', [
|
||||
'name' => 'customer',
|
||||
'label' => __('Customer'),
|
||||
'title' => __('Customer'),
|
||||
'value' => $customer->getFirstname() . ' ' . $customer->getLastname()
|
||||
]);
|
||||
} else {
|
||||
$fieldset->addField('customer', 'text', [
|
||||
'name' => 'customer',
|
||||
'label' => __('Customer'),
|
||||
'title' => __('Customer')
|
||||
])->setAfterElementHtml(
|
||||
'<div id="customer-grid" style="display:none"></div>
|
||||
<script type="text/x-magento-init">
|
||||
{
|
||||
"#author_customer": {
|
||||
"Mageplaza_Blog/js/view/author":{
|
||||
"url": "' . $this->getAjaxUrl() . '"
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>'
|
||||
);
|
||||
$fieldset->addField('customer_id', 'hidden', [
|
||||
'name' => 'customer_id',
|
||||
'value' => 0
|
||||
]);
|
||||
}
|
||||
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Display Name'),
|
||||
'title' => __('Display Name'),
|
||||
'required' => true,
|
||||
'note' => __('This name will be displayed on frontend')
|
||||
]);
|
||||
|
||||
$fieldset->addField('status', 'select', [
|
||||
'name' => 'status',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->authorStatus->toArray()
|
||||
]);
|
||||
|
||||
$fieldset->addField('type', 'hidden', [
|
||||
'name' => 'type',
|
||||
'value' => 0
|
||||
]);
|
||||
|
||||
$fieldset->addField('short_description', 'editor', [
|
||||
'name' => 'short_description',
|
||||
'label' => __('Short Description'),
|
||||
'title' => __('Short Description'),
|
||||
'note' => __('Short Description'),
|
||||
'config' => $this->wysiwygConfig->getConfig([
|
||||
'add_variables' => false,
|
||||
'add_widgets' => false,
|
||||
'add_directives' => true
|
||||
])
|
||||
]);
|
||||
|
||||
$fieldset->addField('image', Image::class, [
|
||||
'name' => 'image',
|
||||
'label' => __('Avatar'),
|
||||
'title' => __('Avatar'),
|
||||
'path' => $this->imageHelper->getBaseMediaPath(ImageHelper::TEMPLATE_MEDIA_TYPE_AUTH)
|
||||
]);
|
||||
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
|
||||
$authorUrlFormat = $this->_storeManager->getDefaultStoreView()->getBaseUrl(UrlInterface::URL_TYPE_LINK)
|
||||
. 'blog/author/';
|
||||
$urlSuffix = $this->_helperData->getUrlSuffix();
|
||||
|
||||
$fieldset->addField(
|
||||
'full_url',
|
||||
'label',
|
||||
[
|
||||
'label' => __('Full URL'),
|
||||
'value' => $author->getUrlKey() ? $authorUrlFormat . $author->getUrlKey() . $urlSuffix : ''
|
||||
]
|
||||
)->setAfterElementHtml(
|
||||
"<script>
|
||||
require(['jquery'], function($){
|
||||
$('#author_url_key').on('keyup', function() {
|
||||
var url = '" . $authorUrlFormat . "'+$(this).val()+'" . $urlSuffix . "';
|
||||
|
||||
if ($(this).val() === ''){
|
||||
url = '';
|
||||
}
|
||||
$('.field-full_url .control-value').html(url);
|
||||
});
|
||||
});
|
||||
</script>"
|
||||
);
|
||||
|
||||
$fieldset->addField('facebook_link', 'text', [
|
||||
'name' => 'facebook_link',
|
||||
'label' => __('Facebook'),
|
||||
'title' => __('Facebook'),
|
||||
'note' => __('Facebook URL'),
|
||||
'required' => false,
|
||||
'class' => 'validate-url'
|
||||
]);
|
||||
|
||||
$fieldset->addField('twitter_link', 'text', [
|
||||
'name' => 'twitter_link',
|
||||
'label' => __('Twitter'),
|
||||
'title' => __('Twitter'),
|
||||
'note' => __('Twitter URL'),
|
||||
'required' => false,
|
||||
'class' => 'validate-url'
|
||||
]);
|
||||
|
||||
$form->addValues($author->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $customerId
|
||||
*
|
||||
* @return bool
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function checkCustomerId($customerId)
|
||||
{
|
||||
try {
|
||||
if ($this->customerRepository->getById($customerId)) {
|
||||
return true;
|
||||
}
|
||||
} catch (NoSuchEntityException $noSuchEntityException) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Author Info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get transaction grid url
|
||||
* @return string
|
||||
*/
|
||||
public function getAjaxUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/author/customergrid');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?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\Adminhtml\Author\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit\Tab
|
||||
*/
|
||||
class Post extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Post collection factory
|
||||
*
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
public $postCollectionFactory;
|
||||
|
||||
/**
|
||||
* Registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Post factory
|
||||
*
|
||||
* @var PostFactory
|
||||
*/
|
||||
public $postFactory;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param PostFactory $postFactory
|
||||
* @param CollectionFactory $postCollectionFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
PostFactory $postFactory,
|
||||
CollectionFactory $postCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->postFactory = $postFactory;
|
||||
$this->postCollectionFactory = $postCollectionFactory;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('post_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setUseAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->postCollectionFactory->create();
|
||||
$collection->addFieldToFilter('author_id', $this->getAuthor()->getId());
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('post_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'post_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('publish_date', [
|
||||
'header' => __('Published'),
|
||||
'index' => 'publish_date',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Model\Post|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/post/edit', ['id' => $item->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/postsgrid', ['id' => $this->getAuthor()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Author
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_author');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Posts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/author/posts', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Adminhtml\Author\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Author\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('author_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Author Information'));
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?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\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Container;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
* @package Mageplaza\Blog\Block\Adminhtml
|
||||
*/
|
||||
class Category extends Container
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'adminhtml_category';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_headerText = __('Categories');
|
||||
$this->_addButtonLabel = __('Create New Blog Category');
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
<?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\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\Category;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Category
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $helperData
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $coreRegistry,
|
||||
Data $helperData,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->_helperData = $helperData;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* prepare the form
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_objectId = 'id';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_category';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
/** @var Category $category */
|
||||
$category = $this->coreRegistry->registry('category');
|
||||
|
||||
if ($category->getId() && !$category->getDuplicate()) {
|
||||
$this->buttonList->add(
|
||||
'duplicate',
|
||||
[
|
||||
'label' => __('Duplicate'),
|
||||
'class' => 'duplicate',
|
||||
'onclick' => sprintf("location.href = '%s';", $this->getDuplicateUrl()),
|
||||
],
|
||||
-101
|
||||
);
|
||||
}
|
||||
|
||||
$this->buttonList->remove('delete');
|
||||
$this->buttonList->remove('back');
|
||||
$this->buttonList->remove('reset');
|
||||
$this->buttonList->remove('save');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getDuplicateUrl()
|
||||
{
|
||||
/** @var Category $category */
|
||||
$category = $this->coreRegistry->registry('category');
|
||||
|
||||
return $this->getUrl(
|
||||
'*/*/duplicate',
|
||||
['id' => $category->getId(), 'duplicate' => true, 'parent' => $category->getParentId()]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMagentoVersion()
|
||||
{
|
||||
return (int)$this->_helperData->versionCompare('2.4.0', '>=') ? '' : '4';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,361 @@
|
||||
<?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\Adminhtml\Category\Edit;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Button;
|
||||
use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory;
|
||||
use Magento\Catalog\Model\Category;
|
||||
use Magento\Catalog\Model\CategoryFactory;
|
||||
use Magento\Catalog\Model\ResourceModel\Category\Tree;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Element\BlockInterface;
|
||||
use Mageplaza\Blog\Model\Category as BlogCategory;
|
||||
use Mageplaza\Blog\Model\CategoryFactory as BlogCategoryFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Tree as BlogResourceTree;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Category\Edit
|
||||
*/
|
||||
class Form extends AbstractCategory
|
||||
{
|
||||
/**
|
||||
* @var array Additional buttons
|
||||
*/
|
||||
public $additionalButtons = [];
|
||||
|
||||
/**
|
||||
* @var string Block template
|
||||
*/
|
||||
protected $_template = 'category/edit/form.phtml';
|
||||
|
||||
/**
|
||||
* @var EncoderInterface
|
||||
*/
|
||||
public $jsonEncoder;
|
||||
|
||||
/**
|
||||
* Form constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Tree $categoryTree
|
||||
* @param Registry $registry
|
||||
* @param CategoryFactory $categoryFactory
|
||||
* @param BlogResourceTree $blogCategoryTree
|
||||
* @param BlogCategoryFactory $blogCategoryFactory
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Tree $categoryTree,
|
||||
Registry $registry,
|
||||
CategoryFactory $categoryFactory,
|
||||
BlogResourceTree $blogCategoryTree,
|
||||
BlogCategoryFactory $blogCategoryFactory,
|
||||
EncoderInterface $jsonEncoder,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct($context, $categoryTree, $registry, $categoryFactory, $data);
|
||||
|
||||
$this->jsonEncoder = $jsonEncoder;
|
||||
$this->_categoryTree = $blogCategoryTree;
|
||||
$this->_categoryFactory = $blogCategoryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AbstractCategory
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
$category = $this->getCategory();
|
||||
$categoryId = (int) $category->getId();
|
||||
// 0 when we create Blog Category, otherwise some value for editing Blog Category
|
||||
|
||||
$this->setChild(
|
||||
'tabs',
|
||||
$this->getLayout()->createBlock(Tabs::class, 'tabs')
|
||||
);
|
||||
|
||||
// Save button
|
||||
$this->addButton('save', [
|
||||
'id' => 'save',
|
||||
'label' => __('Save Category'),
|
||||
'class' => 'save primary save-category',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'Mageplaza_Blog/category/edit' => [
|
||||
'url' => $this->getSaveUrl(),
|
||||
'ajax' => true
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
|
||||
// Delete button
|
||||
if ($categoryId && $categoryId != 1 && !$this->getRequest()->getParam('duplicate')) {
|
||||
$this->addButton('delete', [
|
||||
'id' => 'delete',
|
||||
'label' => __('Delete Category'),
|
||||
'onclick' => "categoryDelete('" . $this->getUrl('mageplaza_blog/*/delete', ['_current' => true]) . "')",
|
||||
'class' => 'delete'
|
||||
]);
|
||||
}
|
||||
|
||||
// Reset button
|
||||
$resetPath = $categoryId ? 'mageplaza_blog/*/edit' : 'mageplaza_blog/*/add';
|
||||
$this->addButton('reset', [
|
||||
'id' => 'reset',
|
||||
'label' => __('Reset'),
|
||||
'onclick' => "categoryReset('" . $this->getUrl($resetPath, ['_current' => true]) . "',false)",
|
||||
'class' => 'reset'
|
||||
]);
|
||||
|
||||
return parent::_prepareLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve additional buttons html
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAdditionalButtonsHtml()
|
||||
{
|
||||
$html = '';
|
||||
foreach ($this->additionalButtons as $childName) {
|
||||
$html .= $this->getChildHtml($childName);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function isAjax()
|
||||
{
|
||||
return $this->getRequest()->isAjax();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSaveUrl(array $args = [])
|
||||
{
|
||||
/** @var BlogCategory $category */
|
||||
$category = $this->_coreRegistry->registry('category');
|
||||
$params = ['_current' => false, '_query' => false];
|
||||
if ($category->getDuplicate()) {
|
||||
$params['duplicate'] = true;
|
||||
}
|
||||
$params = array_merge($params, $args);
|
||||
|
||||
return $this->getUrl('mageplaza_blog/*/save', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEditUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/category/edit', ['_query' => false, 'id' => null, 'parent' => null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $alias
|
||||
* @param array $config
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function addAdditionalButton($alias, $config)
|
||||
{
|
||||
if (isset($config['name'])) {
|
||||
$config['element_name'] = $config['name'];
|
||||
}
|
||||
if ($this->hasToolbarBlock()) {
|
||||
$this->addButton($alias, $config);
|
||||
} else {
|
||||
$this->setChild(
|
||||
$alias . '_button',
|
||||
$this->getLayout()->createBlock(Button::class)->addData($config)
|
||||
);
|
||||
$this->additionalButtons[$alias] = $alias . '_button';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove additional button
|
||||
*
|
||||
* @param string $alias
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function removeAdditionalButton($alias)
|
||||
{
|
||||
if (isset($this->additionalButtons[$alias])) {
|
||||
$this->unsetChild($this->additionalButtons[$alias]);
|
||||
unset($this->additionalButtons[$alias]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabsHtml()
|
||||
{
|
||||
return $this->getChildHtml('tabs');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Phrase|string
|
||||
*/
|
||||
public function getHeader()
|
||||
{
|
||||
if ($this->getCategoryId()) {
|
||||
return $this->getCategoryName();
|
||||
}
|
||||
|
||||
$parentId = (int) $this->getRequest()->getParam('parent');
|
||||
if ($parentId && $parentId !== Category::TREE_ROOT_ID) {
|
||||
return __('New Child 123 Category');
|
||||
} else {
|
||||
return __('New Root 12 Category');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDeleteUrl(array $args = [])
|
||||
{
|
||||
$params = ['_current' => true];
|
||||
$params = array_merge($params, $args);
|
||||
|
||||
return $this->getUrl('mageplaza_blog/*/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return URL for refresh input element 'path' in form
|
||||
*
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRefreshPathUrl(array $args = [])
|
||||
{
|
||||
$params = ['_current' => true];
|
||||
$params = array_merge($params, $args);
|
||||
|
||||
return $this->getUrl('mageplaza_blog/*/refreshPath', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parent Blog Category id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getParentCategoryId()
|
||||
{
|
||||
return (int) $this->templateContext->getRequest()->getParam('parent');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Blog Category id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCategoryId()
|
||||
{
|
||||
return (int) $this->templateContext->getRequest()->getParam('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $buttonId
|
||||
* @param array $data
|
||||
*
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function addButton($buttonId, array $data)
|
||||
{
|
||||
$childBlockId = $buttonId . '_button';
|
||||
$button = $this->getButtonChildBlock($childBlockId);
|
||||
$button->setData($data);
|
||||
$block = $this->getLayout()->getBlock('page.actions.toolbar');
|
||||
if ($block) {
|
||||
$block->setChild($childBlockId, $button);
|
||||
} else {
|
||||
$this->setChild($childBlockId, $button);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function hasToolbarBlock()
|
||||
{
|
||||
return $this->getLayout()->isBlock('page.actions.toolbar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $childId
|
||||
* @param null $blockClassName
|
||||
*
|
||||
* @return BlockInterface
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function getButtonChildBlock($childId, $blockClassName = null)
|
||||
{
|
||||
if ($blockClassName === null) {
|
||||
$blockClassName = Button::class;
|
||||
}
|
||||
|
||||
return $this->getLayout()->createBlock($blockClassName, $this->getNameInLayout() . '-' . $childId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPostsJson()
|
||||
{
|
||||
$posts = $this->getCategory()->getPostsPosition();
|
||||
if (!empty($posts)) {
|
||||
return $this->jsonEncoder->encode($posts);
|
||||
}
|
||||
|
||||
return '{}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
<?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\Adminhtml\Category\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Design\Robots;
|
||||
use Magento\Config\Model\Config\Source\Enabledisable;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Category\Edit\Tab
|
||||
*/
|
||||
class Category extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Wysiwyg config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
protected $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* Country options
|
||||
*
|
||||
* @var Yesno
|
||||
*/
|
||||
protected $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var Enabledisable
|
||||
*/
|
||||
protected $enableDisable;
|
||||
|
||||
/**
|
||||
* @var Robots
|
||||
*/
|
||||
protected $metaRobotsOptions;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $systemStore;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Yesno $booleanOptions
|
||||
* @param Enabledisable $enableDisable
|
||||
* @param Robots $metaRobotsOptions
|
||||
* @param Store $systemStore
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
Config $wysiwygConfig,
|
||||
Yesno $booleanOptions,
|
||||
Enabledisable $enableDisable,
|
||||
Robots $metaRobotsOptions,
|
||||
Store $systemStore,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
$this->enableDisable = $enableDisable;
|
||||
$this->metaRobotsOptions = $metaRobotsOptions;
|
||||
$this->systemStore = $systemStore;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generic
|
||||
* @throws LocalizedException
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Category $category */
|
||||
$category = $this->_coreRegistry->registry('category');
|
||||
|
||||
$form = $this->_formFactory->create();
|
||||
$form->setHtmlIdPrefix('category_');
|
||||
$form->setFieldNameSuffix('category');
|
||||
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Category Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
if ($category->getId()) {
|
||||
$fieldset->addField('category_id', 'hidden', ['name' => 'id', 'value' => $category->getId()]);
|
||||
$fieldset->addField('path', 'hidden', ['name' => 'path', 'value' => $category->getPath()]);
|
||||
} else {
|
||||
$fieldset->addField(
|
||||
'path',
|
||||
'hidden',
|
||||
['name' => 'path', 'value' => $this->getRequest()->getParam('parent') ?: 1]
|
||||
);
|
||||
}
|
||||
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Name'),
|
||||
'title' => __('Name'),
|
||||
'required' => true,
|
||||
]);
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
$fieldset->addField('enabled', 'select', [
|
||||
'name' => 'enabled',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->enableDisable->toOptionArray(),
|
||||
]);
|
||||
|
||||
if ($this->_storeManager->isSingleStoreMode()) {
|
||||
$storeId = $this->_storeManager->getStore()->getId();
|
||||
$fieldset->addField('store_ids', 'hidden', [
|
||||
'name' => 'store_ids',
|
||||
'value' => $storeId
|
||||
]);
|
||||
} else {
|
||||
/** @var RendererInterface $rendererBlock */
|
||||
$rendererBlock = $this->getLayout()->createBlock(Element::class);
|
||||
|
||||
$fieldset->addField('store_ids', 'multiselect', [
|
||||
'name' => 'store_ids',
|
||||
'label' => __('Store Views'),
|
||||
'title' => __('Store Views'),
|
||||
'values' => $this->systemStore->getStoreValuesForForm(false, true)
|
||||
])->setRenderer($rendererBlock);
|
||||
|
||||
if (!$category->hasData('store_ids')) {
|
||||
$category->setStoreIds(0);
|
||||
}
|
||||
}
|
||||
|
||||
$form->addValues($category->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
$this->_eventManager->dispatch('adminhtml_blog_edit_form_prepare_form', ['block' => $this]);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
<?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\Adminhtml\Category\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Category\Edit\Tab
|
||||
*/
|
||||
class Post extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
public $postCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var PostFactory
|
||||
*/
|
||||
public $postFactory;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param PostFactory $postFactory
|
||||
* @param CollectionFactory $postCollectionFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
PostFactory $postFactory,
|
||||
CollectionFactory $postCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->postCollectionFactory = $postCollectionFactory;
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->postFactory = $postFactory;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('post_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setUseAjax(true);
|
||||
|
||||
if ($this->getCategory()->getId()) {
|
||||
$this->setDefaultFilter(['in_posts' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->postCollectionFactory->create();
|
||||
$collection->getSelect()->joinLeft(
|
||||
['related' => $collection->getTable('mageplaza_blog_post_category')],
|
||||
'related.post_id=main_table.post_id AND related.category_id=' . (int) $this->getRequest()->getParam(
|
||||
'id',
|
||||
0
|
||||
),
|
||||
['position']
|
||||
);
|
||||
|
||||
$collection->addFilterToMap('post_id', 'main_table.post_id');
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('in_posts', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'in_post',
|
||||
'values' => $this->_getSelectedPosts(),
|
||||
'align' => 'center',
|
||||
'index' => 'post_id'
|
||||
]);
|
||||
$this->addColumn('post_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'post_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
protected function _getSelectedPosts()
|
||||
{
|
||||
$posts = $this->getRequest()->getPost('category_posts', null);
|
||||
if (!is_array($posts)) {
|
||||
$posts = $this->getCategory()->getPostsPosition();
|
||||
|
||||
return array_keys($posts);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectedPosts()
|
||||
{
|
||||
$selected = $this->getCategory()->getPostsPosition();
|
||||
if (!is_array($selected)) {
|
||||
$selected = [];
|
||||
} else {
|
||||
foreach ($selected as $key => $value) {
|
||||
$selected[$key] = ['position' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Model\Post|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/postsGrid', ['id' => $this->getCategory()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Category
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->coreRegistry->registry('category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _addColumnFilterToCollection($column)
|
||||
{
|
||||
if ($column->getId() === 'in_posts') {
|
||||
$postIds = $this->_getSelectedPosts();
|
||||
if (empty($postIds)) {
|
||||
$postIds = 0;
|
||||
}
|
||||
if ($column->getFilter()->getValue()) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['in' => $postIds]);
|
||||
} elseif ($postIds) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['nin' => $postIds]);
|
||||
}
|
||||
} else {
|
||||
parent::_addColumnFilterToCollection($column);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Posts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/category/posts', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?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\Adminhtml\Category\Edit;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Model\Auth\Session;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Category;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Category\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = 'Magento_Backend::widget/tabshoriz.phtml';
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Tabs constructor.
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param Context $context
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param Session $authSession
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
EncoderInterface $jsonEncoder,
|
||||
Session $authSession,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $jsonEncoder, $authSession, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Tabs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('category_info_tabs');
|
||||
$this->setDestElementId('category_tab_content');
|
||||
$this->setTitle(__('Category Data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Blog Category object
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->coreRegistry->registry('category');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
$this->addTab('category', [
|
||||
'label' => __('Category information'),
|
||||
'content' => $this->getLayout()
|
||||
->createBlock(
|
||||
Tab\Category::class,
|
||||
'mageplaza_blog_category_edit_tab_category'
|
||||
)
|
||||
->toHtml()
|
||||
]);
|
||||
$this->addTab('post', [
|
||||
'label' => __('Posts'),
|
||||
'content' => $this->getLayout()
|
||||
->createBlock(
|
||||
Tab\Post::class,
|
||||
'mageplaza_blog_category_edit_tab_post'
|
||||
)
|
||||
->toHtml()
|
||||
]);
|
||||
|
||||
// dispatch event add custom tabs
|
||||
$this->_eventManager->dispatch('adminhtml_mageplaza_blog_category_tabs', ['tabs' => $this]);
|
||||
|
||||
return parent::_prepareLayout();
|
||||
}
|
||||
}
|
||||
+215
@@ -0,0 +1,215 @@
|
||||
<?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\Adminhtml\Category;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Model\Auth\Session;
|
||||
use Magento\Catalog\Model\Category;
|
||||
use Magento\Catalog\Model\CategoryFactory as CatalogCategoryFactory;
|
||||
use Magento\Catalog\Model\ResourceModel\Category\Tree as TreeResource;
|
||||
use Magento\Framework\Data\Tree\Node;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\DB\Helper;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\CategoryFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Tree as BlogTreeResource;
|
||||
|
||||
/**
|
||||
* @method Tree setUseAjax($useAjax)
|
||||
* @method bool getUseAjax()
|
||||
*/
|
||||
class Tree extends \Magento\Catalog\Block\Adminhtml\Category\Tree
|
||||
{
|
||||
/**
|
||||
* @var int Store filter frontend
|
||||
*/
|
||||
protected $_blogStore;
|
||||
|
||||
/**
|
||||
* Tree constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param TreeResource $categoryTree
|
||||
* @param Registry $registry
|
||||
* @param CatalogCategoryFactory $categoryFactory
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param Helper $resourceHelper
|
||||
* @param Session $backendSession
|
||||
* @param BlogTreeResource $blogCategoryTree
|
||||
* @param CategoryFactory $blogCategoryFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
TreeResource $categoryTree,
|
||||
Registry $registry,
|
||||
CatalogCategoryFactory $categoryFactory,
|
||||
EncoderInterface $jsonEncoder,
|
||||
Helper $resourceHelper,
|
||||
Session $backendSession,
|
||||
BlogTreeResource $blogCategoryTree,
|
||||
CategoryFactory $blogCategoryFactory,
|
||||
array $data = []
|
||||
) {
|
||||
parent::__construct(
|
||||
$context,
|
||||
$categoryTree,
|
||||
$registry,
|
||||
$categoryFactory,
|
||||
$jsonEncoder,
|
||||
$resourceHelper,
|
||||
$backendSession,
|
||||
$data
|
||||
);
|
||||
|
||||
$this->_categoryTree = $blogCategoryTree;
|
||||
$this->_categoryFactory = $blogCategoryFactory;
|
||||
$this->_withProductCount = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNodesUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/category/jsonTree');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMoveUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/category/move');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSaveUrl(array $args = [])
|
||||
{
|
||||
$params = ['_current' => false, '_query' => false];
|
||||
$params = array_merge($params, $args);
|
||||
|
||||
return $this->getUrl('mageplaza_blog/*/save', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEditUrl()
|
||||
{
|
||||
return $this->getUrl(
|
||||
'mageplaza_blog/category/edit',
|
||||
['store' => null, '_query' => false, 'id' => null, 'parent' => null]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $parentNodeCategory
|
||||
* @param null $store
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getTree($parentNodeCategory = null, $store = null)
|
||||
{
|
||||
$this->_blogStore = $store;
|
||||
|
||||
return parent::getTree($parentNodeCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get category name
|
||||
*
|
||||
* @param DataObject $node
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildNodeName($node)
|
||||
{
|
||||
$result = $this->escapeHtml($node->getName());
|
||||
|
||||
if ($this->_withProductCount) {
|
||||
$result .= ' (' . $node->getProductCount() . ')';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get JSON of a tree node or an associative array
|
||||
*
|
||||
* @param Node|array $node
|
||||
* @param int $level
|
||||
*
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
protected function _getNodeJson($node, $level = 0)
|
||||
{
|
||||
// create a node from data array
|
||||
if (is_array($node)) {
|
||||
$node = new Node($node, 'category_id', new \Magento\Framework\Data\Tree());
|
||||
}
|
||||
|
||||
$storeIds = $node->getStoreIds() ? explode(',', $node->getStoreIds() ?? '') : [];
|
||||
if (!($this->_blogStore === null)
|
||||
&& !empty($storeIds)
|
||||
&& !in_array(0, $storeIds, false)
|
||||
&& !in_array($this->_blogStore, $storeIds, false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$node->setIsActive(true);
|
||||
|
||||
if ($item = parent::_getNodeJson($node, $level)) {
|
||||
$item['url'] = $node->getData('url_key');
|
||||
$item['storeIds'] = $node->getData('store_ids');
|
||||
$item['allowDrag'] = $this->_isCategoryMoveable($node) && ($node->getLevel() == 0 ? false : true);
|
||||
$item['enabled'] = $node->getData('enabled');
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ids of root categories as array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getRootIds()
|
||||
{
|
||||
$ids = $this->getData('root_ids');
|
||||
if ($ids === null) {
|
||||
$ids = [Category::TREE_ROOT_ID];
|
||||
$this->setData('root_ids', $ids);
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<?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\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Container;
|
||||
|
||||
/**
|
||||
* Class Comment
|
||||
* @package Mageplaza\Blog\Block\Adminhtml
|
||||
*/
|
||||
class Comment extends Container
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'adminhtml_comment';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_addButtonLabel = __('New Comment');
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
}
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
<?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\Adminhtml\Comment;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Comment;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Comment
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $coreRegistry,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Post edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_comment';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
$this->buttonList->add(
|
||||
'save-and-continue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
-100
|
||||
);
|
||||
$this->buttonList->update('save', 'label', 'Save Comment');
|
||||
$this->buttonList->remove('reset');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Comment $comment */
|
||||
$comment = $this->coreRegistry->registry('mageplaza_blog_comment');
|
||||
if ($comment->getId()) {
|
||||
return __("Edit Comment");
|
||||
}
|
||||
|
||||
return __('New Comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form action URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormActionUrl()
|
||||
{
|
||||
/** @var Post $post */
|
||||
$comment = $this->coreRegistry->registry('mageplaza_blog_comment');
|
||||
if ($id = $comment->getId()) {
|
||||
return $this->getUrl('*/*/save', ['id' => $id]);
|
||||
}
|
||||
|
||||
return parent::getFormActionUrl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Adminhtml\Comment\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Comment\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
<?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\Adminhtml\Comment\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Magento\Store\Model\System\Store;
|
||||
use Mageplaza\Blog\Model\Config\Source\Comments\Status;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
|
||||
/**
|
||||
* Class Comment
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Comment\Edit\Tab
|
||||
*/
|
||||
class Comment extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var CustomerRepositoryInterface
|
||||
*/
|
||||
protected $_customerRepository;
|
||||
|
||||
/**
|
||||
* @var PostFactory
|
||||
*/
|
||||
protected $_postFactory;
|
||||
|
||||
/**
|
||||
* @var Status
|
||||
*/
|
||||
protected $_commentStatus;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $systemStore;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $storeManager;
|
||||
|
||||
/**
|
||||
* Comment constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param CustomerRepositoryInterface $customerRepository
|
||||
* @param PostFactory $postFactory
|
||||
* @param Status $commentStatus
|
||||
* @param Store $systemStore
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
CustomerRepositoryInterface $customerRepository,
|
||||
PostFactory $postFactory,
|
||||
Status $commentStatus,
|
||||
Store $systemStore,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_commentStatus = $commentStatus;
|
||||
$this->_customerRepository = $customerRepository;
|
||||
$this->_postFactory = $postFactory;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->storeManager = $context->getStoreManager();
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Generic
|
||||
* @throws LocalizedException
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
$comment = $this->_coreRegistry->registry('mageplaza_blog_comment');
|
||||
|
||||
$form = $this->_formFactory->create();
|
||||
$form->setHtmlIdPrefix('comment_');
|
||||
$form->setFieldNameSuffix('comment');
|
||||
|
||||
$fieldset = $form->addFieldset(
|
||||
'base_fieldset',
|
||||
['legend' => __('Comment Details'), 'class' => 'fieldset-wide']
|
||||
);
|
||||
|
||||
if ($comment->getId()) {
|
||||
$fieldset->addField('comment_id', 'hidden', ['name' => 'comment_id']);
|
||||
}
|
||||
|
||||
$post = $this->_postFactory->create()->load($comment->getPostId());
|
||||
$postText = '<a href="' . $this->getUrl('mageplaza_blog/post/edit', ['id' => $comment->getPostId()])
|
||||
. '" onclick="this.target=\'blank\'">' . $this->escapeHtml($post->getName()) . '</a>';
|
||||
$fieldset->addField('post_name', 'note', ['text' => $postText, 'label' => __('Post'), 'name' => 'post_name']);
|
||||
|
||||
if ($comment->getEntityId() > 0) {
|
||||
$customer = $this->_customerRepository->getById($comment->getEntityId());
|
||||
$customerText = '<a href="'
|
||||
. $this->getUrl(
|
||||
'customer/index/edit',
|
||||
['id' => $customer->getId(), 'active_tab' => 'review']
|
||||
)
|
||||
. '" onclick="this.target=\'blank\'">'
|
||||
. $this->escapeHtml($customer->getFirstname() . ' ' . $customer->getLastname())
|
||||
. '</a> <a href="mailto:%4">(' . $customer->getEmail() . ')</a>';
|
||||
} else {
|
||||
$customerText = 'Guest';
|
||||
}
|
||||
|
||||
$fieldset->addField(
|
||||
'customer_name',
|
||||
'note',
|
||||
['text' => $customerText, 'label' => __('Customer'), 'name' => 'customer_name']
|
||||
);
|
||||
|
||||
$fieldset->addField('status', 'select', [
|
||||
'label' => __('Status'),
|
||||
'required' => true,
|
||||
'name' => 'status',
|
||||
'values' => $this->_commentStatus->toArray()
|
||||
]);
|
||||
$fieldset->addField('content', 'textarea', [
|
||||
'label' => __('Content'),
|
||||
'required' => true,
|
||||
'name' => 'content',
|
||||
'style' => 'height:24em;'
|
||||
]);
|
||||
$viewText = '';
|
||||
foreach ($this->storeManager->getStores() as $store) {
|
||||
if ($store->getId() === $comment->getStoreIds()) {
|
||||
$viewText .= '<a href="' . $post->getUrl($store->getId()) . '#cmt-id-' . $comment->getId()
|
||||
. '" onclick="this.target=\'blank\'">View in store ' . $store->getName() . '</a><br>';
|
||||
}
|
||||
}
|
||||
|
||||
$fieldset->addField(
|
||||
'view_front',
|
||||
'note',
|
||||
['text' => $viewText, 'label' => __('View On Front End'), 'name' => 'view_front']
|
||||
);
|
||||
|
||||
$form->addValues($comment->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Comment');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Adminhtml\Comment\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Comment\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('comment_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Comment Information'));
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?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\Adminhtml\Import;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Phrase;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Import
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Internal constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->buttonList->remove('back');
|
||||
$this->buttonList->remove('reset');
|
||||
$this->buttonList->remove('save');
|
||||
|
||||
$this->buttonList->add(
|
||||
'check-connection',
|
||||
[
|
||||
'label' => __('Check Connection'),
|
||||
'class' => 'primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'target' => '#edit_form',
|
||||
|
||||
]
|
||||
]
|
||||
],
|
||||
'onclick' => 'mpBlogImport.initImportCheckConnection();'
|
||||
],
|
||||
-100
|
||||
);
|
||||
$this->_objectId = 'import_id';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_import';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header text
|
||||
*
|
||||
* @return Phrase
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
return __('Import Setting');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
<?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\Adminhtml\Import\Edit;
|
||||
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
use Mageplaza\Blog\Helper\Image as ImageHelper;
|
||||
use Mageplaza\Blog\Model\Config\Source\Import\Behaviour;
|
||||
use Mageplaza\Blog\Model\Config\Source\Import\Type;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Import\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
public $systemStore;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
public $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* @var Yesno
|
||||
*/
|
||||
public $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var ImageHelper
|
||||
*/
|
||||
protected $_imageHelper;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
*/
|
||||
protected $_importType;
|
||||
|
||||
/**
|
||||
* @var Behaviour
|
||||
*/
|
||||
protected $_importBehaviour;
|
||||
|
||||
/**
|
||||
* Form constructor.
|
||||
*
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Store $systemStore
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param ImageHelper $imageHelper
|
||||
* @param Type $importType
|
||||
* @param Behaviour $importBehaviour
|
||||
* @param Yesno $booleanOptions
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Config $wysiwygConfig,
|
||||
Store $systemStore,
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
ImageHelper $imageHelper,
|
||||
Type $importType,
|
||||
Behaviour $importBehaviour,
|
||||
Yesno $booleanOptions,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->_imageHelper = $imageHelper;
|
||||
$this->_importType = $importType;
|
||||
$this->_importBehaviour = $importBehaviour;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => '',
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data',
|
||||
],
|
||||
]);
|
||||
$form->setFieldNameSuffix('import');
|
||||
|
||||
$fieldsets['base'] = $form->addFieldset('base_fieldset', ['legend' => __('Import Settings')]);
|
||||
|
||||
$fieldsets['base']->addField('import_type', 'select', [
|
||||
'name' => 'import_type',
|
||||
'label' => __('Import Type'),
|
||||
'title' => __('Import Type'),
|
||||
'values' => $this->_importType->toOptionArray(),
|
||||
'required' => true,
|
||||
'onchange' => 'mpBlogImport.initImportFieldsSet()'
|
||||
]);
|
||||
|
||||
$fieldsetList = $this->_importType->toOptionArray();
|
||||
array_shift($fieldsetList);
|
||||
|
||||
foreach ($fieldsetList as $item) {
|
||||
$fieldsets[$item["value"]] = $form->addFieldset($item["value"] . '_fieldset', [
|
||||
'legend' => $item["label"]->getText() . __(' Import'),
|
||||
'class' => 'no-display'
|
||||
]);
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_import_name', 'hidden', [
|
||||
'name' => 'import_name',
|
||||
'value' => $item["label"]->getText()
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_db_name', 'text', [
|
||||
'name' => 'db_name',
|
||||
'title' => __('Database Name'),
|
||||
'label' => __('Database Name'),
|
||||
'required' => true,
|
||||
'class' => $item["value"],
|
||||
'note' => __('Your SQL database name')
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_user_name', 'text', [
|
||||
'name' => 'user_name',
|
||||
'title' => __('Database User Name'),
|
||||
'label' => __('Database User Name'),
|
||||
'required' => true,
|
||||
'class' => $item["value"],
|
||||
'note' => __('Your SQL database User name')
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_db_password', 'text', [
|
||||
'name' => 'db_password',
|
||||
'title' => __('Database Password'),
|
||||
'label' => __('Database Password'),
|
||||
'class' => $item["value"],
|
||||
'note' => __('Your SQL database Password')
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_db_host', 'text', [
|
||||
'name' => 'db_host',
|
||||
'title' => __('Database Host'),
|
||||
'label' => __('Database Host'),
|
||||
'required' => true,
|
||||
'class' => $item["value"],
|
||||
'value' => 'localhost',
|
||||
'note' => __('Your SQL database Hostname')
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_table_prefix', 'text', [
|
||||
'name' => 'table_prefix',
|
||||
'title' => __('Table Prefix'),
|
||||
'label' => __('Table Prefix'),
|
||||
'class' => $item["value"],
|
||||
'note' => __('Your table prefix name')
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_import_behaviour', 'select', [
|
||||
'name' => 'import_behaviour',
|
||||
'label' => __('Import Behaviour'),
|
||||
'title' => __('Import Behaviour'),
|
||||
'values' => $this->_importBehaviour->toOptionArray(),
|
||||
'note' => __('This action is applied to all data'),
|
||||
'onchange' => 'mpBlogImport.initExpandBehaviour();'
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_import_behaviour_expand', 'select', [
|
||||
'name' => 'import_behaviour_expand',
|
||||
'label' => __('Allow update content on existing URL-key'),
|
||||
'title' => __('Allow update content on existing URL-key'),
|
||||
'values' => $this->booleanOptions->toOptionArray(),
|
||||
'note' => __('If <b>Yes</b>, content will be updated on posts with existing url-key. Select <b>No</b> to add a new post'),
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
$fieldsets[$item["value"]]->addField($item["value"] . '_import_image_path', 'note', [
|
||||
'name' => 'import_image_path',
|
||||
'label' => __('Image Path Hint'),
|
||||
'title' => __('Image Path Hint'),
|
||||
'text' => '<div class="image-path"></div>',
|
||||
]);
|
||||
}
|
||||
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?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\Adminhtml\Import\Edit;
|
||||
|
||||
use Magento\Backend\Block\Template;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Framework\View\Element\Messages;
|
||||
use Mageplaza\Blog\Helper\Data as BlogHelper;
|
||||
use Mageplaza\Blog\Model\Config\Source\Import\Type;
|
||||
|
||||
/**
|
||||
* Class Import
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Import\Edit
|
||||
*/
|
||||
class Import extends Template
|
||||
{
|
||||
/**
|
||||
* @var BlogHelper
|
||||
*/
|
||||
public $blogHelper;
|
||||
|
||||
/**
|
||||
* @var Type
|
||||
*/
|
||||
public $importType;
|
||||
|
||||
/**
|
||||
* Before constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param BlogHelper $blogHelper
|
||||
* @param Type $importType
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
BlogHelper $blogHelper,
|
||||
Type $importType,
|
||||
array $data = []
|
||||
) {
|
||||
$this->blogHelper = $blogHelper;
|
||||
$this->importType = $importType;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTypeSelector()
|
||||
{
|
||||
$types = [];
|
||||
foreach ($this->importType->toOptionArray() as $item) {
|
||||
$types[] = $item['value'];
|
||||
}
|
||||
array_shift($types);
|
||||
|
||||
return BlogHelper::jsonEncode($types);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $priority
|
||||
* @param $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessagesHtml($priority, $message)
|
||||
{
|
||||
/** @var $messagesBlock Messages */
|
||||
$messagesBlock = $this->_layout->createBlock(Messages::class);
|
||||
$messagesBlock->{$priority}(__($message));
|
||||
|
||||
return $messagesBlock->toHtml();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImportButtonHtml()
|
||||
{
|
||||
$importUrl = $this->getUrl('mageplaza_blog/import/import');
|
||||
$html = ' <button id="word-press-import" href="' . $importUrl .
|
||||
'" class="" type="button" onclick="mpBlogImport.importAction();">' .
|
||||
'<span><span><span>Import</span></span></span></button>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?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\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Container;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml
|
||||
*/
|
||||
class Post extends Container
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'adminhtml_post';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_headerText = __('Posts');
|
||||
$this->_headerText = __('Posts');
|
||||
$this->_addButtonLabel = __('Create New Post');
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
}
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
<?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\Adminhtml\Post;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param Context $context
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $coreRegistry,
|
||||
Context $context,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Post edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_post';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
if (!$this->getRequest()->getParam('history')) {
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
$this->buttonList->remove('save');
|
||||
$this->buttonList->add(
|
||||
'save',
|
||||
[
|
||||
'label' => __('Save'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
],
|
||||
'class_name' => \Magento\Ui\Component\Control\Container::SPLIT_BUTTON,
|
||||
'options' => $this->getOptions($post),
|
||||
],
|
||||
-100
|
||||
);
|
||||
|
||||
$this->buttonList->add(
|
||||
'save-and-continue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
-100
|
||||
);
|
||||
if ($post->getId() && !$this->_request->getParam('duplicate')) {
|
||||
$this->buttonList->add(
|
||||
'duplicate',
|
||||
[
|
||||
'label' => __('Duplicate'),
|
||||
'class' => 'duplicate',
|
||||
'onclick' => sprintf("location.href = '%s';", $this->getDuplicateUrl()),
|
||||
],
|
||||
-101
|
||||
);
|
||||
} else {
|
||||
$this->buttonList->remove('delete');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve options
|
||||
*
|
||||
* @param Post $post
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getOptions($post)
|
||||
{
|
||||
if ($post->getId() && !$this->_request->getParam('duplicate')) {
|
||||
$options[] = [
|
||||
'id_hard' => 'save_and_draft',
|
||||
'label' => __('Save as Draft'),
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form',
|
||||
'eventData' => [
|
||||
'action' => ['args' => ['action' => 'draft']]
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
$options[] = [
|
||||
'id_hard' => 'save_and_history',
|
||||
'label' => __(' Save & add History'),
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'save',
|
||||
'target' => '#edit_form',
|
||||
'eventData' => [
|
||||
'action' => ['args' => ['action' => 'add']]
|
||||
],
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Post $post */
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
if ($this->getRequest()->getParam('history')) {
|
||||
return __("Edit History Post '%1'", $this->escapeHtml($post->getName()));
|
||||
}
|
||||
|
||||
if ($post->getId() && $post->getDuplicate()) {
|
||||
return __("Edit Post '%1'", $this->escapeHtml($post->getName()));
|
||||
}
|
||||
|
||||
return __('New Post');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form action URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormActionUrl()
|
||||
{
|
||||
/** @var Post $post */
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
if ($post->getId()) {
|
||||
if ($post->getDuplicate()) {
|
||||
$ar = [];
|
||||
} else {
|
||||
$ar = ['id' => $post->getId()];
|
||||
}
|
||||
if ($this->getRequest()->getParam('history')) {
|
||||
$ar['post_id'] = $this->getRequest()->getParam('post_id');
|
||||
}
|
||||
|
||||
return $this->getUrl('*/*/save', $ar);
|
||||
}
|
||||
|
||||
return parent::getFormActionUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getDuplicateUrl()
|
||||
{
|
||||
$post = $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
return $this->getUrl('*/*/duplicate', ['id' => $post->getId(), 'duplicate' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSaveDraftUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/save', ['action' => 'draft']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getSaveAddHistoryUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/save', ['action' => 'add']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Adminhtml\Post\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Exception\FileSystemException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Action;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Author;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Categories;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Store;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Tags;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History\Topics;
|
||||
use Mageplaza\Blog\Model\AuthorFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\PostHistory\Collection;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Product
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class History extends Extended implements TabInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $historyCollection;
|
||||
|
||||
/**
|
||||
* @var \Mageplaza\Blog\Helper\Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param Collection $historyCollection
|
||||
* @param \Mageplaza\Blog\Helper\Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
Collection $historyCollection,
|
||||
\Mageplaza\Blog\Helper\Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->historyCollection = $historyCollection;
|
||||
$this->_helperData = $_helperData;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
* @throws FileSystemException
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('history_id');
|
||||
$this->setDefaultSort('history_id');
|
||||
$this->setDefaultDir('DESC');
|
||||
$this->setSaveParametersInSession(false);
|
||||
$this->setUseAjax(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->historyCollection;
|
||||
$id = $this->getRequest()->getParam('id', 0);
|
||||
$collection->addFieldToFilter('post_id', $id);
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('history_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'history_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('name', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('short_description', [
|
||||
'header' => __('Short Description'),
|
||||
'index' => 'short_description',
|
||||
'header_css_class' => 'col-short-description',
|
||||
'column_css_class' => 'col-short-description'
|
||||
]);
|
||||
$this->addColumn('store_ids', [
|
||||
'header' => __('Store View'),
|
||||
'index' => 'store_ids',
|
||||
'renderer' => Store::class,
|
||||
'filter' => false,
|
||||
'header_css_class' => 'col-store-ids',
|
||||
'column_css_class' => 'col-store-ids'
|
||||
]);
|
||||
$this->addColumn('category_ids', [
|
||||
'header' => __('Categories'),
|
||||
'index' => 'category_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Categories::class,
|
||||
'header_css_class' => 'col-category-ids',
|
||||
'column_css_class' => 'col-category-ids'
|
||||
]);
|
||||
$this->addColumn('topic_ids', [
|
||||
'header' => __('Topics'),
|
||||
'index' => 'topic_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Topics::class,
|
||||
'header_css_class' => 'col-topic-ids',
|
||||
'column_css_class' => 'col-topic-ids'
|
||||
]);
|
||||
$this->addColumn('tag_ids', [
|
||||
'header' => __('Tags'),
|
||||
'index' => 'tag_ids',
|
||||
'filter' => false,
|
||||
'renderer' => Tags::class,
|
||||
'header_css_class' => 'col-tag-ids',
|
||||
'column_css_class' => 'col-tag-ids'
|
||||
]);
|
||||
$this->addColumn('modifier_id', [
|
||||
'header' => __('Modified by'),
|
||||
'index' => 'modifier_id',
|
||||
'type' => 'options',
|
||||
'options' => $this->_getModifierOptions(),
|
||||
'renderer' => Author::class,
|
||||
'filter_condition_callback' => [$this, '_filterByModifierId'],
|
||||
'header_css_class' => 'col-modifier-id',
|
||||
'column_css_class' => 'col-modifier-id'
|
||||
]);
|
||||
$this->addColumn('updated_at', [
|
||||
'header' => __('Modified At'),
|
||||
'index' => 'updated_at',
|
||||
'header_css_class' => 'col-updated-at',
|
||||
'column_css_class' => 'col-updated-at',
|
||||
'type' => 'datetime',
|
||||
'filter_condition_callback' => [$this, '_filterByUpdatedAt'],
|
||||
]);
|
||||
$this->addColumn(
|
||||
'action',
|
||||
[
|
||||
'header' => __('Action'),
|
||||
'index' => 'template_id',
|
||||
'sortable' => false,
|
||||
'filter' => false,
|
||||
'no_link' => true,
|
||||
'renderer' => Action::class,
|
||||
'header_css_class' => 'col-actions',
|
||||
'column_css_class' => 'col-actions'
|
||||
]
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/historyGrid', ['id' => $this->getPost()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Post
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Edit History');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/post/history', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Modifiers as Author of Post
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function _getModifierOptions()
|
||||
{
|
||||
/** @var AuthorFactory $authors */
|
||||
$authors = $this->_helperData->getFactoryByType('author');
|
||||
|
||||
$authors = $authors->create()->getCollection()->addFieldToSelect(['user_id', 'name'])->getItems();
|
||||
$options = [];
|
||||
foreach ($authors as $author) {
|
||||
$options[$author->getUserId()] = $author->getName();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function _filterByModifierId(
|
||||
Collection $collection,
|
||||
\Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
) {
|
||||
if (!$value = $column->getFilter()->getValue()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$collection->addFieldToFilter('modifier_id', $value);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param \Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function _filterByUpdatedAt(
|
||||
Collection $collection,
|
||||
\Magento\Backend\Block\Widget\Grid\Column\Extended $column
|
||||
) {
|
||||
if (!$value = $column->getFilter()->getValue()) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$formValue = $value['from'] ?? '';
|
||||
$toValue = $value['to'] ?? '';
|
||||
|
||||
if ($formValue && $toValue) {
|
||||
$updateFilter = ['from' => $formValue, 'to' => $toValue];
|
||||
} elseif ($formValue) {
|
||||
$updateFilter = ['from' => $formValue];
|
||||
} else {
|
||||
$updateFilter = ['to' => $toValue];
|
||||
}
|
||||
|
||||
$collection->addFieldToFilter('updated_at', $updateFilter);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,403 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use DateTimeZone;
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Model\Auth\Session;
|
||||
use Magento\Cms\Model\Page\Source\PageLayout as BasePageLayout;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Design\Robots;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\Form;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
use Magento\Store\Model\System\Store;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Category;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Tag;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Topic;
|
||||
use Mageplaza\Blog\Helper\Image;
|
||||
use Mageplaza\Blog\Model\Config\Source\Author;
|
||||
use Mageplaza\Blog\Model\Config\Source\AuthorStatus;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class Post extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Wysiwyg config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
public $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* Country options
|
||||
*
|
||||
* @var Yesno
|
||||
*/
|
||||
public $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var Robots
|
||||
*/
|
||||
public $metaRobotsOptions;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
public $systemStore;
|
||||
|
||||
/**
|
||||
* @var Session
|
||||
*/
|
||||
protected $authSession;
|
||||
|
||||
/**
|
||||
* @var Image
|
||||
*/
|
||||
protected $imageHelper;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
protected $_date;
|
||||
|
||||
/**
|
||||
* @var BasePageLayout
|
||||
*/
|
||||
protected $_layoutOptions;
|
||||
|
||||
/**
|
||||
* @var Author
|
||||
*/
|
||||
protected $_author;
|
||||
|
||||
/**
|
||||
* @var AuthorStatus
|
||||
*/
|
||||
protected $_status;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param Session $authSession
|
||||
* @param DateTime $dateTime
|
||||
* @param BasePageLayout $layoutOption
|
||||
* @param FormFactory $formFactory
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Yesno $booleanOptions
|
||||
* @param Robots $metaRobotsOptions
|
||||
* @param Store $systemStore
|
||||
* @param Image $imageHelper
|
||||
* @param Author $author
|
||||
* @param AuthorStatus $status
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
Session $authSession,
|
||||
DateTime $dateTime,
|
||||
BasePageLayout $layoutOption,
|
||||
FormFactory $formFactory,
|
||||
Config $wysiwygConfig,
|
||||
Yesno $booleanOptions,
|
||||
Robots $metaRobotsOptions,
|
||||
Store $systemStore,
|
||||
Image $imageHelper,
|
||||
Author $author,
|
||||
AuthorStatus $status,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
$this->metaRobotsOptions = $metaRobotsOptions;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->authSession = $authSession;
|
||||
$this->_date = $dateTime;
|
||||
$this->_layoutOptions = $layoutOption;
|
||||
$this->imageHelper = $imageHelper;
|
||||
$this->_author = $author;
|
||||
$this->_status = $status;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Post $post */
|
||||
$post = $this->_coreRegistry->registry('mageplaza_blog_post');
|
||||
|
||||
/** @var Form $form */
|
||||
$form = $this->_formFactory->create();
|
||||
|
||||
$form->setHtmlIdPrefix('post_');
|
||||
$form->setFieldNameSuffix('post');
|
||||
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Post Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
if ($this->_request->getParam('duplicate')) {
|
||||
$fieldset->addField('duplicate', 'hidden', [
|
||||
'name' => 'duplicate',
|
||||
'value' => 1
|
||||
]);
|
||||
}
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Name'),
|
||||
'title' => __('Name'),
|
||||
'required' => true
|
||||
]);
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
$fieldset->addField('author_id', 'select', [
|
||||
'name' => 'author_id',
|
||||
'label' => __('Author'),
|
||||
'title' => __('Author'),
|
||||
'required' => true,
|
||||
'values' => $this->_author->toOptionArray()
|
||||
]);
|
||||
$fieldset->addField('enabled', 'select', [
|
||||
'name' => 'enabled',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->_status->toOptionArray()
|
||||
]);
|
||||
if (!$post->hasData('enabled')) {
|
||||
$post->setEnabled(1);
|
||||
}
|
||||
|
||||
$fieldset->addField('short_description', 'textarea', [
|
||||
'name' => 'short_description',
|
||||
'label' => __('Short Description'),
|
||||
'title' => __('Short Description')
|
||||
]);
|
||||
$fieldset->addField('post_content', 'editor', [
|
||||
'name' => 'post_content',
|
||||
'label' => __('Content'),
|
||||
'title' => __('Content'),
|
||||
'config' => $this->wysiwygConfig->getConfig([
|
||||
'add_variables' => false,
|
||||
'add_widgets' => true,
|
||||
'add_directives' => true
|
||||
])
|
||||
]);
|
||||
|
||||
if ($this->_storeManager->isSingleStoreMode()) {
|
||||
$fieldset->addField('store_ids', 'hidden', [
|
||||
'name' => 'store_ids',
|
||||
'value' => $this->_storeManager->getStore()->getId()
|
||||
]);
|
||||
} else {
|
||||
/** @var RendererInterface $rendererBlock */
|
||||
$rendererBlock = $this->getLayout()->createBlock(Element::class);
|
||||
$fieldset->addField('store_ids', 'multiselect', [
|
||||
'name' => 'store_ids',
|
||||
'label' => __('Store Views'),
|
||||
'title' => __('Store Views'),
|
||||
'values' => $this->systemStore->getStoreValuesForForm(false, true)
|
||||
])->setRenderer($rendererBlock);
|
||||
|
||||
if (!$post->hasData('store_ids')) {
|
||||
$post->setStoreIds(0);
|
||||
}
|
||||
}
|
||||
|
||||
$fieldset->addField('image', \Mageplaza\Blog\Block\Adminhtml\Renderer\Image::class, [
|
||||
'name' => 'image',
|
||||
'label' => __('Image'),
|
||||
'title' => __('Image'),
|
||||
'path' => $this->imageHelper->getBaseMediaPath(Image::TEMPLATE_MEDIA_TYPE_POST),
|
||||
'note' => __('The appropriate size is 265px * 250px.')
|
||||
]);
|
||||
$fieldset->addField('categories_ids', Category::class, [
|
||||
'name' => 'categories_ids',
|
||||
'label' => __('Categories'),
|
||||
'title' => __('Categories'),
|
||||
]);
|
||||
if (!$post->getCategoriesIds()) {
|
||||
$post->setCategoriesIds($post->getCategoryIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('topics_ids', Topic::class, [
|
||||
'name' => 'topics_ids',
|
||||
'label' => __('Topics'),
|
||||
'title' => __('Topics'),
|
||||
]);
|
||||
if (!$post->getTopicsIds()) {
|
||||
$post->setTopicsIds($post->getTopicIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('tags_ids', Tag::class, [
|
||||
'name' => 'tags_ids',
|
||||
'label' => __('Tags'),
|
||||
'title' => __('Tags'),
|
||||
]);
|
||||
if (!$post->getTagsIds()) {
|
||||
$post->setTagsIds($post->getTagIds());
|
||||
}
|
||||
|
||||
$fieldset->addField('in_rss', 'select', [
|
||||
'name' => 'in_rss',
|
||||
'label' => __('In RSS'),
|
||||
'title' => __('In RSS'),
|
||||
'values' => $this->booleanOptions->toOptionArray(),
|
||||
]);
|
||||
$fieldset->addField('allow_comment', 'select', [
|
||||
'name' => 'allow_comment',
|
||||
'label' => __('Allow Comment'),
|
||||
'title' => __('Allow Comment'),
|
||||
'values' => $this->booleanOptions->toOptionArray(),
|
||||
]);
|
||||
$fieldset->addField(
|
||||
'publish_date',
|
||||
'date',
|
||||
[
|
||||
'name' => 'publish_date',
|
||||
'label' => __('Publish Date'),
|
||||
'title' => __('Publish Date'),
|
||||
'date_format' => 'yyyy-MM-dd',
|
||||
'timezone' => false,
|
||||
'time_format' => 'hh:mm:ss'
|
||||
]
|
||||
);
|
||||
$this->_eventManager->dispatch('after_adminhtml_blog_post_info_tab', ['fieldset' => $fieldset]);
|
||||
|
||||
$seoFieldset = $form->addFieldset('seo_fieldset', [
|
||||
'legend' => __('Search Engine Optimization'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
$seoFieldset->addField('meta_title', 'text', [
|
||||
'name' => 'meta_title',
|
||||
'label' => __('Meta Title'),
|
||||
'title' => __('Meta Title'),
|
||||
'note' => __('If empty, the post name will be used.')
|
||||
]);
|
||||
$seoFieldset->addField('meta_keywords', 'textarea', [
|
||||
'name' => 'meta_keywords',
|
||||
'label' => __('Meta Keywords'),
|
||||
'title' => __('Meta Keywords'),
|
||||
'note' => __('Enter comma-separated keywords.')
|
||||
]);
|
||||
$seoFieldset->addField('meta_description', 'textarea', [
|
||||
'name' => 'meta_description',
|
||||
'label' => __('Meta Description'),
|
||||
'title' => __('Meta Description'),
|
||||
'note' => __('If empty, the global blog meta description will be used.')
|
||||
]);
|
||||
|
||||
$designFieldset = $form->addFieldset('design_fieldset', [
|
||||
'legend' => __('Design'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
|
||||
$designFieldset->addField('layout', 'select', [
|
||||
'name' => 'layout',
|
||||
'label' => __('Layout'),
|
||||
'title' => __('Layout'),
|
||||
'values' => $this->_layoutOptions->toOptionArray()
|
||||
]);
|
||||
|
||||
if (!$post->getId()) {
|
||||
$post->addData([
|
||||
'allow_comment' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
/** Get the public_date from database */
|
||||
if ($post->getData('publish_date')) {
|
||||
$publicDateTime = new \DateTime($post->getData('publish_date'), new DateTimeZone('UTC'));
|
||||
$publicDateTime->setTimezone(new DateTimeZone($this->_localeDate->getConfigTimezone()));
|
||||
$publicDateTime = $publicDateTime->format('m/d/Y H:i:s');
|
||||
$post->setData('publish_date', $publicDateTime);
|
||||
}
|
||||
|
||||
$form->addValues($post->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
$this->_eventManager->dispatch('adminhtml_blog_edit_form_prepare_form', ['block' => $this]);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Post');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,316 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\Collection;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
|
||||
use Magento\Framework\App\RequestInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Product
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab
|
||||
*/
|
||||
class Product extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
public $productCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Product constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param RequestInterface $request
|
||||
* @param CollectionFactory $productCollectionFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
RequestInterface $request,
|
||||
CollectionFactory $productCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->productCollectionFactory = $productCollectionFactory;
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->request = $request;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('product_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setSaveParametersInSession(false);
|
||||
$this->setUseAjax(true);
|
||||
|
||||
if ($this->getPost()->getId()) {
|
||||
$this->setDefaultFilter(['in_products' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->productCollectionFactory->create();
|
||||
$collection->clear();
|
||||
|
||||
$collection->getSelect()->joinLeft(
|
||||
['mp_p' => $collection->getTable('mageplaza_blog_post_product')],
|
||||
'e.entity_id = mp_p.entity_id',
|
||||
['position']
|
||||
)->group('e.entity_id');
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('in_products', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'in_product',
|
||||
'values' => $this->_getSelectedProducts(),
|
||||
'align' => 'center',
|
||||
'index' => 'entity_id'
|
||||
]);
|
||||
$this->addColumn('entity_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'entity_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Sku'),
|
||||
'index' => 'sku',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
|
||||
if ($this->request->getParam('post_id') || $this->getPost()->getId()) {
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
'edit_only' => true,
|
||||
]);
|
||||
} else {
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
'filter' => false,
|
||||
'edit_only' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Tags
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _getSelectedProducts()
|
||||
{
|
||||
$products = $this->getRequest()->getPost('post_products', null);
|
||||
if (!is_array($products)) {
|
||||
$products = $this->getPost()->getProductsPosition();
|
||||
|
||||
return array_keys($products);
|
||||
}
|
||||
|
||||
return $products;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Tags
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectedProducts()
|
||||
{
|
||||
$selected = $this->getPost()->getProductsPosition();
|
||||
if (!is_array($selected)) {
|
||||
$selected = [];
|
||||
} else {
|
||||
foreach ($selected as $key => $value) {
|
||||
$selected[$key] = ['position' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/productsGrid', ['post_id' => $this->getPost()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Post
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_post');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _addColumnFilterToCollection($column)
|
||||
{
|
||||
if ($column->getId() === 'in_products') {
|
||||
$productIds = $this->_getSelectedProducts();
|
||||
if (empty($productIds)) {
|
||||
$productIds = 0;
|
||||
}
|
||||
if ($column->getFilter()->getValue()) {
|
||||
$this->getCollection()->addFieldToFilter('entity_id', ['in' => $productIds]);
|
||||
} else {
|
||||
if ($productIds) {
|
||||
$this->getCollection()->addFieldToFilter('entity_id', ['nin' => $productIds]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
parent::_addColumnFilterToCollection($column);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Products');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/post/products', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Catalog\Model\Category as CategoryModel;
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\CollectionFactory as BlogCategoryCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Category
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Category extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogCategoryCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Category constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogCategoryCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogCategoryCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-category-select" class="admin__field"
|
||||
data-bind="scope:\'blogCategory\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[categories_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"
|
||||
data-bind="scope:\'create_category_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_category_modal\' -->
|
||||
<!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::category');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCategoriesTree()
|
||||
{
|
||||
/* @var $collection \Magento\Catalog\Model\ResourceModel\Category\Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
|
||||
$categoryById = [
|
||||
CategoryModel::TREE_ROOT_ID => [
|
||||
'value' => CategoryModel::TREE_ROOT_ID,
|
||||
'optgroup' => null,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($collection as $category) {
|
||||
foreach ([$category->getId(), $category->getParentId()] as $categoryId) {
|
||||
if (!isset($categoryById[$categoryId])) {
|
||||
$categoryById[$categoryId] = ['value' => $categoryId];
|
||||
}
|
||||
}
|
||||
|
||||
$categoryById[$category->getId()]['is_active'] = 1;
|
||||
$categoryById[$category->getId()]['label'] = $category->getName();
|
||||
$categoryById[$category->getParentId()]['optgroup'][] = &$categoryById[$category->getId()];
|
||||
}
|
||||
|
||||
return $categoryById[CategoryModel::TREE_ROOT_ID]['optgroup'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $category) {
|
||||
$options[] = $category->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Category suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogCategory": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_category": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getCategoriesTree()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_category:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_category",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_category_button": {
|
||||
"title": "' . __('New Category') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_category_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_category_modal.create_category",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_category_modal.create_category",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_category_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Category') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_category:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_category": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
['handle' => 'mageplaza_blog_category_create', 'buttons' => 1]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_category_form",
|
||||
"externalProvider": "blog_new_category_form.new_category_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Json\EncoderInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Action extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Action
|
||||
{
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
protected $_storeManager;
|
||||
|
||||
/**
|
||||
* Action constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param EncoderInterface $jsonEncoder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
StoreManagerInterface $storeManager,
|
||||
EncoderInterface $jsonEncoder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_storeManager = $storeManager;
|
||||
parent::__construct($context, $jsonEncoder, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/edit', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId(),
|
||||
'history' => true
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Edit'),
|
||||
];
|
||||
try {
|
||||
$actions[] = [
|
||||
'url' => $this->_storeManager->getStore()->getBaseUrl()
|
||||
. 'mpblog/post/preview?id=' . $row->getPostId() . '&historyId=' . $row->getId(),
|
||||
'popup' => true,
|
||||
'caption' => __('Preview'),
|
||||
];
|
||||
} catch (Exception $exception) {
|
||||
$actions[] = [];
|
||||
}
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/restore', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId()
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Restore'),
|
||||
'confirm' => 'Are you sure you want to do this?'
|
||||
];
|
||||
|
||||
$actions[] = [
|
||||
'url' =>
|
||||
$this->getUrl('*/history/delete', [
|
||||
'id' => $row->getId(),
|
||||
'post_id' => $row->getPostId()
|
||||
]),
|
||||
'popup' => false,
|
||||
'caption' => __('Delete'),
|
||||
'confirm' => 'Are you sure you want to do this?'
|
||||
];
|
||||
|
||||
$this->getColumn()->setActions($actions);
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Author extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$userId = $row->getData($this->getColumn()->getIndex());
|
||||
$author = $this->_helperData->getFactoryByType('author')->create()->load($userId);
|
||||
$row->setData($this->getColumn()->getIndex(), $author->getName());
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Categories extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$CategoryIds = explode(',', $row->getData($this->getColumn()->getIndex()) ?? '');
|
||||
foreach ($CategoryIds as $categoryId) {
|
||||
$category = $this->_helperData->getFactoryByType('category')->create()->load($categoryId);
|
||||
$text .= $category->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?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_LayeredNavigationUltimate
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
|
||||
use Magento\Framework\DataObject;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Store\Model\System\Store as SystemStore;
|
||||
|
||||
/**
|
||||
* Class Name
|
||||
* @package Mageplaza\LayeredNavigationUltimate\Block\Adminhtml\Grid\Renderer
|
||||
*/
|
||||
class Store extends AbstractRenderer
|
||||
{
|
||||
/**
|
||||
* @var Escaper
|
||||
*/
|
||||
protected $escaper;
|
||||
|
||||
/**
|
||||
* System store
|
||||
*
|
||||
* @var SystemStore
|
||||
*/
|
||||
protected $systemStore;
|
||||
|
||||
/**
|
||||
* Store constructor.
|
||||
*
|
||||
* @param SystemStore $systemStore
|
||||
* @param Escaper $escaper
|
||||
*/
|
||||
public function __construct(
|
||||
SystemStore $systemStore,
|
||||
Escaper $escaper
|
||||
) {
|
||||
$this->systemStore = $systemStore;
|
||||
$this->escaper = $escaper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders grid column
|
||||
*
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if ($row) {
|
||||
$store = '';
|
||||
$store .= $this->prepareItem($row->getData());
|
||||
|
||||
return $store;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $item
|
||||
* @return \Magento\Framework\Phrase|string
|
||||
*/
|
||||
protected function prepareItem(array $item)
|
||||
{
|
||||
$content = '';
|
||||
$origStores = [];
|
||||
$items = explode(",", $item['store_ids']);
|
||||
|
||||
foreach ($items as $storeId) {
|
||||
$origStores[] = $storeId;
|
||||
}
|
||||
|
||||
if (in_array(0, $origStores)) {
|
||||
return __('All Store Views');
|
||||
}
|
||||
|
||||
$data = $this->systemStore->getStoresStructure(false, $origStores);
|
||||
foreach ($data as $website) {
|
||||
$content .= "<b>" . $website['label'] . "</b><br/>";
|
||||
foreach ($website['children'] as $group) {
|
||||
$content .= str_repeat(' ', 3) . "<b>" . $this->escaper->escapeHtml($group['label']) . "</b><br/>";
|
||||
foreach ($group['children'] as $store) {
|
||||
$content .= str_repeat(' ', 6) . $this->escaper->escapeHtml($store['label']) . "<br/>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Tags extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$tagIds = explode(',', $row->getData($this->getColumn()->getIndex()));
|
||||
foreach ($tagIds as $tagId) {
|
||||
$tag = $this->_helperData->getFactoryByType('tag')->create()->load($tagId);
|
||||
$text .= $tag->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer\History;
|
||||
|
||||
use Magento\Backend\Block\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Text;
|
||||
use Magento\Framework\DataObject;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Topics extends Text
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $_helperData;
|
||||
|
||||
/**
|
||||
* Categories constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $_helperData
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $_helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_helperData = $_helperData;
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObject $row
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(DataObject $row)
|
||||
{
|
||||
if (!empty($row->getData($this->getColumn()->getIndex()))) {
|
||||
$text = '';
|
||||
$topicIds = explode(',', $row->getData($this->getColumn()->getIndex()));
|
||||
foreach ($topicIds as $topicId) {
|
||||
$topic = $this->_helperData->getFactoryByType('topic')->create()->load($topicId);
|
||||
$text .= $topic->getName() . ',';
|
||||
}
|
||||
$row->setData($this->getColumn()->getIndex(), trim($text, ','));
|
||||
}
|
||||
|
||||
return parent::render($row);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\CollectionFactory as BlogTagCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Tag
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Tag extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogTagCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* Authorization
|
||||
*
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Tag constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogTagCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogTagCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-tag-select" class="admin__field" data-bind="scope:\'blogTag\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[tags_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"'
|
||||
. 'data-bind="scope:\'create_tag_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_tag_modal\' --><!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::tag');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTagsCollection()
|
||||
{
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
$tagById = [];
|
||||
foreach ($collection as $tag) {
|
||||
$tagById[$tag->getId()]['value'] = $tag->getId();
|
||||
$tagById[$tag->getId()]['is_active'] = 1;
|
||||
$tagById[$tag->getId()]['label'] = $tag->getName();
|
||||
}
|
||||
|
||||
return $tagById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $tag) {
|
||||
$options[] = $tag->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Tag suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogTag": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_tag": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getTagsCollection()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_tag:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_tag",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_tag_button": {
|
||||
"title": "' . __('New Tag') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_tag_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_tag_modal.create_tag",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_tag_modal.create_tag",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_tag_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Tag') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_tag:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_tag": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
[
|
||||
'handle' => 'mageplaza_blog_tag_create',
|
||||
'buttons' => 1
|
||||
]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_tag_form",
|
||||
"externalProvider": "blog_new_tag_form.new_tag_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
<?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\Adminhtml\Post\Edit\Tab\Renderer;
|
||||
|
||||
use Magento\Framework\AuthorizationInterface;
|
||||
use Magento\Framework\Data\Form\Element\CollectionFactory;
|
||||
use Magento\Framework\Data\Form\Element\Factory;
|
||||
use Magento\Framework\Data\Form\Element\Multiselect;
|
||||
use Magento\Framework\Escaper;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\CollectionFactory as BlogTopicCollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Topic
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer
|
||||
*/
|
||||
class Topic extends Multiselect
|
||||
{
|
||||
/**
|
||||
* @var BlogTopicCollectionFactory
|
||||
*/
|
||||
public $collectionFactory;
|
||||
|
||||
/**
|
||||
* Authorization
|
||||
*
|
||||
* @var AuthorizationInterface
|
||||
*/
|
||||
public $authorization;
|
||||
|
||||
/**
|
||||
* @var UrlInterface
|
||||
*/
|
||||
protected $_urlBuilder;
|
||||
|
||||
/**
|
||||
* Topic constructor.
|
||||
*
|
||||
* @param Factory $factoryElement
|
||||
* @param CollectionFactory $factoryCollection
|
||||
* @param Escaper $escaper
|
||||
* @param BlogTopicCollectionFactory $collectionFactory
|
||||
* @param AuthorizationInterface $authorization
|
||||
* @param UrlInterface $urlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Factory $factoryElement,
|
||||
CollectionFactory $factoryCollection,
|
||||
Escaper $escaper,
|
||||
BlogTopicCollectionFactory $collectionFactory,
|
||||
AuthorizationInterface $authorization,
|
||||
UrlInterface $urlBuilder,
|
||||
array $data = []
|
||||
) {
|
||||
$this->collectionFactory = $collectionFactory;
|
||||
$this->authorization = $authorization;
|
||||
$this->_urlBuilder = $urlBuilder;
|
||||
|
||||
parent::__construct($factoryElement, $factoryCollection, $escaper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getElementHtml()
|
||||
{
|
||||
$html = '<div class="admin__field-control admin__control-grouped">';
|
||||
$html .= '<div id="blog-topic-select" class="admin__field" data-bind="scope:\'blogTopic\'" data-index="index">';
|
||||
$html .= '<!-- ko foreach: elems() -->';
|
||||
$html .= '<input name="post[topics_ids]" data-bind="value: value" style="display: none"/>';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '<!-- /ko -->';
|
||||
$html .= '</div>';
|
||||
|
||||
$html .= '<div class="admin__field admin__field-group-additional admin__field-small"'
|
||||
. ' data-bind="scope:\'create_topic_button\'">';
|
||||
$html .= '<div class="admin__field-control">';
|
||||
$html .= '<!-- ko template: elementTmpl --><!-- /ko -->';
|
||||
$html .= '</div></div></div>';
|
||||
|
||||
$html .= '<!-- ko scope: \'create_topic_modal\' --><!-- ko template: getTemplate() --><!-- /ko --><!-- /ko -->';
|
||||
|
||||
$html .= $this->getAfterElementHtml();
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get no display
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getNoDisplay()
|
||||
{
|
||||
$isNotAllowed = !$this->authorization->isAllowed('Mageplaza_Blog::topic');
|
||||
|
||||
return $this->getData('no_display') || $isNotAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTopicsCollection()
|
||||
{
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create();
|
||||
$topicById = [];
|
||||
foreach ($collection as $topic) {
|
||||
$topicById[$topic->getId()]['value'] = $topic->getId();
|
||||
$topicById[$topic->getId()]['is_active'] = 1;
|
||||
$topicById[$topic->getId()]['label'] = $topic->getName();
|
||||
}
|
||||
|
||||
return $topicById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values for select
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$values = $this->getValue();
|
||||
|
||||
if (!is_array($values)) {
|
||||
$values = explode(',', $values);
|
||||
}
|
||||
|
||||
if (!count($values)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* @var $collection Collection */
|
||||
$collection = $this->collectionFactory->create()
|
||||
->addIdFilter($values);
|
||||
|
||||
$options = [];
|
||||
foreach ($collection as $topic) {
|
||||
$options[] = $topic->getId();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach Blog Topic suggest widget initialization
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAfterElementHtml()
|
||||
{
|
||||
$html = '<script type="text/x-magento-init">
|
||||
{
|
||||
"*": {
|
||||
"Magento_Ui/js/core/app": {
|
||||
"components": {
|
||||
"blogTopic": {
|
||||
"component": "uiComponent",
|
||||
"children": {
|
||||
"blog_select_topic": {
|
||||
"component": "Mageplaza_Blog/js/components/new-category",
|
||||
"config": {
|
||||
"filterOptions": true,
|
||||
"disableLabel": true,
|
||||
"chipsEnabled": true,
|
||||
"levelsVisibility": "1",
|
||||
"elementTmpl": "ui/grid/filters/elements/ui-select",
|
||||
"options": ' . json_encode($this->getTopicsCollection()) . ',
|
||||
"value": ' . json_encode($this->getValues()) . ',
|
||||
"listens": {
|
||||
"index=create_topic:responseData": "setParsed",
|
||||
"newOption": "toggleOptionSelected"
|
||||
},
|
||||
"config": {
|
||||
"dataScope": "blog_select_topic",
|
||||
"sortOrder": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"create_topic_button": {
|
||||
"title": "' . __('New Topic') . '",
|
||||
"formElement": "container",
|
||||
"additionalClasses": "admin__field-small",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/button",
|
||||
"template": "ui/form/components/button/container",
|
||||
"actions": [
|
||||
{
|
||||
"targetName": "create_topic_modal",
|
||||
"actionName": "toggleModal"
|
||||
},
|
||||
{
|
||||
"targetName": "create_topic_modal.create_topic",
|
||||
"actionName": "render"
|
||||
},
|
||||
{
|
||||
"targetName": "create_topic_modal.create_topic",
|
||||
"actionName": "resetForm"
|
||||
}
|
||||
],
|
||||
"additionalForGroup": true,
|
||||
"provider": false,
|
||||
"source": "product_details",
|
||||
"displayArea": "insideGroup"
|
||||
},
|
||||
"create_topic_modal": {
|
||||
"config": {
|
||||
"isTemplate": false,
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/modal/modal-component",
|
||||
"options": {
|
||||
"title": "' . __('New Topic') . '",
|
||||
"type": "slide"
|
||||
},
|
||||
"imports": {
|
||||
"state": "!index=create_topic:responseStatus"
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"create_topic": {
|
||||
"label": "",
|
||||
"componentType": "container",
|
||||
"component": "Magento_Ui/js/form/components/insert-form",
|
||||
"dataScope": "",
|
||||
"update_url": "' . $this->_urlBuilder->getUrl('mui/index/render') . '",
|
||||
"render_url": "' .
|
||||
$this->_urlBuilder->getUrl(
|
||||
'mui/index/render_handle',
|
||||
[
|
||||
'handle' => 'mageplaza_blog_topic_create',
|
||||
'buttons' => 1
|
||||
]
|
||||
) . '",
|
||||
"autoRender": false,
|
||||
"ns": "blog_new_topic_form",
|
||||
"externalProvider": "blog_new_topic_form.new_topic_form_data_source",
|
||||
"toolbarContainer": "${ $.parentName }",
|
||||
"formSubmitType": "ajax"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Adminhtml\Post\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Post\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('post_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Post Information'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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_Core
|
||||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
|
||||
* @license https://www.mageplaza.com/LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Mageplaza\Blog\Block\Adminhtml\Renderer;
|
||||
|
||||
/**
|
||||
* Renderer image for admin form
|
||||
* Add media path to url
|
||||
*
|
||||
* Class Image
|
||||
* @package Mageplaza\Core\Block\Adminhtml\Renderer
|
||||
*/
|
||||
class Image extends \Mageplaza\Core\Block\Adminhtml\Renderer\Image
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function _getDeleteCheckbox()
|
||||
{
|
||||
$html = '';
|
||||
if ($this->getValue()) {
|
||||
$label = __('Delete Image');
|
||||
$html .= '<span class="delete-image">';
|
||||
$html .= '<input style="margin: auto;" type="checkbox"' .
|
||||
' name="' .
|
||||
$this->getName() .
|
||||
'[delete]" value="1" class="checkbox"' .
|
||||
' id="' .
|
||||
$this->getHtmlId() .
|
||||
'_delete"' .
|
||||
($this->getDisabled() ? ' disabled="disabled"' : '') .
|
||||
'/>';
|
||||
$html .= '<label for="' . $this->getHtmlId() .
|
||||
'_delete"' . ($this->getDisabled() ? ' class="disabled"' : '') . '> ' .
|
||||
$label .
|
||||
'</label>';
|
||||
$html .= $this->_getHiddenInput();
|
||||
$html .= '</span>';
|
||||
}
|
||||
$html .= '<style>#author_image_image, #post_image_image{ position: relative;top: 6px }</style>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?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\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Container;
|
||||
|
||||
/**
|
||||
* Class Tag
|
||||
* @package Mageplaza\Blog\Block\Adminhtml
|
||||
*/
|
||||
class Tag extends Container
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'adminhtml_tag';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_headerText = __('Tags');
|
||||
$this->_addButtonLabel = __('Create New Tag');
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?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\Adminhtml\Tag;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Tag edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_tag';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
$this->buttonList->add(
|
||||
'save-and-continue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
-100
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Tag $tag */
|
||||
$tag = $this->coreRegistry->registry('mageplaza_blog_tag');
|
||||
if ($tag->getId()) {
|
||||
return __("Edit Tag '%1'", $this->escapeHtml($tag->getName()));
|
||||
}
|
||||
|
||||
return __('New Tag');
|
||||
}
|
||||
}
|
||||
@@ -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\Adminhtml\Tag\Edit\Button;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
/**
|
||||
* Button "Create Tag" in "New Category" slide-out panel of a product page
|
||||
* Class CreateTag
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit\Button
|
||||
*/
|
||||
class CreateTag implements ButtonProviderInterface
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Create Tag'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 10
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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\Adminhtml\Tag\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
<?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\Adminhtml\Tag\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit\Tab
|
||||
*/
|
||||
class Post extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Post collection factory
|
||||
*
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
public $postCollectionFactory;
|
||||
|
||||
/**
|
||||
* Registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Post factory
|
||||
*
|
||||
* @var PostFactory
|
||||
*/
|
||||
public $postFactory;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param Data $backendHelper
|
||||
* @param PostFactory $postFactory
|
||||
* @param CollectionFactory $postCollectionFactory
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
Data $backendHelper,
|
||||
PostFactory $postFactory,
|
||||
CollectionFactory $postCollectionFactory,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->postFactory = $postFactory;
|
||||
$this->postCollectionFactory = $postCollectionFactory;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('post_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setSaveParametersInSession(false);
|
||||
$this->setUseAjax(true);
|
||||
|
||||
if ($this->getTag()->getId()) {
|
||||
$this->setDefaultFilter(['in_posts' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->postCollectionFactory->create();
|
||||
$collection->getSelect()->joinLeft(
|
||||
['related' => $collection->getTable('mageplaza_blog_post_tag')],
|
||||
'related.post_id=main_table.post_id AND related.tag_id=' . (int) $this->getRequest()->getParam('id', 0),
|
||||
['position']
|
||||
);
|
||||
|
||||
$collection->addFilterToMap('post_id', 'main_table.post_id');
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('in_posts', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'in_post',
|
||||
'values' => $this->_getSelectedPosts(),
|
||||
'align' => 'center',
|
||||
'index' => 'post_id'
|
||||
]);
|
||||
$this->addColumn('post_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'post_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
protected function _getSelectedPosts()
|
||||
{
|
||||
$posts = $this->getRequest()->getPost('tag_posts', null);
|
||||
if (!is_array($posts)) {
|
||||
$posts = $this->getTag()->getPostsPosition();
|
||||
|
||||
return array_keys($posts);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectedPosts()
|
||||
{
|
||||
$selected = $this->getTag()->getPostsPosition();
|
||||
if (!is_array($selected)) {
|
||||
$selected = [];
|
||||
} else {
|
||||
foreach ($selected as $key => $value) {
|
||||
$selected[$key] = ['position' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Model\Post|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/postsGrid', ['id' => $this->getTag()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Tag
|
||||
*/
|
||||
public function getTag()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _addColumnFilterToCollection($column)
|
||||
{
|
||||
if ($column->getId() == 'in_posts') {
|
||||
$postIds = $this->_getSelectedPosts();
|
||||
if (empty($postIds)) {
|
||||
$postIds = 0;
|
||||
}
|
||||
if ($column->getFilter()->getValue()) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['in' => $postIds]);
|
||||
} elseif ($postIds) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['nin' => $postIds]);
|
||||
}
|
||||
} else {
|
||||
parent::_addColumnFilterToCollection($column);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Posts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/tag/posts', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
<?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\Adminhtml\Tag\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Design\Robots;
|
||||
use Magento\Config\Model\Config\Source\Enabledisable;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
/**
|
||||
* Class Tag
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit\Tab
|
||||
*/
|
||||
class Tag extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Wysiwyg config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
public $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* Country options
|
||||
*
|
||||
* @var Yesno
|
||||
*/
|
||||
public $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var Enabledisable
|
||||
*/
|
||||
protected $enableDisable;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
public $systemStore;
|
||||
|
||||
/**
|
||||
* @var Robots
|
||||
*/
|
||||
public $metaRobots;
|
||||
|
||||
/**
|
||||
* Tag constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Yesno $booleanOptions
|
||||
* @param Enabledisable $enableDisable
|
||||
* @param Store $systemStore
|
||||
* @param Robots $metaRobotsOptions
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
Config $wysiwygConfig,
|
||||
Yesno $booleanOptions,
|
||||
Enabledisable $enableDisable,
|
||||
Store $systemStore,
|
||||
Robots $metaRobotsOptions,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
$this->enableDisable = $enableDisable;
|
||||
$this->systemStore = $systemStore;
|
||||
$this->metaRobots = $metaRobotsOptions;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Tag $tag */
|
||||
$tag = $this->_coreRegistry->registry('mageplaza_blog_tag');
|
||||
|
||||
$form = $this->_formFactory->create();
|
||||
$form->setHtmlIdPrefix('tag_');
|
||||
$form->setFieldNameSuffix('tag');
|
||||
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Tag Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
if ($tag->getId()) {
|
||||
$fieldset->addField('tag_id', 'hidden', ['name' => 'tag_id']);
|
||||
}
|
||||
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Name'),
|
||||
'title' => __('Name'),
|
||||
'required' => true,
|
||||
]);
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
$fieldset->addField('enabled', 'select', [
|
||||
'name' => 'enabled',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->enableDisable->toOptionArray(),
|
||||
]);
|
||||
if (!$tag->hasData('enabled')) {
|
||||
$tag->setEnabled(1);
|
||||
}
|
||||
|
||||
$fieldset->addField('description', 'editor', [
|
||||
'name' => 'description',
|
||||
'label' => __('Description'),
|
||||
'title' => __('Description'),
|
||||
'config' => $this->wysiwygConfig->getConfig(['add_variables' => false, 'add_widgets' => false])
|
||||
]);
|
||||
|
||||
if (!$this->_storeManager->isSingleStoreMode()) {
|
||||
/** @var RendererInterface $rendererBlock */
|
||||
$rendererBlock = $this->getLayout()->createBlock(
|
||||
Element::class
|
||||
);
|
||||
$fieldset->addField('store_ids', 'multiselect', [
|
||||
'name' => 'store_ids',
|
||||
'label' => __('Store Views'),
|
||||
'title' => __('Store Views'),
|
||||
'values' => $this->systemStore->getStoreValuesForForm(false, true)
|
||||
])->setRenderer($rendererBlock);
|
||||
|
||||
if (!$tag->hasData('store_ids')) {
|
||||
$tag->setStoreIds(0);
|
||||
}
|
||||
} else {
|
||||
$fieldset->addField('store_ids', 'hidden', [
|
||||
'name' => 'store_ids',
|
||||
'value' => $this->_storeManager->getStore()->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
$form->addValues($tag->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
$this->_eventManager->dispatch('adminhtml_blog_edit_form_prepare_form', ['block' => $this]);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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\Adminhtml\Tag\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Tag\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('tag_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Tag Information'));
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?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\Adminhtml;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Container;
|
||||
|
||||
/**
|
||||
* Class Topic
|
||||
* @package Mageplaza\Blog\Block\Adminhtml
|
||||
*/
|
||||
class Topic extends Container
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_controller = 'adminhtml_topic';
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_headerText = __('Topics');
|
||||
$this->_addButtonLabel = __('Create New Topic');
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?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\Adminhtml\Topic;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Container;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\Topic;
|
||||
|
||||
/**
|
||||
* Class Edit
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Topic
|
||||
*/
|
||||
class Edit extends Container
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Edit constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Topic edit block
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_blockGroup = 'Mageplaza_Blog';
|
||||
$this->_controller = 'adminhtml_topic';
|
||||
|
||||
parent::_construct();
|
||||
|
||||
$this->buttonList->add(
|
||||
'save-and-continue',
|
||||
[
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => [
|
||||
'button' => [
|
||||
'event' => 'saveAndContinueEdit',
|
||||
'target' => '#edit_form'
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
-100
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve text for header element depending on loaded Topic
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderText()
|
||||
{
|
||||
/** @var Topic $topic */
|
||||
$topic = $this->coreRegistry->registry('mageplaza_blog_topic');
|
||||
if ($topic->getId()) {
|
||||
return __("Edit Topic '%1'", $this->escapeHtml($topic->getName()));
|
||||
}
|
||||
|
||||
return __('New Topic');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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\Adminhtml\Topic\Edit\Button;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
/**
|
||||
* Button "Create Topic" in "New Category" slide-out panel of a product page
|
||||
*/
|
||||
class CreateTopic implements ButtonProviderInterface
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getButtonData()
|
||||
{
|
||||
return [
|
||||
'label' => __('Create Topic'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 10
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\Adminhtml\Topic\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
|
||||
/**
|
||||
* Class Form
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Topic\Edit
|
||||
*/
|
||||
class Form extends Generic
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Magento\Framework\Data\Form $form */
|
||||
$form = $this->_formFactory->create([
|
||||
'data' => [
|
||||
'id' => 'edit_form',
|
||||
'action' => $this->getData('action'),
|
||||
'method' => 'post',
|
||||
'enctype' => 'multipart/form-data'
|
||||
]
|
||||
]);
|
||||
$form->setUseContainer(true);
|
||||
$this->setForm($form);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
<?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\Adminhtml\Topic\Edit\Tab;
|
||||
|
||||
use Exception;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Backend\Block\Widget\Grid\Extended;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Backend\Helper\Data;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Post
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Topic\Edit\Tab
|
||||
*/
|
||||
class Post extends Extended implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* Post factory
|
||||
*
|
||||
* @var PostFactory
|
||||
*/
|
||||
public $postFactory;
|
||||
|
||||
/**
|
||||
* Post constructor.
|
||||
*
|
||||
* @param Registry $coreRegistry
|
||||
* @param PostFactory $postFactory
|
||||
* @param Context $context
|
||||
* @param Data $backendHelper
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Registry $coreRegistry,
|
||||
PostFactory $postFactory,
|
||||
Context $context,
|
||||
Data $backendHelper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->postFactory = $postFactory;
|
||||
|
||||
parent::__construct($context, $backendHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set grid params
|
||||
*/
|
||||
public function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
$this->setId('post_grid');
|
||||
$this->setDefaultSort('position');
|
||||
$this->setDefaultDir('ASC');
|
||||
$this->setUseAjax(true);
|
||||
if ($this->getTopic()->getId()) {
|
||||
$this->setDefaultFilter(['in_posts' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareCollection()
|
||||
{
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->postFactory->create()->getCollection();
|
||||
$collection->getSelect()->joinLeft(
|
||||
['related' => $collection->getTable('mageplaza_blog_post_topic')],
|
||||
'related.post_id=main_table.post_id AND related.topic_id=' . (int) $this->getRequest()->getParam('id', 0),
|
||||
['position']
|
||||
);
|
||||
|
||||
$this->setCollection($collection);
|
||||
|
||||
return parent::_prepareCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function _prepareColumns()
|
||||
{
|
||||
$this->addColumn('in_posts', [
|
||||
'header_css_class' => 'a-center',
|
||||
'type' => 'checkbox',
|
||||
'name' => 'in_post',
|
||||
'values' => $this->_getSelectedPosts(),
|
||||
'align' => 'center',
|
||||
'index' => 'post_id'
|
||||
]);
|
||||
$this->addColumn('post_id', [
|
||||
'header' => __('ID'),
|
||||
'sortable' => true,
|
||||
'index' => 'post_id',
|
||||
'type' => 'number',
|
||||
'header_css_class' => 'col-id',
|
||||
'column_css_class' => 'col-id'
|
||||
]);
|
||||
$this->addColumn('title', [
|
||||
'header' => __('Name'),
|
||||
'index' => 'name',
|
||||
'header_css_class' => 'col-name',
|
||||
'column_css_class' => 'col-name'
|
||||
]);
|
||||
$this->addColumn('position', [
|
||||
'header' => __('Position'),
|
||||
'name' => 'position',
|
||||
'width' => 60,
|
||||
'type' => 'number',
|
||||
'validate_class' => 'validate-number',
|
||||
'index' => 'position',
|
||||
'editable' => true,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
protected function _getSelectedPosts()
|
||||
{
|
||||
$posts = $this->getRequest()->getPost('topic_posts', null);
|
||||
if (!is_array($posts)) {
|
||||
$posts = $this->getTopic()->getPostsPosition();
|
||||
|
||||
return array_keys($posts);
|
||||
}
|
||||
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve selected Posts
|
||||
* @return array
|
||||
*/
|
||||
public function getSelectedPosts()
|
||||
{
|
||||
$selected = $this->getTopic()->getPostsPosition();
|
||||
if (!is_array($selected)) {
|
||||
$selected = [];
|
||||
} else {
|
||||
foreach ($selected as $key => $value) {
|
||||
$selected[$key] = ['position' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
return $selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Mageplaza\Blog\Model\Post|Object $item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRowUrl($item)
|
||||
{
|
||||
return '#';
|
||||
}
|
||||
|
||||
/**
|
||||
* get grid url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGridUrl()
|
||||
{
|
||||
return $this->getUrl('*/*/postsGrid', ['id' => $this->getTopic()->getId()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Mageplaza\Blog\Model\Topic
|
||||
*/
|
||||
public function getTopic()
|
||||
{
|
||||
return $this->coreRegistry->registry('mageplaza_blog_topic');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
*
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _addColumnFilterToCollection($column)
|
||||
{
|
||||
if ($column->getId() === 'in_posts') {
|
||||
$postIds = $this->_getSelectedPosts();
|
||||
if (empty($postIds)) {
|
||||
$postIds = 0;
|
||||
}
|
||||
if ($column->getFilter()->getValue()) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['in' => $postIds]);
|
||||
} elseif ($postIds) {
|
||||
$this->getCollection()->addFieldToFilter('main_table.post_id', ['nin' => $postIds]);
|
||||
}
|
||||
} else {
|
||||
parent::_addColumnFilterToCollection($column);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Posts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabUrl()
|
||||
{
|
||||
return $this->getUrl('mageplaza_blog/topic/posts', ['_current' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTabClass()
|
||||
{
|
||||
return 'ajax only';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?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\Adminhtml\Topic\Edit\Tab;
|
||||
|
||||
use Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element;
|
||||
use Magento\Backend\Block\Template\Context;
|
||||
use Magento\Backend\Block\Widget\Form\Generic;
|
||||
use Magento\Backend\Block\Widget\Tab\TabInterface;
|
||||
use Magento\Cms\Model\Wysiwyg\Config;
|
||||
use Magento\Config\Model\Config\Source\Design\Robots;
|
||||
use Magento\Config\Model\Config\Source\Enabledisable;
|
||||
use Magento\Config\Model\Config\Source\Yesno;
|
||||
use Magento\Framework\Data\Form\Element\Renderer\RendererInterface;
|
||||
use Magento\Framework\Data\FormFactory;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Store\Model\System\Store;
|
||||
|
||||
/**
|
||||
* Class Topic
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Topic\Edit\Tab
|
||||
*/
|
||||
class Topic extends Generic implements TabInterface
|
||||
{
|
||||
/**
|
||||
* Wysiwyg config
|
||||
*
|
||||
* @var Config
|
||||
*/
|
||||
protected $wysiwygConfig;
|
||||
|
||||
/**
|
||||
* Country options
|
||||
*
|
||||
* @var Yesno
|
||||
*/
|
||||
protected $booleanOptions;
|
||||
|
||||
/**
|
||||
* @var Enabledisable
|
||||
*/
|
||||
protected $enableDisable;
|
||||
|
||||
/**
|
||||
* @var Robots
|
||||
*/
|
||||
protected $metaRobotsOptions;
|
||||
|
||||
/**
|
||||
* @var Store
|
||||
*/
|
||||
protected $systemStore;
|
||||
|
||||
/**
|
||||
* Topic constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param FormFactory $formFactory
|
||||
* @param Config $wysiwygConfig
|
||||
* @param Yesno $booleanOptions
|
||||
* @param Enabledisable $enableDisable
|
||||
* @param Robots $metaRobotsOptions
|
||||
* @param Store $systemStore
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
FormFactory $formFactory,
|
||||
Config $wysiwygConfig,
|
||||
Yesno $booleanOptions,
|
||||
Enabledisable $enableDisable,
|
||||
Robots $metaRobotsOptions,
|
||||
Store $systemStore,
|
||||
array $data = []
|
||||
) {
|
||||
$this->wysiwygConfig = $wysiwygConfig;
|
||||
$this->booleanOptions = $booleanOptions;
|
||||
$this->enableDisable = $enableDisable;
|
||||
$this->metaRobotsOptions = $metaRobotsOptions;
|
||||
$this->systemStore = $systemStore;
|
||||
|
||||
parent::__construct($context, $registry, $formFactory, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareForm()
|
||||
{
|
||||
/** @var \Mageplaza\Blog\Model\Topic $topic */
|
||||
$topic = $this->_coreRegistry->registry('mageplaza_blog_topic');
|
||||
|
||||
$form = $this->_formFactory->create();
|
||||
$form->setHtmlIdPrefix('topic_');
|
||||
$form->setFieldNameSuffix('topic');
|
||||
|
||||
$fieldset = $form->addFieldset('base_fieldset', [
|
||||
'legend' => __('Topic Information'),
|
||||
'class' => 'fieldset-wide'
|
||||
]);
|
||||
if ($topic->getId()) {
|
||||
$fieldset->addField('topic_id', 'hidden', ['name' => 'topic_id']);
|
||||
}
|
||||
|
||||
$fieldset->addField('name', 'text', [
|
||||
'name' => 'name',
|
||||
'label' => __('Name'),
|
||||
'title' => __('Name'),
|
||||
'required' => true,
|
||||
]);
|
||||
$fieldset->addField('url_key', 'text', [
|
||||
'name' => 'url_key',
|
||||
'label' => __('URL Key'),
|
||||
'title' => __('URL Key')
|
||||
]);
|
||||
$fieldset->addField('enabled', 'select', [
|
||||
'name' => 'enabled',
|
||||
'label' => __('Status'),
|
||||
'title' => __('Status'),
|
||||
'values' => $this->enableDisable->toOptionArray(),
|
||||
]);
|
||||
if (!$topic->hasData('enabled')) {
|
||||
$topic->setEnabled(1);
|
||||
}
|
||||
|
||||
$fieldset->addField('description', 'editor', [
|
||||
'name' => 'description',
|
||||
'label' => __('Description'),
|
||||
'title' => __('Description'),
|
||||
'config' => $this->wysiwygConfig->getConfig(['add_variables' => false, 'add_widgets' => false])
|
||||
]);
|
||||
|
||||
if (!$this->_storeManager->isSingleStoreMode()) {
|
||||
/** @var RendererInterface $rendererBlock */
|
||||
$rendererBlock = $this->getLayout()->createBlock(
|
||||
Element::class
|
||||
);
|
||||
$fieldset->addField('store_ids', 'multiselect', [
|
||||
'name' => 'store_ids',
|
||||
'label' => __('Store Views'),
|
||||
'title' => __('Store Views'),
|
||||
'values' => $this->systemStore->getStoreValuesForForm(false, true)
|
||||
])->setRenderer($rendererBlock);
|
||||
if (!$topic->hasData('store_ids')) {
|
||||
$topic->setStoreIds(0);
|
||||
}
|
||||
} else {
|
||||
$fieldset->addField('store_ids', 'hidden', [
|
||||
'name' => 'store_ids',
|
||||
'value' => $this->_storeManager->getStore()->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
$form->addValues($topic->getData());
|
||||
$this->setForm($form);
|
||||
|
||||
$this->_eventManager->dispatch('adminhtml_blog_edit_form_prepare_form', ['block' => $this]);
|
||||
|
||||
return parent::_prepareForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare label for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabLabel()
|
||||
{
|
||||
return __('Topic');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare title for tab
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTabTitle()
|
||||
{
|
||||
return $this->getTabLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Can show tab in tabs
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function canShowTab()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab is hidden
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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\Adminhtml\Topic\Edit;
|
||||
|
||||
/**
|
||||
* Class Tabs
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Topic\Edit
|
||||
*/
|
||||
class Tabs extends \Magento\Backend\Block\Widget\Tabs
|
||||
{
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$this->setId('topic_tabs');
|
||||
$this->setDestElementId('edit_form');
|
||||
$this->setTitle(__('Topic Information'));
|
||||
}
|
||||
}
|
||||
@@ -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\Adminhtml\Widget;
|
||||
|
||||
use Magento\Backend\Block\Widget\Grid\Column;
|
||||
use Magento\Framework\Data\Form\Element\AbstractElement;
|
||||
|
||||
/**
|
||||
* Class Number
|
||||
* @package Mageplaza\Blog\Block\Adminhtml\Widget
|
||||
*/
|
||||
class Number extends Column
|
||||
{
|
||||
/**
|
||||
* @param AbstractElement $element
|
||||
*
|
||||
* @return AbstractElement
|
||||
*/
|
||||
public function prepareElementHtml(AbstractElement $element)
|
||||
{
|
||||
$html = '<input type="text" name="' . $element->getName() . '" id="' . $element->getId()
|
||||
. '" class=" input-text admin__control-text required-entry _required validate-digits" value="'
|
||||
. $element->getValue() . '">';
|
||||
$element->setData('value', '');
|
||||
$element->setData('after_element_html', $html);
|
||||
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
<?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\Category;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Category
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_category;
|
||||
|
||||
/**
|
||||
* Override this function to apply collection for each type
|
||||
*
|
||||
* @return Collection|null
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
if ($category = $this->getBlogObject()) {
|
||||
return $this->helperData->getPostCollection(Data::TYPE_CATEGORY, $category->getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getBlogObject()
|
||||
{
|
||||
if (!$this->_category) {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
if ($id) {
|
||||
$category = $this->helperData->getObjectByParam($id, null, Data::TYPE_CATEGORY);
|
||||
if ($category && $category->getId()) {
|
||||
$this->_category = $category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$category = $this->getBlogObject();
|
||||
$categoryName = preg_replace('/[^A-Za-z0-9\-]/', ' ', $category->getName());
|
||||
if ($category) {
|
||||
$breadcrumbs->addCrumb($category->getUrlKey(), [
|
||||
'label' => __($categoryName),
|
||||
'title' => __($categoryName)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
*
|
||||
* @return array|Phrase|string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
$category = $this->getBlogObject();
|
||||
if (!$category) {
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
if ($this->helperData->getMetaTitleByStoreId($category->getMetaTitle())) {
|
||||
$blogTitle[] = $this->helperData->getMetaTitleByStoreId($category->getMetaTitle());
|
||||
} else {
|
||||
$blogTitle[] = ucfirst($category->getName());
|
||||
}
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return ucfirst($category->getName());
|
||||
}
|
||||
}
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
<?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\Category;
|
||||
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Mageplaza\Blog\Api\Data\CategoryInterface;
|
||||
use Mageplaza\Blog\Helper\Data as HelperData;
|
||||
use Mageplaza\Blog\Model\Category;
|
||||
use Mageplaza\Blog\Model\CategoryFactory;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\CollectionFactory;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\Category
|
||||
*/
|
||||
class Menu extends Template
|
||||
{
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $categoryCollection;
|
||||
|
||||
/**
|
||||
* @var CategoryFactory
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* @var HelperData
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* Menu constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param CollectionFactory $collectionFactory
|
||||
* @param CategoryFactory $categoryFactory
|
||||
* @param HelperData $helperData
|
||||
* @param StoreManagerInterface $storeManager
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
CollectionFactory $collectionFactory,
|
||||
CategoryFactory $categoryFactory,
|
||||
HelperData $helperData,
|
||||
StoreManagerInterface $storeManager,
|
||||
array $data = []
|
||||
) {
|
||||
$this->categoryCollection = $collectionFactory;
|
||||
$this->category = $categoryFactory;
|
||||
$this->helper = $helperData;
|
||||
$this->storeManager = $storeManager;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
*
|
||||
* @return CategoryInterface[]
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getChildCategory($id)
|
||||
{
|
||||
$collection = $this->categoryCollection->create()->addAttributeToFilter('parent_id', $id)
|
||||
->addAttributeToFilter('enabled', '1');
|
||||
$this->helper->addStoreFilter($collection, $this->storeManager->getStore()->getId());
|
||||
|
||||
return $collection->getItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getCollections()
|
||||
{
|
||||
$collection = $this->categoryCollection->create()
|
||||
->addAttributeToFilter('level', '1')->addAttributeToFilter('enabled', '1')->setOrder('position','ASC');
|
||||
|
||||
return $this->helper->addStoreFilter($collection, $this->storeManager->getStore()->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $parentCategory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMenuHtml($parentCategory)
|
||||
{
|
||||
$categoryUrl = $this->helper->getBlogUrl($parentCategory, HelperData::TYPE_CATEGORY);
|
||||
$html = '<li class="level' . $parentCategory->getLevel()
|
||||
. ' category-item ui-menu-item" role="presentation">'
|
||||
. '<a href="' . $categoryUrl . '" class="ui-corner-all" tabindex="-1" role="menuitem">'
|
||||
. '<span>' . $parentCategory->getName() . '</span></a>';
|
||||
|
||||
$childCategorys = $this->getChildCategory($parentCategory->getId());
|
||||
|
||||
if (count($childCategorys) > 0) {
|
||||
$html .= '<ul class="level' . $parentCategory->getLevel() . ' submenu ui-menu ui-widget'
|
||||
. ' ui-widget-content ui-corner-all"'
|
||||
. ' role="menu" aria-expanded="false" style="display: none; top: 47px; left: -0.15625px;"'
|
||||
. ' aria-hidden="true">';
|
||||
|
||||
/** @var Category $childCategory */
|
||||
foreach ($childCategorys as $childCategory) {
|
||||
$html .= $this->getMenuHtml($childCategory);
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
$html .= '</li>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $parentCategory
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPortoMenuHtml($parentCategory)
|
||||
{
|
||||
$categoryUrl = $this->helper->getBlogUrl($parentCategory, HelperData::TYPE_CATEGORY);
|
||||
$html = '<li class="ui-menu-item level' . $parentCategory->getLevel() . ' parent" role="presentation">'
|
||||
. '<div class="open-children-toggle"></div>'
|
||||
. '<a href="' . $categoryUrl . '" class="ui-corner-all" tabindex="-1" role="menuitem">'
|
||||
. '<span>' . $parentCategory->getName() . '</span></a>';
|
||||
|
||||
$childCategories = $this->getChildCategory($parentCategory->getId());
|
||||
|
||||
if (count($childCategories) > 0) {
|
||||
$html .= '<ul class="subchildmenu level' . $parentCategory->getLevel() . ''
|
||||
. ' ui-widget-content ui-corner-all"'
|
||||
. ' role="menu" aria-expanded="false"'
|
||||
. ' aria-hidden="true">';
|
||||
|
||||
/** @var Category $childCategory */
|
||||
foreach ($childCategories as $childCategory) {
|
||||
$html .= $this->getMenuHtml($childCategory);
|
||||
}
|
||||
$html .= '</ul>';
|
||||
}
|
||||
$html .= '</li>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Phrase|mixed
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBlogHomePageTitle()
|
||||
{
|
||||
return $this->helper->getBlogConfig('display/name', $this->helper->getCurrentStoreId()) ?: __('Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBlogHomeUrl()
|
||||
{
|
||||
return $this->helper->getBlogUrl('');
|
||||
}
|
||||
|
||||
|
||||
public function getBlogUrlByUrlKey($urlKey)
|
||||
{
|
||||
return $this->helper->getBlogUrl($urlKey, HelperData::TYPE_CATEGORY);
|
||||
}
|
||||
|
||||
public function getChildDataCate($category)
|
||||
{
|
||||
$childCategorys = $this->getChildCategory($category->getId());
|
||||
$childCategoryData = [];
|
||||
if (count($childCategorys) > 0) {
|
||||
foreach ($childCategorys as $childCategory) {
|
||||
$childCategoryUrl = $this->getBlogUrlByUrlKey($childCategory->getUrlKey());
|
||||
array_push($childCategoryData,
|
||||
[
|
||||
"name" => $childCategory->getName(),
|
||||
"id" => "mg-blog" . $childCategory->getId(),
|
||||
"url" => $childCategoryUrl,
|
||||
"image" => false,
|
||||
"has_active" => false,
|
||||
"is_active" => false,
|
||||
"is_category" => true,
|
||||
"is_parent_active" => true,
|
||||
"position" => null,
|
||||
"path" => "1/2/38",
|
||||
"childData" => $this->getChildDataCate($childCategory)
|
||||
]
|
||||
);
|
||||
}
|
||||
return $childCategoryData;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?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\Category;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\App\ObjectManager;
|
||||
use Magento\Framework\Phrase;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Category\Tree;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\Category
|
||||
*/
|
||||
class Widget extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getTree()
|
||||
{
|
||||
try {
|
||||
$tree = ObjectManager::getInstance()->create(Tree::class);
|
||||
$tree = $tree->getTree(null, $this->store->getStore()->getId());
|
||||
|
||||
return $tree;
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $tree
|
||||
*
|
||||
* @return Phrase|string
|
||||
*/
|
||||
public function getCategoryTreeHtml($tree)
|
||||
{
|
||||
if (!$tree) {
|
||||
return __('No Categories.');
|
||||
}
|
||||
|
||||
$html = '';
|
||||
foreach ($tree as $value) {
|
||||
if (!$value) {
|
||||
continue;
|
||||
}
|
||||
if ($value['enabled']) {
|
||||
$level = count(explode('/', ($value['path'])));
|
||||
$hasChild = isset($value['children']) && $level < 4;
|
||||
$html .= '<ul class="block-content menu-categories category-level'
|
||||
. $level . '" style="margin-bottom:0px;margin-top:8px;">';
|
||||
$html .= '<li class="category-item">';
|
||||
$html .= $hasChild ? '<i class="fa fa-plus-square-o mp-blog-expand-tree-' . $level . '"></i>' : '';
|
||||
$html .= '<a class="list-categories" href="' . $this->getCategoryUrl($value['url']) . '">';
|
||||
$html .= '<i class="fa fa-folder-open-o"> </i>';
|
||||
$html .= ucfirst($value['text']) . '</a>';
|
||||
$html .= $hasChild ? $this->getCategoryTreeHtml($value['children']) : '';
|
||||
$html .= '</li>';
|
||||
$html .= '</ul>';
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryUrl($category)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($category, Data::TYPE_CATEGORY);
|
||||
}
|
||||
}
|
||||
Executable
+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;
|
||||
|
||||
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
|
||||
use Magento\Framework\View\Design\ThemeInterface;
|
||||
use Magento\Framework\View\DesignInterface;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Mageplaza\Blog\Helper\Data as HelperData;
|
||||
|
||||
/**
|
||||
* Class Frontend
|
||||
*
|
||||
* @package Mageplaza\Blog\Block
|
||||
*/
|
||||
class Design extends Template
|
||||
{
|
||||
/**
|
||||
* @var HelperData
|
||||
*/
|
||||
public $helperData;
|
||||
|
||||
/**
|
||||
* @var ThemeProviderInterface
|
||||
*/
|
||||
protected $_themeProvider;
|
||||
|
||||
/**
|
||||
* Design constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param HelperData $helperData
|
||||
* @param ThemeProviderInterface $_themeProvider
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
HelperData $helperData,
|
||||
ThemeProviderInterface $_themeProvider,
|
||||
array $data = []
|
||||
) {
|
||||
$this->helperData = $helperData;
|
||||
$this->_themeProvider = $_themeProvider;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HelperData
|
||||
*/
|
||||
public function getHelper()
|
||||
{
|
||||
return $this->helperData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Current Theme Name Function
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentTheme()
|
||||
{
|
||||
$themeId = $this->helperData->getConfigValue(DesignInterface::XML_PATH_THEME_ID);
|
||||
|
||||
/** @var $theme ThemeInterface */
|
||||
$theme = $this->_themeProvider->getThemeById($themeId);
|
||||
|
||||
return $theme->getCode();
|
||||
}
|
||||
}
|
||||
Executable
+432
@@ -0,0 +1,432 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
use Magento\Cms\Model\Template\FilterProvider;
|
||||
use Magento\Customer\Api\CustomerRepositoryInterface;
|
||||
use Magento\Customer\Model\Url;
|
||||
use Magento\Framework\Encryption\EncryptorInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\Stdlib\DateTime\DateTime;
|
||||
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Category as CategoryOptions;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Tag as TagOptions;
|
||||
use Mageplaza\Blog\Block\Adminhtml\Post\Edit\Tab\Renderer\Topic as TopicOptions;
|
||||
use Mageplaza\Blog\Helper\Data as HelperData;
|
||||
use Mageplaza\Blog\Helper\Image;
|
||||
use Mageplaza\Blog\Model\CategoryFactory;
|
||||
use Mageplaza\Blog\Model\CommentFactory;
|
||||
use Mageplaza\Blog\Model\Config\Source\AuthorStatus;
|
||||
use Mageplaza\Blog\Model\LikeFactory;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
use Mageplaza\Blog\Model\PostFactory;
|
||||
use Mageplaza\Blog\Model\PostLikeFactory;
|
||||
|
||||
/**
|
||||
* Class Frontend
|
||||
* @package Mageplaza\Blog\Block
|
||||
*/
|
||||
class Frontend extends Template
|
||||
{
|
||||
/**
|
||||
* @var FilterProvider
|
||||
*/
|
||||
public $filterProvider;
|
||||
|
||||
/**
|
||||
* @var HelperData
|
||||
*/
|
||||
public $helperData;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
public $store;
|
||||
|
||||
/**
|
||||
* @var CommentFactory
|
||||
*/
|
||||
public $cmtFactory;
|
||||
|
||||
/**
|
||||
* @var LikeFactory
|
||||
*/
|
||||
public $likeFactory;
|
||||
|
||||
/**
|
||||
* @var CustomerRepositoryInterface
|
||||
*/
|
||||
public $customerRepository;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
public $commentTree;
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
protected $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
*/
|
||||
public $dateTime;
|
||||
|
||||
/**
|
||||
* @var PostFactory
|
||||
*/
|
||||
protected $postFactory;
|
||||
|
||||
/**
|
||||
* @var CategoryFactory
|
||||
*/
|
||||
protected $categoryFactory;
|
||||
|
||||
/**
|
||||
* @var Url
|
||||
*/
|
||||
protected $customerUrl;
|
||||
|
||||
/**
|
||||
* @var CategoryOptions
|
||||
*/
|
||||
protected $categoryOptions;
|
||||
|
||||
/**
|
||||
* @var TopicOptions
|
||||
*/
|
||||
protected $topicOptions;
|
||||
|
||||
/**
|
||||
* @var TagOptions
|
||||
*/
|
||||
protected $tagOptions;
|
||||
|
||||
/**
|
||||
* @var PostLikeFactory
|
||||
*/
|
||||
protected $postLikeFactory;
|
||||
|
||||
/**
|
||||
* @var AuthorStatus
|
||||
*/
|
||||
protected $authorStatusType;
|
||||
|
||||
/**
|
||||
* @var ThemeProviderInterface
|
||||
*/
|
||||
protected $themeProvider;
|
||||
|
||||
/**
|
||||
* @var EncryptorInterface
|
||||
*/
|
||||
public $enc;
|
||||
|
||||
/**
|
||||
* Frontend constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param FilterProvider $filterProvider
|
||||
* @param CommentFactory $commentFactory
|
||||
* @param LikeFactory $likeFactory
|
||||
* @param CustomerRepositoryInterface $customerRepository
|
||||
* @param Registry $coreRegistry
|
||||
* @param HelperData $helperData
|
||||
* @param Url $customerUrl
|
||||
* @param CategoryFactory $categoryFactory
|
||||
* @param PostFactory $postFactory
|
||||
* @param DateTime $dateTime
|
||||
* @param PostLikeFactory $postLikeFactory
|
||||
* @param CategoryOptions $category
|
||||
* @param TopicOptions $topic
|
||||
* @param TagOptions $tag
|
||||
* @param ThemeProviderInterface $themeProvider
|
||||
* @param EncryptorInterface $enc
|
||||
* @param AuthorStatus $authorStatus
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
FilterProvider $filterProvider,
|
||||
CommentFactory $commentFactory,
|
||||
LikeFactory $likeFactory,
|
||||
CustomerRepositoryInterface $customerRepository,
|
||||
Registry $coreRegistry,
|
||||
HelperData $helperData,
|
||||
Url $customerUrl,
|
||||
CategoryFactory $categoryFactory,
|
||||
PostFactory $postFactory,
|
||||
DateTime $dateTime,
|
||||
PostLikeFactory $postLikeFactory,
|
||||
CategoryOptions $category,
|
||||
TopicOptions $topic,
|
||||
TagOptions $tag,
|
||||
ThemeProviderInterface $themeProvider,
|
||||
EncryptorInterface $enc,
|
||||
AuthorStatus $authorStatus,
|
||||
array $data = []
|
||||
) {
|
||||
$this->filterProvider = $filterProvider;
|
||||
$this->cmtFactory = $commentFactory;
|
||||
$this->likeFactory = $likeFactory;
|
||||
$this->customerRepository = $customerRepository;
|
||||
$this->helperData = $helperData;
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
$this->dateTime = $dateTime;
|
||||
$this->categoryFactory = $categoryFactory;
|
||||
$this->postFactory = $postFactory;
|
||||
$this->customerUrl = $customerUrl;
|
||||
$this->postLikeFactory = $postLikeFactory;
|
||||
$this->categoryOptions = $category;
|
||||
$this->topicOptions = $topic;
|
||||
$this->tagOptions = $tag;
|
||||
$this->authorStatusType = $authorStatus;
|
||||
$this->themeProvider = $themeProvider;
|
||||
$this->store = $context->getStoreManager();
|
||||
$this->enc = $enc;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HelperData
|
||||
*/
|
||||
public function getBlogHelper()
|
||||
{
|
||||
return $this->helperData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBlogEnabled()
|
||||
{
|
||||
return $this->helperData->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPageFilter($content)
|
||||
{
|
||||
try {
|
||||
return $this->filterProvider->getPageFilter()->filter((string) $content);
|
||||
} catch (Exception $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $image
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getImageUrl($image, $type = Image::TEMPLATE_MEDIA_TYPE_POST)
|
||||
{
|
||||
$imageHelper = $this->helperData->getImageHelper();
|
||||
if ($image) {
|
||||
$imageFile = $imageHelper->getMediaPath($image, $type);
|
||||
}
|
||||
|
||||
return $image ? $this->helperData->getImageHelper()->getMediaUrl($imageFile) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Object $urlKey
|
||||
* @param null $type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRssUrl($urlKey, $type = null)
|
||||
{
|
||||
if (is_object($urlKey)) {
|
||||
$urlKey = $urlKey->getUrlKey();
|
||||
}
|
||||
|
||||
$urlKey = ($type ? $type . '/' : '') . $urlKey;
|
||||
$url = $this->helperData->getUrl($this->helperData->getRoute() . '/' . $urlKey);
|
||||
|
||||
return rtrim($url, '/') . '.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Post $post
|
||||
*
|
||||
* @return Phrase|string
|
||||
*/
|
||||
public function getPostInfo($post)
|
||||
{
|
||||
try {
|
||||
$likeCollection = $this->postLikeFactory->create()->getCollection();
|
||||
$couldLike = $likeCollection->addFieldToFilter('post_id', $post->getId())
|
||||
->addFieldToFilter('action', '1')->count();
|
||||
$html = __(
|
||||
'<i class="mp-blog-icon mp-blog-calendar-times"></i> %1',
|
||||
$this->getDateFormat($post->getPublishDate())
|
||||
);
|
||||
|
||||
if ($categoryPost = $this->getPostCategoryHtml($post)) {
|
||||
$html .= __('| Posted in %1', $categoryPost);
|
||||
}
|
||||
|
||||
$author = $this->helperData->getAuthorByPost($post);
|
||||
if ($author && $author->getName() && $this->helperData->showAuthorInfo()) {
|
||||
$aTag = '<a class="mp-info" href="' . $author->getUrl() . '">'
|
||||
. $this->escapeHtml($author->getName()) . '</a>';
|
||||
$html .= __('| <i class="mp-blog-icon mp-blog-user"></i> %1', $aTag);
|
||||
}
|
||||
|
||||
if ($this->getCommentinPost($post)) {
|
||||
$html .= __(
|
||||
'| <i class="mp-blog-icon mp-blog-comments" aria-hidden="true"></i> %1',
|
||||
$this->getCommentinPost($post)
|
||||
);
|
||||
}
|
||||
|
||||
if ($post->getViewTraffic()) {
|
||||
$html .= __(
|
||||
'| <i class="mp-blog-icon mp-blog-traffic" aria-hidden="true"></i> %1',
|
||||
$post->getViewTraffic()
|
||||
);
|
||||
}
|
||||
|
||||
if ($couldLike > 0) {
|
||||
$html .= __('| <i class="mp-blog-icon mp-blog-thumbs-up" aria-hidden="true"></i> %1', $couldLike);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$html = '';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Post $post
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCommentinPost($post)
|
||||
{
|
||||
$cmt = $this->cmtFactory->create()->getCollection()->addFieldToFilter('post_id', $post->getId());
|
||||
|
||||
return $cmt->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list category html of post
|
||||
*
|
||||
* @param Post $post
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPostCategoryHtml($post)
|
||||
{
|
||||
$categoryHtml = [];
|
||||
|
||||
try {
|
||||
if (!$post->getCategoryIds()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$categories = $this->helperData->getCategoryCollection($post->getCategoryIds());
|
||||
$count = 0;
|
||||
foreach ($categories as $_cat) {
|
||||
$count++;
|
||||
$maximum = $this->helperData->getSidebarConfig('categories/maximum');
|
||||
if ($maximum && $count > $maximum) {
|
||||
continue;
|
||||
}
|
||||
$categoryHtml[] = '<a class="mp-info" href="'
|
||||
. $this->helperData->getBlogUrl(
|
||||
$_cat,
|
||||
HelperData::TYPE_CATEGORY
|
||||
)
|
||||
. '">' . $_cat->getName() . '</a>';
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return implode(', ', $categoryHtml);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
* @param bool $monthly
|
||||
*
|
||||
* @return false|string|null
|
||||
*/
|
||||
public function getDateFormat($date, $monthly = false)
|
||||
{
|
||||
try {
|
||||
$date = $this->helperData->getDateFormat($date, $monthly);
|
||||
} catch (Exception $e) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $image
|
||||
* @param null $size
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function resizeImage($image, $size = null, $type = Image::TEMPLATE_MEDIA_TYPE_POST)
|
||||
{
|
||||
if (!$image) {
|
||||
return $this->getDefaultImageUrl();
|
||||
}
|
||||
|
||||
return $this->helperData->getImageHelper()->resizeImage($image, $size, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* get default image url
|
||||
*/
|
||||
public function getDefaultImageUrl()
|
||||
{
|
||||
return $this->getViewFileUrl('Mageplaza_Blog::media/images/mageplaza-logo-default.png');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDefaultAuthorImage()
|
||||
{
|
||||
return $this->getViewFileUrl('Mageplaza_Blog::media/images/no-artist-image.jpg');
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
<?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\Html;
|
||||
|
||||
use Magento\Framework\View\Element\Html\Link;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Footer
|
||||
* @package Mageplaza\Blog\Block\Html
|
||||
*/
|
||||
class Footer extends Link
|
||||
{
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
public $helper;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = 'Mageplaza_Blog::html\footer.phtml';
|
||||
|
||||
/**
|
||||
* Footer constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $helper
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Data $helper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->helper = $helper;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHref()
|
||||
{
|
||||
return $this->helper->getBlogUrl('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Magento\Framework\Phrase|mixed|string
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->helper->getBlogConfig('display/name', $this->helper->getCurrentStoreId()) ? : __('Blog');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Data
|
||||
*/
|
||||
public function getHelperData()
|
||||
{
|
||||
return $this->helper;
|
||||
}
|
||||
}
|
||||
Executable
+257
@@ -0,0 +1,257 @@
|
||||
<?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;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Theme\Block\Html\Pager;
|
||||
use Mageplaza\Blog\Model\Config\Source\DisplayType;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class Listpost extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return Collection
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function getPostCollection()
|
||||
{
|
||||
$collection = $this->getCollection();
|
||||
|
||||
if ($collection && $collection->getSize()) {
|
||||
$pager = $this->getLayout()->createBlock(Pager::class, 'mpblog.post.pager');
|
||||
|
||||
$perPageValues = (string) $this->helperData
|
||||
->getDisplayConfig('pagination', $this->store->getStore()->getId());
|
||||
|
||||
$perPageValues = explode(',', $perPageValues ?? '');
|
||||
$perPageValues = array_combine($perPageValues, $perPageValues);
|
||||
$pager->setAvailableLimit($perPageValues)
|
||||
->setCollection($collection);
|
||||
|
||||
$this->setChild('pager', $pager);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* find /n in text
|
||||
*
|
||||
* @param $description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function maxShortDescription($description)
|
||||
{
|
||||
if (is_string($description)) {
|
||||
$html = '';
|
||||
foreach (explode("\n", trim($description)) as $value) {
|
||||
$html .= '<p>' . $value . '</p>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
return $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
try {
|
||||
return $this->helperData->getPostCollection(null, null, $this->store->getStore()->getId());
|
||||
} catch (Exception $exception) {
|
||||
$this->_logger->error($exception->getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPagerHtml()
|
||||
{
|
||||
return $this->getChildHtml('pager');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isGridView()
|
||||
{
|
||||
return $this->helperData->getPostViewPageConfig('display_style') == DisplayType::GRID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Listpost
|
||||
* @throws LocalizedException
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$breadcrumbs->addCrumb('home', [
|
||||
'label' => __('Home'),
|
||||
'title' => __('Go to Home Page'),
|
||||
'link' => $this->_storeManager->getStore()->getBaseUrl()
|
||||
])
|
||||
->addCrumb($this->helperData->getRoute(), $this->getBreadcrumbsData());
|
||||
}
|
||||
|
||||
$this->applySeoCode();
|
||||
|
||||
return parent::_prepareLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getBreadcrumbsData()
|
||||
{
|
||||
$label = $this->helperData->getBlogName();
|
||||
|
||||
$data = [
|
||||
'label' => $label,
|
||||
'title' => $label
|
||||
];
|
||||
|
||||
if ($this->getRequest()->getFullActionName() !== 'mpblog_post_index') {
|
||||
$data['link'] = $this->helperData->getBlogUrl();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
public function applySeoCode()
|
||||
{
|
||||
$this->pageConfig->getTitle()->set(join($this->getTitleSeparator(), array_reverse($this->getBlogTitle(true))));
|
||||
|
||||
$object = $this->getBlogObject();
|
||||
$storeId = $this->store->getStore()->getId();
|
||||
$description = $object ? $this->getMetaFieldByStoreId($object->getMetaDescription(), $storeId) : null;
|
||||
$this->pageConfig->setDescription($description ?: $this->helperData->getBlogConfig('seo/meta_description', $storeId));
|
||||
|
||||
$keywords = $object ? $this->getMetaFieldByStoreId($object->getMetaKeywords(), $storeId) : null;
|
||||
$this->pageConfig->setKeywords($keywords ?: $this->helperData->getBlogConfig('seo/meta_keywords', $storeId));
|
||||
|
||||
$robots = $object ? $this->getMetaRobotsByStoreId($object->getMetaRobots(), $storeId) : null;
|
||||
$this->pageConfig->setRobots($robots ?: $this->helperData->getBlogConfig('seo/meta_robots', $storeId));
|
||||
|
||||
$url = $object ? $object->getUrl() : $this->helperData->getBlogConfig('seo/url_key', $storeId);
|
||||
|
||||
if ($this->getRequest()->getFullActionName() === 'mpblog_post_view' && $url) {
|
||||
$this->pageConfig->addRemotePageAsset(
|
||||
$url,
|
||||
'canonical',
|
||||
['attributes' => ['rel' => 'canonical']]
|
||||
);
|
||||
}
|
||||
$pageMainTitle = $this->getLayout()->getBlock('page.main.title');
|
||||
if ($pageMainTitle) {
|
||||
$pageMainTitle->setPageTitle($this->getBlogTitle());
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve HTML title value separator (with space)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitleSeparator()
|
||||
{
|
||||
$separator = (string) $this->helperData->getConfigValue('catalog/seo/title_separator');
|
||||
|
||||
return ' ' . $separator . ' ';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $meta
|
||||
*
|
||||
* @return array|Phrase
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$pageTitle = $this->helperData->getDisplayConfig('name') ?: __('Blog');
|
||||
if ($meta) {
|
||||
$title = $this->helperData->getBlogConfig('seo/meta_title') ?: $pageTitle;
|
||||
|
||||
return [$title];
|
||||
}
|
||||
|
||||
return $pageTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $jsonValue
|
||||
* @param int $storeId
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getMetaFieldByStoreId(?string $jsonValue, int $storeId): ?string
|
||||
{
|
||||
if (empty($jsonValue)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$decoded = json_decode($jsonValue, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE || !is_array($decoded)) {
|
||||
$decoded = ['0' => $jsonValue];
|
||||
}
|
||||
|
||||
return $decoded[$storeId] ?? $decoded[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $robots
|
||||
* @param $storeId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMetaRobotsByStoreId($robots, $storeId)
|
||||
{
|
||||
if (empty($robots)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$robots = json_decode($robots, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE || !is_array($robots)) {
|
||||
$robots = ['0' => $robots];
|
||||
}
|
||||
|
||||
return $robots[$storeId] ?? ($robots[0] ?? null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?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\MonthlyArchive;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\MonthlyArchive
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @return Collection|null
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
return $this->helperData->getPostCollection(Data::TYPE_MONTHLY, $this->getMonthKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getMonthKey()
|
||||
{
|
||||
return $this->getRequest()->getParam('month_key');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false|string
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function getMonthLabel()
|
||||
{
|
||||
return $this->helperData->getDateFormat($this->getMonthKey() . '-10', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$breadcrumbs->addCrumb($this->getMonthKey(), [
|
||||
'label' => __('Monthy Archive'),
|
||||
'title' => __('Monthy Archive')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $meta
|
||||
*
|
||||
* @return array|false|string
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
|
||||
if ($meta) {
|
||||
array_push($blogTitle, $this->getMonthLabel());
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return $this->getMonthLabel();
|
||||
}
|
||||
}
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
<?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\MonthlyArchive;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data as DataHelper;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\MonthlyArchive
|
||||
*/
|
||||
class Widget extends Frontend
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_postDate;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function isEnable()
|
||||
{
|
||||
return $this->helperData->getBlogConfig(
|
||||
'sidebar/monthly_archive/enable_monthly',
|
||||
$this->helperData->getCurrentStoreId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getDateArrayCount()
|
||||
{
|
||||
return array_values(array_count_values($this->getDateArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getDateArrayUnique()
|
||||
{
|
||||
return array_values(array_unique($this->getDateArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getDateArray()
|
||||
{
|
||||
$dateArray = [];
|
||||
foreach ($this->getPostDate() as $postDate) {
|
||||
$dateArray[] = date("F Y", $this->dateTime->timestamp($postDate));
|
||||
}
|
||||
|
||||
return $dateArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function getPostDate()
|
||||
{
|
||||
if (!$this->_postDate) {
|
||||
$posts = $this->helperData->getPostList();
|
||||
$postDates = [];
|
||||
if ($posts->getSize()) {
|
||||
foreach ($posts as $post) {
|
||||
$postDates[] = $post->getPublishDate();
|
||||
}
|
||||
}
|
||||
$this->_postDate = $postDates;
|
||||
}
|
||||
|
||||
return $this->_postDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|void
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getDateCount()
|
||||
{
|
||||
$limit = $this->helperData->getBlogConfig(
|
||||
'sidebar/monthly_archive/number_records',
|
||||
$this->helperData->getCurrentStoreId())
|
||||
?: 5;
|
||||
$dateArrayCount = $this->getDateArrayCount();
|
||||
$count = count($dateArrayCount);
|
||||
|
||||
return ($count < $limit) ? $count : $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $month
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMonthlyUrl($month)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($month, DataHelper::TYPE_MONTHLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getDateLabel()
|
||||
{
|
||||
$postDates = $this->getPostDate();
|
||||
$postDatesLabel = [];
|
||||
if (count($postDates)) {
|
||||
foreach ($postDates as $date) {
|
||||
$postDatesLabel[] = $this->helperData->getDateFormat($date, true);
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($postDatesLabel));
|
||||
}
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
|
||||
use Magento\Framework\View\Element\Html\Links;
|
||||
|
||||
/**
|
||||
* Class Navigation
|
||||
* @package Mageplaza\Blog\Block
|
||||
*/
|
||||
class Navigation extends Links
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
$links = parent::getLinks();
|
||||
|
||||
usort($links, [$this, "compare"]);
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $firstLink
|
||||
* @param $secondLink
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function compare($firstLink, $secondLink)
|
||||
{
|
||||
return $firstLink->getData('sortOrder') - $secondLink->getData('sortOrder');
|
||||
}
|
||||
}
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
<?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\Post;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Theme\Block\Html\Pager;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class AuthorPost
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class AuthorPost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @return AbstractCollection|Collection|null
|
||||
*/
|
||||
public function getPostCollection()
|
||||
{
|
||||
try {
|
||||
$collection = $this->helperData->getFactoryByType()->create()->getCollection();
|
||||
$this->helperData->addStoreFilter($collection, $this->store->getStore()->getId());
|
||||
|
||||
$userId = $this->getAuthor()->getId();
|
||||
|
||||
$collection->addFieldToFilter('author_id', $userId);
|
||||
|
||||
if ($collection && $collection->getSize()) {
|
||||
$pager = $this->getLayout()->createBlock(Pager::class, 'mpblog.post.pager');
|
||||
$perPageValues = (string) $this->helperData->getDisplayConfig('pagination');
|
||||
$perPageValues = explode(',', $perPageValues ?? '');
|
||||
$perPageValues = array_combine($perPageValues, $perPageValues);
|
||||
$pager->setAvailableLimit($perPageValues)->setCollection($collection);
|
||||
$this->setChild('pager', $pager);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$collection = null;
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $statusId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getStatusHtmlById($statusId)
|
||||
{
|
||||
$statusText = $this->authorStatusType->toArray()[$statusId]->getText();
|
||||
|
||||
switch ($statusId) {
|
||||
case '2':
|
||||
$html = '<div class="mp-post-status mp-post-disapproved">' . __($statusText) . '</div>';
|
||||
break;
|
||||
case '1':
|
||||
$html = '<div class="mp-post-status mp-post-approved">' . __($statusText) . '</div>';
|
||||
break;
|
||||
case '0':
|
||||
default:
|
||||
$html = '<div class="mp-post-status mp-post-pending">' . __($statusText) . '</div>';
|
||||
break;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractCollection|Collection|null $postCollection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostDatas($postCollection)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
if ($postCollection) {
|
||||
try {
|
||||
/** @var Post $post */
|
||||
foreach ($postCollection->getItems() as $post) {
|
||||
$post->getCategoryIds();
|
||||
$post->getTopicIds();
|
||||
$post->getTagIds();
|
||||
if ($post->getPostContent()) {
|
||||
$post->setData('post_content', $this->getPageFilter($post->getPostContent()));
|
||||
}
|
||||
$post = $this->helperData->formatPublishDate($post);
|
||||
$result[$post->getId()] = $post->getData();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$result = [];
|
||||
}
|
||||
}
|
||||
|
||||
return Data::jsonEncode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthorName()
|
||||
{
|
||||
return $this->getAuthor()->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getAuthorStatus()
|
||||
{
|
||||
$author = $this->getAuthor();
|
||||
|
||||
return $author->getStatus() === '1';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->coreRegistry->registry('mp_author');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $meta
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
return $meta ? [$this->getAuthor()->getName()] : $this->getAuthor()->getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBaseMediaUrl()
|
||||
{
|
||||
return $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?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\Post;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?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\Post;
|
||||
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class ManagePost
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class ManagePost extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoriesTree()
|
||||
{
|
||||
return Data::jsonEncode($this->categoryOptions->getCategoriesTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTopicTree()
|
||||
{
|
||||
return Data::jsonEncode($this->topicOptions->getTopicsCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTagTree()
|
||||
{
|
||||
return Data::jsonEncode($this->tagOptions->getTagsCollection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function checkTheme()
|
||||
{
|
||||
return $this->themeProvider->getThemeById($this->helperData->getCurrentThemeId())
|
||||
->getCode() === 'Smartwave/porto';
|
||||
}
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
<?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\Post;
|
||||
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Registry;
|
||||
use Magento\Framework\View\Element\Template;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Helper\Image;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class RelatedPost
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class RelatedPost extends Template
|
||||
{
|
||||
/**
|
||||
* Core registry
|
||||
*
|
||||
* @var Registry
|
||||
*/
|
||||
protected $_coreRegistry;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
protected $helperData;
|
||||
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $_relatedPosts;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $_limitPost;
|
||||
|
||||
/**
|
||||
* RelatedPost constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $registry
|
||||
* @param Data $helperData
|
||||
* @param array $data
|
||||
*
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $registry,
|
||||
Data $helperData,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_coreRegistry = $registry;
|
||||
$this->helperData = $helperData;
|
||||
|
||||
parent::__construct($context, $data);
|
||||
|
||||
$this->setTabTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current product id
|
||||
*
|
||||
* @return null|int
|
||||
*/
|
||||
public function getProductId()
|
||||
{
|
||||
$product = $this->_coreRegistry->registry('product');
|
||||
|
||||
return $product ? $product->getId() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getRelatedPostList()
|
||||
{
|
||||
if ($this->_relatedPosts == null) {
|
||||
/** @var Collection $collection */
|
||||
$collection = $this->helperData->getPostList();
|
||||
$collection->getSelect()
|
||||
->join(
|
||||
[
|
||||
'related' => $collection->getTable('mageplaza_blog_post_product')
|
||||
],
|
||||
'related.post_id=main_table.post_id AND related.entity_id=' . $this->getProductId()
|
||||
)
|
||||
->limit($this->getLimitPosts());
|
||||
|
||||
$this->_relatedPosts = $collection;
|
||||
}
|
||||
|
||||
return $this->_relatedPosts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int|mixed
|
||||
*/
|
||||
public function getLimitPosts()
|
||||
{
|
||||
if (!$this->_limitPost) {
|
||||
$this->_limitPost = (int) $this->helperData->getBlogConfig('product_post/product_detail/post_limit') ?: 1;
|
||||
}
|
||||
|
||||
return $this->_limitPost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set tab title
|
||||
*
|
||||
* @return void
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function setTabTitle()
|
||||
{
|
||||
$relatedSize = min($this->getRelatedPostList()->getSize(), $this->getLimitPosts());
|
||||
|
||||
$title = $relatedSize
|
||||
? __('Related Posts %1', '(' . $relatedSize . ')')
|
||||
: __('Related Posts');
|
||||
if ($this->helperData->isEnabled()) {
|
||||
$this->setTitle($title);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabledBlog()
|
||||
{
|
||||
return $this->helperData->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getRelatedMode()
|
||||
{
|
||||
return (int) $this->helperData->getPostViewPageConfig('related_mode') === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize Image Function
|
||||
*
|
||||
* @param $image
|
||||
* @param null $size
|
||||
* @param string $type
|
||||
*
|
||||
* @return string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function resizeImage($image, $size = null, $type = Image::TEMPLATE_MEDIA_TYPE_POST)
|
||||
{
|
||||
if (!$image) {
|
||||
return $this->getDefaultImageUrl();
|
||||
}
|
||||
|
||||
return $this->helperData->getImageHelper()->resizeImage($image, $size, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* get default image url
|
||||
*/
|
||||
public function getDefaultImageUrl()
|
||||
{
|
||||
return $this->getViewFileUrl('Mageplaza_Blog::media/images/mageplaza-logo-default.png');
|
||||
}
|
||||
}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
<?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\Post;
|
||||
|
||||
use Exception;
|
||||
use Magento\Catalog\Api\CategoryRepositoryInterface;
|
||||
use Magento\Catalog\Block\Product\Context;
|
||||
use Magento\Catalog\Block\Product\ListProduct;
|
||||
use Magento\Catalog\Helper\Output;
|
||||
use Magento\Catalog\Model\Layer\Resolver;
|
||||
use Magento\Catalog\Model\Product;
|
||||
use Magento\Catalog\Model\ProductRepository;
|
||||
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
|
||||
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
|
||||
use Magento\Framework\Data\Helper\PostHelper;
|
||||
use Magento\Framework\Url\Helper\Data;
|
||||
use Mageplaza\Blog\Helper\Data as HelperData;
|
||||
|
||||
/**
|
||||
* Class RelatedProduct
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
*/
|
||||
class RelatedProduct extends ListProduct
|
||||
{
|
||||
/**
|
||||
* Default related product page title
|
||||
*/
|
||||
const TITLE = 'Related Products';
|
||||
|
||||
/**
|
||||
* Default limit related products
|
||||
*/
|
||||
const LIMIT = '12';
|
||||
|
||||
/**
|
||||
* @var CollectionFactory
|
||||
*/
|
||||
protected $_productCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var HelperData
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @var Output
|
||||
*/
|
||||
protected $outputHelper;
|
||||
|
||||
/**
|
||||
* @var Configurable
|
||||
*/
|
||||
protected $catalogProductTypeConfigurable;
|
||||
|
||||
/**
|
||||
* @var ProductRepository
|
||||
*/
|
||||
protected $productRepository;
|
||||
|
||||
/**
|
||||
* RelatedProduct constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param PostHelper $postDataHelper
|
||||
* @param Resolver $layerResolver
|
||||
* @param CategoryRepositoryInterface $categoryRepository
|
||||
* @param CollectionFactory $productCollectionFactory
|
||||
* @param Configurable $catalogProductTypeConfigurable
|
||||
* @param ProductRepository $productRepository
|
||||
* @param HelperData $helperData
|
||||
* @param Output $output
|
||||
* @param Data $urlHelper
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
PostHelper $postDataHelper,
|
||||
Resolver $layerResolver,
|
||||
CategoryRepositoryInterface $categoryRepository,
|
||||
CollectionFactory $productCollectionFactory,
|
||||
Configurable $catalogProductTypeConfigurable,
|
||||
ProductRepository $productRepository,
|
||||
HelperData $helperData,
|
||||
Output $output,
|
||||
Data $urlHelper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->_productCollectionFactory = $productCollectionFactory;
|
||||
$this->helper = $helperData;
|
||||
$this->outputHelper = $output;
|
||||
$this->catalogProductTypeConfigurable = $catalogProductTypeConfigurable;
|
||||
$this->productRepository = $productRepository;
|
||||
|
||||
parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Output
|
||||
*/
|
||||
public function getHelper()
|
||||
{
|
||||
return $this->outputHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function relatedMode()
|
||||
{
|
||||
return $this->helper->getModuleConfig('product_post/post_detail/related_mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function hasProduct()
|
||||
{
|
||||
$collection = $this->_getProductCollection();
|
||||
|
||||
return $collection->getSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ProductCollection in same brand (filter by Attribute Option_Id)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function _getProductCollection()
|
||||
{
|
||||
if ($this->_productCollection === null) {
|
||||
$postId = $this->getRequest()->getParam('id');
|
||||
$collection = $this->_productCollectionFactory->create()
|
||||
->addAttributeToSelect('*')
|
||||
->addStoreFilter();
|
||||
|
||||
$collection->getSelect()
|
||||
->join(
|
||||
['product_post' => $collection->getTable('mageplaza_blog_post_product')],
|
||||
'e.entity_id = product_post.entity_id'
|
||||
)
|
||||
->where('product_post.post_id = ' . $postId)
|
||||
->order('product_post.position ASC')
|
||||
->limit((int) $this->helper->getBlogConfig('product_post/post_detail/product_limit') ?: self::LIMIT);
|
||||
|
||||
$this->_productCollection = $collection;
|
||||
}
|
||||
|
||||
return $this->_productCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getMode()
|
||||
{
|
||||
return 'grid';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getToolbarHtml()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAdditionalHtml()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _beforeToHtml()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Product $product
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParentProductUrl($product)
|
||||
{
|
||||
$parentByChild = $this->catalogProductTypeConfigurable->getParentIdsByChild($product->getId());
|
||||
if (isset($parentByChild[0])) {
|
||||
try {
|
||||
$parentProduct = $this->productRepository->getById($parentByChild[0]);
|
||||
|
||||
return $parentProduct->getProductUrl();
|
||||
} catch (Exception $e) {
|
||||
return $product->getProductUrl();
|
||||
}
|
||||
}
|
||||
|
||||
return $product->getProductUrl();
|
||||
}
|
||||
}
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
<?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\Post\Rss;
|
||||
|
||||
use Magento\Framework\App\Rss\DataProviderInterface;
|
||||
use Magento\Framework\App\Rss\UrlBuilderInterface;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\UrlInterface;
|
||||
use Magento\Framework\View\Element\AbstractBlock;
|
||||
use Magento\Framework\View\Element\Template\Context;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
|
||||
/**
|
||||
* Class NewProducts
|
||||
* @package Magento\Catalog\Block\Rss\Product
|
||||
*/
|
||||
class Lists extends AbstractBlock implements DataProviderInterface
|
||||
{
|
||||
/**
|
||||
* @var UrlBuilderInterface
|
||||
*/
|
||||
public $rssUrlBuilder;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
public $storeManager;
|
||||
|
||||
/**
|
||||
* @var Data
|
||||
*/
|
||||
public $helper;
|
||||
|
||||
/**
|
||||
* Lists constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Data $helper
|
||||
* @param UrlBuilderInterface $rssUrlBuilder
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
UrlBuilderInterface $rssUrlBuilder,
|
||||
Data $helper,
|
||||
array $data = []
|
||||
) {
|
||||
$this->rssUrlBuilder = $rssUrlBuilder;
|
||||
$this->helper = $helper;
|
||||
$this->storeManager = $context->getStoreManager();
|
||||
|
||||
parent::__construct($context, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
$this->setCacheKey('rss_blog_posts_store_' . $this->getStoreId());
|
||||
|
||||
parent::_construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isAllowed()
|
||||
{
|
||||
return $this->helper->isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRssData()
|
||||
{
|
||||
$storeModel = $this->storeManager->getStore($this->getStoreId());
|
||||
$title = __('List Posts from %1', $storeModel->getFrontendName())->render();
|
||||
$storeUrl = $this->storeManager->getStore($this->getStoreId())->getBaseUrl(UrlInterface::URL_TYPE_WEB);
|
||||
$data = [
|
||||
'title' => $title,
|
||||
'description' => $title,
|
||||
'link' => $storeUrl . 'blog/post/rss.xml',
|
||||
'charset' => 'UTF-8',
|
||||
'language' => $this->helper->getConfigValue('general/locale/code', $storeModel),
|
||||
];
|
||||
|
||||
$posts = $this->helper->getPostList($this->getStoreId())
|
||||
->addFieldToFilter('in_rss', 1)
|
||||
->setOrder('post_id', 'DESC');
|
||||
$posts->getSelect()->limit(10);
|
||||
/** @var Post $item */
|
||||
foreach ($posts->getItems() as $item) {
|
||||
$item->setAllowedInRss(true);
|
||||
$item->setAllowedPriceInRss(true);
|
||||
|
||||
$description = $item->getShortDescription();
|
||||
$data['entries'][] = [
|
||||
'title' => $item->getName(),
|
||||
'link' => $item->getUrl(),
|
||||
'description' => $description ?: 'no content',
|
||||
'lastUpdate' => strtotime($item->getPublishDate())
|
||||
];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getStoreId()
|
||||
{
|
||||
$storeId = $this->getRequest()->getParam('store_id');
|
||||
if ($storeId === null) {
|
||||
$storeId = $this->storeManager->getStore()->getId();
|
||||
}
|
||||
|
||||
return (int)$storeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheLifetime()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFeeds()
|
||||
{
|
||||
$data = [];
|
||||
if ($this->isAllowed()) {
|
||||
$url = $this->rssUrlBuilder->getUrl(['type' => 'blog_posts']);
|
||||
$data = ['label' => __('Posts'), 'link' => $url];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isAuthRequired()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Executable
+449
@@ -0,0 +1,449 @@
|
||||
<?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\Post;
|
||||
|
||||
use Magento\Customer\Api\Data\CustomerInterface;
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\View\Element\Messages;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\Post;
|
||||
use Mageplaza\Blog\Model\PostLike;
|
||||
|
||||
/**
|
||||
* Class View
|
||||
* @package Mageplaza\Blog\Block\Post
|
||||
* @method Post getPost()
|
||||
* @method void setPost($post)
|
||||
*/
|
||||
class View extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* config logo blog path
|
||||
*/
|
||||
const LOGO = 'mageplaza/blog/logo/';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _construct()
|
||||
{
|
||||
parent::_construct();
|
||||
|
||||
$post = $this->postFactory->create();
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
$historyId = $this->getRequest()->getParam('historyId');
|
||||
|
||||
if ($historyId) {
|
||||
$history = $this->helperData->getFactoryByType(Data::TYPE_HISTORY)->create()->load($historyId);
|
||||
$post = $this->helperData->getFactoryByType(Data::TYPE_POST)->create()->load($history->getPostId());
|
||||
$data = $history->getData();
|
||||
$post->addData($data);
|
||||
} elseif ($id) {
|
||||
$post->load($id);
|
||||
}
|
||||
$this->setPost($post);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getRelatedMode()
|
||||
{
|
||||
return (int) $this->helperData->getPostViewPageConfig('related_mode') === 1 ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDecrypt($value)
|
||||
{
|
||||
return $this->enc->decrypt($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getBlogObject()
|
||||
{
|
||||
return $this->getPost();
|
||||
}
|
||||
|
||||
/**
|
||||
* check customer is logged in or not
|
||||
*/
|
||||
public function isLoggedIn()
|
||||
{
|
||||
return $this->helperData->isLogin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function checkRss()
|
||||
{
|
||||
return $this->helperData->getBlogUrl('post/rss');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $topic
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopicUrl($topic)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($topic, Data::TYPE_TOPIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTagUrl($tag)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($tag, Data::TYPE_TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategoryUrl($category)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($category, Data::TYPE_CATEGORY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store-specific SEO title with the post name as fallback.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostMetaTitle()
|
||||
{
|
||||
return (string) ($this->helperData->getMetaTitleByStoreId($this->getPost()->getMetaTitle())
|
||||
?: $this->getPost()->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the store-specific SEO description with the short description as fallback.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPostMetaDescription()
|
||||
{
|
||||
$storeId = (int) $this->store->getStore()->getId();
|
||||
|
||||
return (string) ($this->getMetaFieldByStoreId($this->getPost()->getMetaDescription(), $storeId)
|
||||
?: $this->getPost()->getShortDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function helperComment($code)
|
||||
{
|
||||
return $this->helperData->getBlogConfig('comment/' . $code);
|
||||
}
|
||||
|
||||
/**
|
||||
* get comments tree html
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCommentsHtml()
|
||||
{
|
||||
return $this->commentTree;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
*
|
||||
* @return CustomerInterface
|
||||
* @throws LocalizedException
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getUserComment($userId)
|
||||
{
|
||||
return $this->customerRepository->getById($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cmtId
|
||||
*
|
||||
* @return int|string
|
||||
*/
|
||||
public function getCommentLikes($cmtId)
|
||||
{
|
||||
$likes = $this->likeFactory->create()
|
||||
->getCollection()
|
||||
->addFieldToFilter('comment_id', $cmtId)
|
||||
->getSize();
|
||||
|
||||
return $likes ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $cmtId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLiked($cmtId)
|
||||
{
|
||||
if ($this->helperData->isLogin()) {
|
||||
$customerId = $this->helperData->getCustomerIdByContext();
|
||||
$likes = $this->likeFactory->create()->getCollection();
|
||||
foreach ($likes as $like) {
|
||||
if ($like->getEntityId() == $customerId && $like->getCommentId() == $cmtId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $postId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getPostComments($postId)
|
||||
{
|
||||
$result = [];
|
||||
$comments = $this->cmtFactory->create()->getCollection()
|
||||
->addFieldToFilter('main_table.post_id', $postId);
|
||||
foreach ($comments as $comment) {
|
||||
$result[] = $comment->getData();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $postId
|
||||
* @param $action
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPostLike($postId, $action)
|
||||
{
|
||||
/** @var PostLike $postLike */
|
||||
$postLike = $this->postLikeFactory->create();
|
||||
|
||||
return $postLike->getCollection()->addFieldToFilter('post_id', $postId)
|
||||
->addFieldToFilter('action', $action)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function commentHtml($comment)
|
||||
{
|
||||
$html = '';
|
||||
foreach (explode("\n", trim($comment)) as $value) {
|
||||
$html .= '<p>' . $this->escapeHtml($value) . '</p>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $comments
|
||||
* @param $cmtId
|
||||
*
|
||||
* @throws LocalizedException
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getCommentsTree($comments, $cmtId)
|
||||
{
|
||||
$this->commentTree .= '<ul class="default-cmt__content__cmt-content row">';
|
||||
foreach ($comments as $comment) {
|
||||
if ($comment['reply_id'] == $cmtId && $comment['status'] == 1) {
|
||||
$isReply = (bool) $comment['is_reply'];
|
||||
$replyId = $isReply ? $comment['reply_id'] : '';
|
||||
if ($comment['entity_id'] == 0) {
|
||||
$userName = $comment['user_name'];
|
||||
} else {
|
||||
$userCmt = $this->getUserComment($comment['entity_id']);
|
||||
$userName = $userCmt->getFirstName() . ' '
|
||||
. $userCmt->getLastName();
|
||||
}
|
||||
$countLikes = $this->getCommentLikes($comment['comment_id']);
|
||||
$isLiked = ($this->isLiked($comment['comment_id'])) ? "mpblog-liked" : "mpblog-like";
|
||||
$this->commentTree .= '<li id="cmt-id-' . $comment['comment_id']
|
||||
. '" class="default-cmt__content__cmt-content__cmt-row cmt-row-'
|
||||
. $comment['comment_id'] . ' cmt-row col-md-12'
|
||||
. ($isReply ? ' reply-row' : '') . '" data-cmt-id="'
|
||||
. $comment['comment_id'] . '" ' . ($replyId
|
||||
? 'data-reply-id="' . $replyId . '"' : '') . '>
|
||||
<div class="cmt-row__cmt-username">
|
||||
<span class="cmt-row__cmt-username username username__'
|
||||
. $comment['comment_id'] . '">'
|
||||
. $userName . '</span>
|
||||
</div>
|
||||
<div class="cmt-row__cmt-content">
|
||||
' . $this->commentHtml($comment['content']) . '
|
||||
</div>
|
||||
<div class="cmt-row__cmt-interactions interactions">
|
||||
<div class="interactions__btn-actions">
|
||||
<a class="interactions__btn-actions action btn-like '
|
||||
. $isLiked . '" data-cmt-id="'
|
||||
. $comment['comment_id'] . '" click="1">
|
||||
<i class="fa fa-thumbs-up" aria-hidden="true"></i>
|
||||
<span class="count-like__like-text">'
|
||||
. $countLikes . '</span></a>
|
||||
<a class="interactions__btn-actions action btn-reply" data-cmt-id="'
|
||||
. $comment['comment_id'] . '">' . __('Reply') . '</a>
|
||||
</div>
|
||||
<div class="interactions__cmt-createdat">
|
||||
<span>' . $this->getDateFormat($comment['created_at']) . '</span>
|
||||
</div>
|
||||
</div>';
|
||||
if ($comment['has_reply']) {
|
||||
$this->commentTree .= $this->getCommentsTree(
|
||||
$comments,
|
||||
$comment['comment_id']
|
||||
);
|
||||
}
|
||||
$this->commentTree .= '</li>';
|
||||
}
|
||||
}
|
||||
$this->commentTree .= '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* get tag list
|
||||
*
|
||||
* @param Post $post
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTagList($post)
|
||||
{
|
||||
$tagCollection = $post->getSelectedTagsCollection();
|
||||
$result = '';
|
||||
if (!empty($tagCollection)) {
|
||||
$listTags = [];
|
||||
foreach ($tagCollection as $tag) {
|
||||
$listTags[] = '<a class="mp-info" href="' . $this->getTagUrl($tag) . '">' . $tag->getName() . '</a>';
|
||||
}
|
||||
$result = implode(', ', $listTags);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLoginUrl()
|
||||
{
|
||||
return $this->customerUrl->getLoginUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRegisterUrl()
|
||||
{
|
||||
return $this->customerUrl->getRegisterUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
if ($catId = $this->getRequest()->getParam('cat')) {
|
||||
$category = $this->categoryFactory->create()
|
||||
->load($catId);
|
||||
if ($category->getId()) {
|
||||
$breadcrumbs->addCrumb($category->getUrlKey(), [
|
||||
'label' => $category->getName(),
|
||||
'title' => $category->getName(),
|
||||
'link' => $this->helperData->getBlogUrl($category, Data::TYPE_CATEGORY)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$post = $this->getPost();
|
||||
$breadcrumbs->addCrumb($post->getUrlKey(), [
|
||||
'label' => $post->getName(),
|
||||
'title' => $post->getName()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
*
|
||||
* @return array|Phrase|string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
$post = $this->getBlogObject();
|
||||
if (!$post) {
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
if ($this->helperData->getMetaTitleByStoreId($post->getMetaTitle())) {
|
||||
$blogTitle[] = $this->helperData->getMetaTitleByStoreId($post->getMetaTitle());
|
||||
} else {
|
||||
$blogTitle[] = ucfirst($post->getName());
|
||||
}
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return ucfirst($post->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $priority
|
||||
* @param $message
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMessagesHtml($priority, $message)
|
||||
{
|
||||
/** @var $messagesBlock Messages */
|
||||
$messagesBlock = $this->_layout->createBlock(Messages::class);
|
||||
$messagesBlock->{$priority}(__($message));
|
||||
|
||||
return $messagesBlock->toHtml();
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<?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\Sidebar;
|
||||
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class MostView
|
||||
* @package Mageplaza\Blog\Block\Sidebar
|
||||
*/
|
||||
class MostView extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMostViewPosts()
|
||||
{
|
||||
$collection = $this->helperData->getPostList();
|
||||
$collection->getSelect()
|
||||
->joinLeft(
|
||||
['traffic' => $collection->getTable('mageplaza_blog_post_traffic')],
|
||||
'main_table.post_id=traffic.post_id',
|
||||
'numbers_view'
|
||||
)
|
||||
->order('numbers_view DESC')
|
||||
->limit((int)$this->helperData->getBlogConfig('sidebar/recent_post/number_mostview_posts') ?: 4);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getRecentPost()
|
||||
{
|
||||
$collection = $this->helperData->getPostList();
|
||||
$collection->getSelect()
|
||||
->limit((int)$this->helperData->
|
||||
getBlogConfig('sidebar/recent_post/number_recent_posts') ?: 4);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
<?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\Sidebar;
|
||||
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
|
||||
/**
|
||||
* Class Search
|
||||
* @package Mageplaza\Blog\Block\Sidebar
|
||||
*/
|
||||
class Search extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getSearchBlogData()
|
||||
{
|
||||
$result = [];
|
||||
$posts = $this->helperData->getPostList();
|
||||
$limitDesc = (int)$this->getSidebarConfig('search/description');
|
||||
if (!empty($posts)) {
|
||||
foreach ($posts as $item) {
|
||||
$shortDescription = ($item->getShortDescription() && $limitDesc > 0) ?
|
||||
$item->getShortDescription() : '';
|
||||
if (strlen($shortDescription) > $limitDesc) {
|
||||
$shortDescription = mb_substr($shortDescription, 0, $limitDesc, 'UTF-8') . '...';
|
||||
}
|
||||
|
||||
$result[] = [
|
||||
'value' => $item->getName(),
|
||||
'url' => $item->getUrl(),
|
||||
'image' => $this->resizeImage($item->getImage(), '100x'),
|
||||
'desc' => $shortDescription
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return Data::jsonEncode($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* get sidebar config
|
||||
*
|
||||
* @param $code
|
||||
* @param $storeId
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSidebarConfig($code, $storeId = null)
|
||||
{
|
||||
return $this->helperData->getBlogConfig('sidebar/' . $code, $storeId);
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?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\Tag;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\TagFactory;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Tag
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @var TagFactory
|
||||
*/
|
||||
protected $_tag;
|
||||
|
||||
/**
|
||||
* Override this function to apply collection for each type
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
if ($tag = $this->getBlogObject()) {
|
||||
return $this->helperData->getPostCollection(Data::TYPE_TAG, $tag->getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getBlogObject()
|
||||
{
|
||||
if (!$this->_tag) {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
|
||||
if ($id) {
|
||||
$tag = $this->helperData->getObjectByParam($id, null, Data::TYPE_TAG);
|
||||
if ($tag && $tag->getId()) {
|
||||
$this->_tag = $tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$tag = $this->getBlogObject();
|
||||
$tagName = preg_replace('/[^A-Za-z0-9\-]/', ' ', $tag->getName());
|
||||
if ($tag) {
|
||||
$breadcrumbs->addCrumb($tag->getUrlKey(), [
|
||||
'label' => __($tagName),
|
||||
'title' => __($tagName)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
*
|
||||
* @return array|Phrase|string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
$tag = $this->getBlogObject();
|
||||
if (!$tag) {
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
if ($this->helperData->getMetaTitleByStoreId($tag->getMetaTitle())) {
|
||||
$blogTitle[] = $this->helperData->getMetaTitleByStoreId($tag->getMetaTitle());
|
||||
} else {
|
||||
$blogTitle[] = ucfirst($tag->getName());
|
||||
}
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return ucfirst($tag->getName());
|
||||
}
|
||||
}
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
<?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\Tag;
|
||||
|
||||
use Exception;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Author\Collection as AuthorCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Collection as CategoryCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\Collection as TagCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\Collection as TopicCollection;
|
||||
use Mageplaza\Blog\Model\Tag;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\Tag
|
||||
*/
|
||||
class Widget extends Frontend
|
||||
{
|
||||
/**
|
||||
* @var TagCollection
|
||||
*/
|
||||
protected $_tagList;
|
||||
|
||||
/**
|
||||
* @return AuthorCollection|CategoryCollection|Collection|TagCollection|TopicCollection|null
|
||||
*/
|
||||
public function getTagList()
|
||||
{
|
||||
try {
|
||||
if (!$this->_tagList) {
|
||||
$this->_tagList = $this->helperData->getObjectList(Data::TYPE_TAG);
|
||||
}
|
||||
|
||||
return $this->_tagList;
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tag $tag
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTagUrl($tag)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($tag, Data::TYPE_TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get tags size based on num of post
|
||||
*
|
||||
* @param $tag
|
||||
*
|
||||
* @return false|float|int
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getTagSize($tag)
|
||||
{
|
||||
/** @var Collection $postList */
|
||||
$postList = $this->helperData->getPostList();
|
||||
if ($postList && ($max = $postList->getSize()) > 1) {
|
||||
$maxSize = 22;
|
||||
$tagPost = $this->helperData->getPostCollection(Data::TYPE_TAG, $tag->getId());
|
||||
if ($tagPost && ($countTagPost = $tagPost->getSize()) > 1) {
|
||||
$size = $maxSize * $countTagPost / $max;
|
||||
|
||||
return round($size) + 8;
|
||||
}
|
||||
}
|
||||
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?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\Topic;
|
||||
|
||||
use Magento\Framework\Exception\LocalizedException;
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Framework\Phrase;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\TopicFactory;
|
||||
|
||||
/**
|
||||
* Class Listpost
|
||||
* @package Mageplaza\Blog\Block\Topic
|
||||
*/
|
||||
class Listpost extends \Mageplaza\Blog\Block\Listpost
|
||||
{
|
||||
/**
|
||||
* @var TopicFactory
|
||||
*/
|
||||
protected $_topic;
|
||||
|
||||
/**
|
||||
* Override this function to apply collection for each type
|
||||
*
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
protected function getCollection()
|
||||
{
|
||||
if ($topic = $this->getBlogObject()) {
|
||||
return $this->helperData->getPostCollection(Data::TYPE_TOPIC, $topic->getId());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getBlogObject()
|
||||
{
|
||||
if (!$this->_topic) {
|
||||
$id = $this->getRequest()->getParam('id');
|
||||
|
||||
if ($id) {
|
||||
$topic = $this->helperData->getObjectByParam($id, null, Data::TYPE_TOPIC);
|
||||
if ($topic && $topic->getId()) {
|
||||
$this->_topic = $topic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_topic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws LocalizedException
|
||||
*/
|
||||
protected function _prepareLayout()
|
||||
{
|
||||
parent::_prepareLayout();
|
||||
|
||||
if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
|
||||
$topic = $this->getBlogObject();
|
||||
$topicName = preg_replace('/[^A-Za-z0-9\-]/', ' ', $topic->getName());
|
||||
if ($topic) {
|
||||
$breadcrumbs->addCrumb($topic->getUrlKey(), [
|
||||
'label' => __($topicName),
|
||||
'title' => __($topicName)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $meta
|
||||
*
|
||||
* @return array|Phrase|string
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getBlogTitle($meta = false)
|
||||
{
|
||||
$blogTitle = parent::getBlogTitle($meta);
|
||||
$topic = $this->getBlogObject();
|
||||
if (!$topic) {
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
if ($meta) {
|
||||
if ($this->helperData->getMetaTitleByStoreId($topic->getMetaTitle())) {
|
||||
$blogTitle[] = $this->helperData->getMetaTitleByStoreId($topic->getMetaTitle());
|
||||
} else {
|
||||
$blogTitle[] = ucfirst($topic->getName());
|
||||
}
|
||||
|
||||
return $blogTitle;
|
||||
}
|
||||
|
||||
return ucfirst($topic->getName());
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?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\Topic;
|
||||
|
||||
use Exception;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Author\Collection as AuthorCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Category\Collection as CategoryCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Tag\Collection as TagCollection;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Topic\Collection as TopicCollection;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\Topic;
|
||||
|
||||
/**
|
||||
* Class Widget
|
||||
* @package Mageplaza\Blog\Block\Topic
|
||||
*/
|
||||
class Widget extends Frontend
|
||||
{
|
||||
/**
|
||||
* @return AuthorCollection|CategoryCollection|Collection|TagCollection|TopicCollection|null
|
||||
*/
|
||||
public function getTopicList()
|
||||
{
|
||||
try {
|
||||
return $this->helperData->getObjectList(Data::TYPE_TOPIC);
|
||||
} catch (Exception $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Topic $topic
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTopicUrl($topic)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($topic, Data::TYPE_TOPIC);
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
<?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\Widget;
|
||||
|
||||
use Magento\Framework\Exception\NoSuchEntityException;
|
||||
use Magento\Widget\Block\BlockInterface;
|
||||
use Mageplaza\Blog\Block\Frontend;
|
||||
use Mageplaza\Blog\Helper\Data;
|
||||
use Mageplaza\Blog\Model\ResourceModel\Post\Collection;
|
||||
|
||||
/**
|
||||
* Class Posts
|
||||
* @package Mageplaza\Blog\Block\Widget
|
||||
*/
|
||||
class Posts extends Frontend implements BlockInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_template = "widget/posts.phtml";
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
* @throws NoSuchEntityException
|
||||
*/
|
||||
public function getCollection()
|
||||
{
|
||||
if ($this->hasData('show_type') && $this->getData('show_type') === 'category') {
|
||||
$collection = $this->helperData->getObjectByParam($this->getData('category_id'), null, Data::TYPE_CATEGORY)
|
||||
->getSelectedPostsCollection();
|
||||
$this->helperData->addStoreFilter($collection);
|
||||
} else {
|
||||
$collection = $this->helperData->getPostList();
|
||||
}
|
||||
|
||||
$collection->setPageSize($this->getData('post_count'));
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Data
|
||||
*/
|
||||
public function getHelperData()
|
||||
{
|
||||
return $this->helperData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->getData('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlogUrl($code)
|
||||
{
|
||||
return $this->helperData->getBlogUrl($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render block HTML
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function _toHtml()
|
||||
{
|
||||
if ($this->helperData->checkHyvaTheme()) {
|
||||
$this->setTemplate('Mageplaza_Blog::hyva/widget/posts.phtml');
|
||||
}
|
||||
return parent::_toHtml();
|
||||
}
|
||||
}
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
Changelog: https://www.mageplaza.com/releases/blog
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?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\Controller\Adminhtml;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Registry;
|
||||
use Mageplaza\Blog\Model\AuthorFactory;
|
||||
|
||||
/**
|
||||
* Class Author
|
||||
* @package Mageplaza\Blog\Controller\Adminhtml
|
||||
*/
|
||||
abstract class Author extends Action
|
||||
{
|
||||
/** Authorization level of a basic admin session */
|
||||
const ADMIN_RESOURCE = 'Mageplaza_Blog::author';
|
||||
|
||||
/**
|
||||
* @var Registry
|
||||
*/
|
||||
public $coreRegistry;
|
||||
|
||||
/**
|
||||
* @var AuthorFactory
|
||||
*/
|
||||
public $authorFactory;
|
||||
|
||||
/**
|
||||
* Author constructor.
|
||||
*
|
||||
* @param Context $context
|
||||
* @param Registry $coreRegistry
|
||||
* @param AuthorFactory $authorFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
Registry $coreRegistry,
|
||||
AuthorFactory $authorFactory
|
||||
) {
|
||||
$this->authorFactory = $authorFactory;
|
||||
$this->coreRegistry = $coreRegistry;
|
||||
|
||||
parent::__construct($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $register
|
||||
*
|
||||
* @return bool|\Mageplaza\Blog\Model\Author
|
||||
*/
|
||||
public function initAuthor($register = false)
|
||||
{
|
||||
$authorId = (int)$this->getRequest()->getParam('id');
|
||||
|
||||
/** @var \Mageplaza\Blog\Model\Author $author */
|
||||
$author = $this->authorFactory->create();
|
||||
if ($authorId) {
|
||||
$author->load($authorId);
|
||||
if (!$author->getId()) {
|
||||
$this->messageManager->addErrorMessage(__('This author no longer exists.'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($register) {
|
||||
$this->coreRegistry->register('mageplaza_blog_author', $author);
|
||||
}
|
||||
|
||||
return $author;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?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\Controller\Adminhtml\Author;
|
||||
|
||||
use Magento\Backend\App\Action;
|
||||
use Magento\Backend\App\Action\Context;
|
||||
use Magento\Framework\Controller\Result\Raw;
|
||||
use Magento\Framework\Controller\Result\RawFactory;
|
||||
use Magento\Framework\View\LayoutFactory;
|
||||
|
||||
/**
|
||||
* Class CustomerGrid
|
||||
* @package Mageplaza\Blog\Controller\Adminhtml\Author
|
||||
*/
|
||||
class CustomerGrid extends Action
|
||||
{
|
||||
/**
|
||||
* @var RawFactory
|
||||
*/
|
||||
protected $resultRawFactory;
|
||||
|
||||
/**
|
||||
* @var LayoutFactory
|
||||
*/
|
||||
protected $layoutFactory;
|
||||
|
||||
/**
|
||||
* @param Context $context
|
||||
* @param RawFactory $resultRawFactory
|
||||
* @param LayoutFactory $layoutFactory
|
||||
*/
|
||||
public function __construct(
|
||||
Context $context,
|
||||
RawFactory $resultRawFactory,
|
||||
LayoutFactory $layoutFactory
|
||||
) {
|
||||
parent::__construct($context);
|
||||
|
||||
$this->resultRawFactory = $resultRawFactory;
|
||||
$this->layoutFactory = $layoutFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grid Action
|
||||
*
|
||||
* @return Raw
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
/** @var Raw $resultRaw */
|
||||
$resultRaw = $this->resultRawFactory->create();
|
||||
|
||||
return $resultRaw->setContents(
|
||||
$this->layoutFactory->create()->createBlock(
|
||||
\Mageplaza\Blog\Block\Adminhtml\Author\CustomerGrid::class,
|
||||
'blog.customer.grid'
|
||||
)->toHtml()
|
||||
);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user