Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: magefan/module-blog
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2.10.2.3
Choose a base ref
...
head repository: magefan/module-blog
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 10,794 additions and 4,052 deletions.
  1. +6 −1 Api/AuthorInterface.php
  2. +16 −0 Api/CommentManagementInterface.php
  3. +12 −11 Api/ManagementInterface.php
  4. +22 −0 Api/ShortContentExtractorInterface.php
  5. +13 −6 Api/SitemapConfigInterface.php
  6. +16 −0 Api/TagManagementInterface.php
  7. +21 −0 Api/VersionInterface.php
  8. +51 −0 Block/Adminhtml/AiButton.php
  9. +41 −0 Block/Adminhtml/Comment/ReplyButton.php
  10. +39 −0 Block/Adminhtml/Grid/Column/Render/Image.php
  11. +1 −1 Block/Adminhtml/Post/Helper/Form/Gallery.php
  12. +23 −2 Block/Adminhtml/System/Config/Form/ColorPicker.php
  13. +153 −0 Block/Adminhtml/System/Config/Form/Featured.php
  14. +56 −0 Block/Adminhtml/System/Config/Form/Featured/Form.php
  15. +301 −0 Block/Adminhtml/System/Config/Form/Featured/Grid.php
  16. +59 −0 Block/Adminhtml/System/Config/Form/Featured/Renderer/GridElement.php
  17. +1 −1 Block/Adminhtml/System/Config/Form/Info.php
  18. +52 −0 Block/Adminhtml/System/Config/Form/InfoBlogExtra.php
  19. +45 −0 Block/Adminhtml/System/Config/Form/InfoBlogPlus.php
  20. +103 −0 Block/Adminhtml/System/Config/Form/InfoPlan.php
  21. +55 −0 Block/Adminhtml/System/Config/Form/PermalinkSettingsMessage.php
  22. +24 −0 Block/Adminhtml/System/Config/Form/SitemapInfo.php
  23. +17 −20 Block/Adminhtml/System/Config/Form/UpdateInfo.php
  24. +353 −0 Block/Adminhtml/Widget/Featured/Grid.php
  25. +250 −0 Block/Adminhtml/Widget/Featured/Grid/Chooser.php
  26. +61 −0 Block/Archive/Archive.php
  27. +59 −0 Block/Archive/Description.php
  28. +32 −33 Block/Archive/PostList.php
  29. +30 −6 Block/Author/PostList.php
  30. +23 −6 Block/Category/PostList.php
  31. +24 −7 Block/Category/View.php
  32. +48 −0 Block/CustomCss.php
  33. +10 −1 Block/Index.php
  34. +27 −0 Block/Index/Description.php
  35. +39 −4 Block/Post/AbstractPost.php
  36. +12 −0 Block/Post/Info.php
  37. +37 −14 Block/Post/PostList.php
  38. +23 −2 Block/Post/PostList/AbstractList.php
  39. +52 −6 Block/Post/PostList/Toolbar.php
  40. +65 −2 Block/Post/PostList/Toolbar/Pager.php
  41. +31 −7 Block/Post/View.php
  42. +0 −3 Block/Post/View/Comments/HeadFbApi.php
  43. +3 −3 Block/Post/View/Comments/Magefan/Comment.php
  44. +31 −0 Block/Post/View/CustomCss.php
  45. +2 −3 Block/Post/View/NextPrev.php
  46. +8 −0 Block/Post/View/Opengraph.php
  47. +145 −39 Block/Post/View/Richsnippets.php
  48. +28 −3 Block/Search/PostList.php
  49. +30 −2 Block/Sidebar/Archive.php
  50. +1 −0 Block/Sidebar/Categories.php
  51. +18 −1 Block/Sidebar/Featured.php
  52. +173 −0 Block/Sidebar/PostRelatedProducts.php
  53. +13 −0 Block/Sidebar/Widget.php
  54. +31 −13 Block/Tag/PostList.php
  55. +4 −4 Block/Widget/Featured.php
  56. +5 −8 Block/Widget/Link.php
  57. +26 −27 Block/Widget/PostList.php
  58. +45 −8 Block/Widget/Recent.php
  59. +47 −1 Controller/Adminhtml/Actions.php
  60. +46 −0 Controller/Adminhtml/Block/Featured/Grid.php
  61. +70 −0 Controller/Adminhtml/Block/Featured/Grid/Chooser.php
  62. +7 −1 Controller/Adminhtml/Category/Save.php
  63. +109 −0 Controller/Adminhtml/Comment/AddReply.php
  64. +1 −1 Controller/Adminhtml/Comment/Save.php
  65. +79 −0 Controller/Adminhtml/CreateWithAi/Index.php
  66. +13 −7 Controller/Adminhtml/Import/Run.php
  67. +22 −32 Controller/Adminhtml/Post/Save.php
  68. +1 −1 Controller/Adminhtml/Tag/Autocomplete.php
  69. +12 −1 Controller/Adminhtml/Tag/Save.php
  70. +3 −2 Controller/Archive/View.php
  71. +22 −1 Controller/Author/View.php
  72. +15 −2 Controller/Category/View.php
  73. +1 −1 Controller/Comment/Post.php
  74. +6 −1 Controller/Index/Index.php
  75. +14 −2 Controller/Post/View.php
  76. +15 −1 Controller/Router.php
  77. +18 −1 Controller/Tag/View.php
  78. +76 −0 Cron/ReSaveExistingPosts.php
  79. +13 −2 Helper/Data.php
  80. +30 −1 Helper/Image.php
  81. +1 −1 Helper/Page.php
  82. +113 −13 Model/AbstractManagement.php
  83. +0 −180 Model/AdminNotificationFeed.php
  84. +48 −7 Model/Author.php
  85. +20 −6 Model/AuthorRepository.php
  86. +49 −5 Model/Category.php
  87. +1 −1 Model/CategoryManagement.php
  88. +20 −6 Model/CategoryRepository.php
  89. +12 −2 Model/Comment.php
  90. +99 −0 Model/CommentManagement.php
  91. +1 −1 Model/CommentRepository.php
  92. +99 −1 Model/Config.php
  93. +51 −0 Model/Config/Source/ArchiveGroupBy.php
  94. +2 −0 Model/Config/Source/CategoryTree.php
  95. +43 −0 Model/Config/Source/ImageSizeOptions.php
  96. +56 −0 Model/Config/Source/PageLayout.php
  97. +39 −0 Model/Config/Source/PagePaginationType.php
  98. +65 −0 Model/Config/Source/ReadingProgressBarPosition.php
  99. +41 −0 Model/Config/Source/SocialNetworks.php
  100. +58 −8 Model/Import/AbstractImport.php
  101. +3 −3 Model/Import/Aw.php
  102. +14 −10 Model/Import/Aw2.php
  103. +16 −12 Model/Import/Mageplaza.php
  104. +3 −3 Model/Import/Mageplaza1.php
  105. +3 −3 Model/Import/Wordpress.php
  106. +191 −161 Model/Post.php
  107. +8 −6 Model/PostManagement.php
  108. +7 −1 Model/PostRepository.php
  109. +6 −0 Model/ResourceModel/Author/Collection.php
  110. +50 −18 Model/ResourceModel/Category.php
  111. +52 −26 Model/ResourceModel/Category/Collection.php
  112. +11 −1 Model/ResourceModel/Comment/Collection.php
  113. +6 −1 Model/ResourceModel/Comment/Collection/Grid.php
  114. +27 −15 Model/ResourceModel/PageIdentifierGenerator.php
  115. +51 −5 Model/ResourceModel/Post.php
  116. +132 −35 Model/ResourceModel/Post/Collection.php
  117. +86 −14 Model/ResourceModel/Tag.php
  118. +33 −1 Model/ResourceModel/Tag/Collection.php
  119. +224 −0 Model/ShortContentExtractor.php
  120. +0 −149 Model/Sitemap.php
  121. +77 −0 Model/Sitemap/ItemProvider/Category.php
  122. +97 −0 Model/Sitemap/ItemProvider/Index.php
  123. +96 −0 Model/Sitemap/ItemProvider/Post.php
  124. +16 −9 Model/Sitemap/SitemapConfig.php
  125. +7 −1 Model/SlashUrlRedirect.php
  126. +55 −9 Model/Tag.php
  127. +101 −0 Model/TagManagement.php
  128. +6 −1 Model/TagRepository.php
  129. +17 −9 Model/Url.php
  130. +35 −6 Model/UrlResolver.php
  131. +59 −0 Model/Version.php
  132. +99 −0 Observer/LayoutGenerateBlocksAfter.php
  133. +37 −5 Observer/LayoutLoadBeforeObserver.php
  134. +0 −66 Observer/PredispathAdminActionControllerObserver.php
  135. +1 −4 Observer/PredispathFrontendBlogActionControllerObserver.php
  136. +0 −3 Plugin/Magento/AdminGws/Model/ModelsPlugin.php
  137. +78 −0 Plugin/Magento/Framework/App/Config/ScopeConfigInterfacePlugin.php
  138. +48 −0 Plugin/Magento/Framework/View/Element/TemplatePlugin.php
  139. +0 −160 Plugin/Magento/Sitemap/SitemapPlugin.php
  140. +163 −105 README.md
  141. +0 −120 Setup/InstallData.php
  142. +0 −396 Setup/InstallSchema.php
  143. +96 −0 Setup/Patch/Data/CreateSamplePost.php
  144. +91 −0 Setup/Patch/Data/TagInStore.php
  145. +79 −0 Setup/Patch/Data/UpdatePostCommentsCount.php
  146. +0 −64 Setup/UpgradeData.php
  147. +0 −806 Setup/UpgradeSchema.php
  148. +16 −1 Ui/DataProvider/Category/Form/CategoryDataProvider.php
  149. +1 −1 Ui/DataProvider/Comment/Form/CommentDataProvider.php
  150. +18 −1 Ui/DataProvider/Tag/Form/TagDataProvider.php
  151. +28 −17 ViewModel/Style.php
  152. +5 −6 composer.json
  153. +14 −0 etc/adminhtml/di.xml
  154. +0 −22 etc/adminhtml/events.xml
  155. +651 −117 etc/adminhtml/system.xml
  156. +183 −9 etc/config.xml
  157. +18 −0 etc/cron_groups.xml
  158. +14 −0 etc/crontab.xml
  159. +4 −4 etc/csp_whitelist.xml
  160. +343 −0 etc/db_schema.xml
  161. +22 −14 etc/di.xml
  162. +4 −0 etc/frontend/di.xml
  163. +3 −0 etc/frontend/events.xml
  164. +1 −1 etc/module.xml
  165. +133 −0 etc/webapi.xml
  166. +11 −3 etc/widget.xml
  167. +205 −0 i18n/cs_CZ.csv
  168. +5 −0 i18n/de_DE.csv
  169. +10 −3 i18n/el_GR.csv
  170. +5 −0 i18n/en_US.csv
  171. +20 −0 i18n/es_ES.csv
  172. +5 −0 i18n/fi_FI.csv
  173. +32 −12 i18n/fr_FR.csv
  174. +22 −2 i18n/it_IT.csv
  175. +21 −0 i18n/nl_NL.csv
  176. +245 −0 i18n/pl_PL.csv
  177. +97 −78 i18n/pt_BR.csv
  178. +8 −1 i18n/pt_PT.csv
  179. +21 −1 i18n/ro_RO.csv
  180. +0 −194 i18n/ru_RU.csv
  181. +205 −0 i18n/sk_SK.csv
  182. +5 −0 i18n/sv_SE.csv
  183. +1 −70 i18n/tr_TR.csv
  184. +4 −0 i18n/uk_UA.csv
  185. +20 −0 i18n/zh_Hans_CN.csv
  186. +705 −0 postman/rest_collection.json
  187. +15 −0 view/adminhtml/layout/blog_block_featured_grid.xml
  188. +5 −5 view/adminhtml/layout/blog_category_grid_block.xml
  189. +7 −0 view/adminhtml/layout/blog_import_index.xml
  190. +2 −2 view/adminhtml/layout/blog_post_edit.xml
  191. +19 −9 view/adminhtml/layout/blog_post_grid_block.xml
  192. +2 −1 view/adminhtml/layout/blog_post_index.xml
  193. +5 −5 view/adminhtml/layout/blog_tag_grid_block.xml
  194. +10 −9 view/adminhtml/templates/admin_grid_issue.phtml
  195. +4 −6 view/adminhtml/templates/feedback_button.phtml
  196. +7 −3 view/adminhtml/templates/post/helper/gallery.phtml
  197. +37 −18 view/adminhtml/templates/post/tag/autocomplete.phtml
  198. +15 −12 view/adminhtml/templates/updateinfo.phtml
  199. +125 −9 view/adminhtml/ui_component/blog_category_form.xml
  200. +1 −0 view/adminhtml/ui_component/blog_comment_form.xml
  201. +139 −35 view/adminhtml/ui_component/blog_post_form.xml
  202. +32 −22 view/adminhtml/ui_component/blog_tag_form.xml
  203. BIN view/adminhtml/web/images/amasty2_blog.png
  204. +2 −1 view/adminhtml/web/js/post-gallery.js
  205. +1 −0 view/frontend/layout/blog_archive_view.xml
  206. +21 −0 view/frontend/layout/blog_css.xml
  207. +2 −0 view/frontend/layout/blog_default.xml
  208. +1 −0 view/frontend/layout/blog_index_index.xml
  209. +1 −1 view/frontend/layout/blog_post_list.xml
  210. +1 −1 view/frontend/layout/blog_post_opengraph.xml
  211. +4 −0 view/frontend/layout/blog_post_view.xml
  212. +35 −0 view/frontend/layout/breeze_default.xml
  213. +4 −5 view/frontend/layout/default.xml
  214. +30 −8 view/frontend/templates/addthis-js.phtml
  215. +19 −0 view/frontend/templates/index/description.phtml
  216. +55 −0 view/frontend/templates/lazyload-js.phtml
  217. +28 −0 view/frontend/templates/post/info.phtml
  218. +34 −15 view/frontend/templates/post/list-modern.phtml
  219. +0 −7 view/frontend/templates/post/list.phtml
  220. +19 −14 view/frontend/templates/post/list/item.phtml
  221. +8 −5 view/frontend/templates/post/list/toolbar.phtml
  222. +52 −21 view/frontend/templates/post/view-modern.phtml
  223. +20 −8 view/frontend/templates/post/view.phtml
  224. +6 −6 view/frontend/templates/post/view/comments/disqus.phtml
  225. +6 −3 view/frontend/templates/post/view/comments/facebook.phtml
  226. +1 −10 view/frontend/templates/post/view/comments/google.phtml
  227. +7 −7 view/frontend/templates/post/view/gallery.phtml
  228. +4 −2 view/frontend/templates/post/view/gallery_porto_fanybox2.phtml
  229. +1 −1 view/frontend/templates/post/view/relatedposts.phtml
  230. +1 −1 view/frontend/templates/post/view/relatedproducts.phtml
  231. +6 −6 view/frontend/templates/post/view/views_count.phtml
  232. +39 −42 view/frontend/templates/sidebar/categories.phtml
  233. +53 −0 view/frontend/templates/sidebar/post-related-products.phtml
  234. +19 −13 view/frontend/templates/sidebar/search.phtml
  235. +12 −10 view/frontend/templates/sidebar/tag_claud_animated.phtml
  236. +7 −5 view/frontend/templates/themes/smartwave_porto/recent_home_custom.phtml
  237. +6 −4 view/frontend/templates/widget/porto_theme_recent_home.phtml
  238. +7 −1 view/frontend/templates/widget/recent.phtml
  239. +13 −5 view/frontend/templates/widget/recent_masonry.phtml
  240. +43 −7 view/frontend/web/css/blog-m.css
  241. +88 −48 view/frontend/web/css/blog-new.css
  242. +1 −2 view/frontend/web/css/bootstrap-4.4.1-custom-min.css
  243. +1 −1 view/frontend/web/css/comments.css
  244. +1 −56 view/frontend/web/images/calendar-icon.svg
  245. +1 −62 view/frontend/web/images/comments-icon.svg
  246. +1 −43 view/frontend/web/images/folder-icon.svg
  247. +1 −0 view/frontend/web/images/social/facebook.svg
  248. +4 −0 view/frontend/web/images/social/linkedin.svg
  249. +1 −0 view/frontend/web/images/social/pinterest.svg
  250. +1 −0 view/frontend/web/images/social/twitter.svg
  251. +1 −54 view/frontend/web/images/tags-icon.svg
  252. +1 −0 view/frontend/web/images/time-icon.svg
  253. +1 −55 view/frontend/web/images/user-icon.svg
  254. +1 −53 view/frontend/web/images/views-icon.svg
  255. +23 −15 view/frontend/web/js/lazyload.js
  256. +63 −0 view/frontend/web/js/lib/mfblogunveil.js
  257. +21 −0 view/frontend/web/js/tagcanvas.min.js
7 changes: 6 additions & 1 deletion Api/AuthorInterface.php
Original file line number Diff line number Diff line change
@@ -5,10 +5,15 @@
*
* Glory to Ukraine! Glory to the heroes!
*/
declare(strict_types=1);

namespace Magefan\Blog\Api;

interface AuthorInterface
{

/**
* @param int $storeId
* @return bool
*/
public function isVisibleOnStore(int $storeId): bool;
}
16 changes: 16 additions & 0 deletions Api/CommentManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/

declare(strict_types=1);

namespace Magefan\Blog\Api;

interface CommentManagementInterface extends ManagementInterface
{

}
23 changes: 12 additions & 11 deletions Api/ManagementInterface.php
Original file line number Diff line number Diff line change
@@ -14,46 +14,47 @@ interface ManagementInterface
* Create new item.
*
* @api
* @param string $data.
* @return string.
* @param string $data
* @return string
*/
public function create($data);

/**
* Update item by id.
*
* @api
* @param int $id.
* @param string $data.
* @return string.
* @param int $id
* @param string $data
* @return string
*/
public function update($id, $data);

/**
* Remove item by id.
*
* @api
* @param int $id.
* @return bool.
* @param int $id
* @return bool
*/
public function delete($id);

/**
* Get item by id.
*
* @api
* @param int $id.
* @return bool.
* @param int $id
* @param int|null $storeId
* @return bool
*/
public function get($id);
public function get($id, $storeId = null);

/**
* Get item by id and store id, only if item published
*
* @api
* @param int $id
* @param int $storeId
* @return bool.
* @return bool
*/
public function view($id, $storeId);

22 changes: 22 additions & 0 deletions Api/ShortContentExtractorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/

namespace Magefan\Blog\Api;

interface ShortContentExtractorInterface
{
/**
* Retrieve short filtered content
* @param string$content
* @param mixed $len
* @param mixed $endCharacters
* @return string
* @throws \Exception
*/
public function execute($content, $len = null, $endCharacters = null);
}
19 changes: 13 additions & 6 deletions Api/SitemapConfigInterface.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
* Glory to Ukraine! Glory to the heroes!
*/

declare(strict_types=1);

namespace Magefan\Blog\Api;

/**
@@ -16,22 +18,27 @@ interface SitemapConfigInterface
const HOME_PAGE = 'index';
const CATEGORIES_PAGE = 'category';
const POSTS_PAGE = 'post';
const TAGS_PAGE = 'tag';
const AUTHOR_PAGE = 'author';

/**
* @param string $page
* @param $page
* @param $storeId
* @return bool
*/
public function isEnabledSitemap($page);
public function isEnabledSitemap($page, $storeId = null): bool;

/**
* @param string $page
* @param $page
* @param $storeId
* @return string
*/
public function getFrequency($page);
public function getFrequency($page, $storeId = null): string;

/**
* @param string $page
* @param $page
* @param $storeId
* @return float
*/
public function getPriority($page);
public function getPriority($page, $storeId = null): float;
}
16 changes: 16 additions & 0 deletions Api/TagManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/

declare(strict_types=1);

namespace Magefan\Blog\Api;

interface TagManagementInterface extends ManagementInterface
{

}
21 changes: 21 additions & 0 deletions Api/VersionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/
declare(strict_types=1);

namespace Magefan\Blog\Api;

interface VersionInterface
{
/**
* get blog version and edition
*
* @api
* @return string
*/
public function getVersion(): string;
}
51 changes: 51 additions & 0 deletions Block/Adminhtml/AiButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*/

declare(strict_types=1);

namespace Magefan\Blog\Block\Adminhtml;

use Magefan\Blog\Model\Config;
use Magento\Backend\Block\Widget\Context;

class AiButton extends \Magento\Backend\Block\Widget\Grid\Container
{
const ADMIN_RESOURCE = 'Magefan_Blog::post_save';

/**
* @param Config $config
* @param Context $context
* @param array $data
*/
public function __construct(
Config $config,
Context $context,
array $data = []
) {
$this->config = $config;
parent::__construct($context, $data);
}

/**
* Preparing global layout
*
* @return $this
*/
protected function _prepareLayout()
{
if ($this->config->getConfig('mfblog/ai_writer/enabled_ai_writer')
&& $this->_authorization->isAllowed(self::ADMIN_RESOURCE)
) {
$this->getToolbar()->addChild(
'ai_button',
\Magento\Backend\Block\Widget\Button::class,
['label' => __('Add With AI'),
'onclick' => 'window.location.href = \'' . $this->getUrl('blog/createwithai/index') . '\'']
);
}
return $this;
}
}
41 changes: 41 additions & 0 deletions Block/Adminhtml/Comment/ReplyButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © Magefan (support@magefan.com). All rights reserved.
* Please visit Magefan.com for license details (https://magefan.com/end-user-license-agreement).
*
* Glory to Ukraine! Glory to the heroes!
*/

namespace Magefan\Blog\Block\Adminhtml\Comment;

use Magefan\Community\Block\Adminhtml\Edit\GenericButton;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

/**
* Class Reply Button Block
*/
class ReplyButton extends GenericButton implements ButtonProviderInterface
{
/**
* @return array
*/
public function getButtonData()
{
return [
'label' => __('Reply'),
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
'class' => 'reply',
'sort_order' => 10
];
}

/**
* Get URL for back (reset) button
*
* @return string
*/
public function getBackUrl()
{
return $this->getUrl('*/*/addreply/', ['id' => $this->getObjectId()]);
}
}
39 changes: 39 additions & 0 deletions Block/Adminhtml/Grid/Column/Render/Image.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Magefan\Blog\Block\Adminhtml\Grid\Column\Render;

use Magefan\Blog\Model\Url;
use Magento\Backend\Block\Context;
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;

class Image extends AbstractRenderer
{

/**
* @param Url $url
* @param Context $context
* @param array $data
*/
public function __construct(
Url $url,
Context $context,
array $data = []
) {
$this->_url = $url;
parent::__construct($context, $data);
}

/**
* @param DataObject $row
* @return string
*/
public function render(DataObject $row)
{
$imagePath = $row->getData($this->getColumn()->getIndex());
if ($imagePath) {
return '<img src="' . $this->escapeHtml($this->_url->getMediaUrl($imagePath)) . '" alt="" width="75"/>';
}
return '';
}
}
2 changes: 1 addition & 1 deletion Block/Adminhtml/Post/Helper/Form/Gallery.php
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@ public function getImages()
$result['images'][] = [
'value_id' => $image->getFile(),
'file' => $image->getFile(),
'label' => basename($image->getFile()),
'label' => basename($image->getFile() ?: ''),
'position' => $position,
'url' => $image->getUrl(),
];
25 changes: 23 additions & 2 deletions Block/Adminhtml/System/Config/Form/ColorPicker.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@

namespace Magefan\Blog\Block\Adminhtml\System\Config\Form;

use Magefan\Community\Api\SecureHtmlRendererInterface;
use Magento\Config\Block\System\Config\Form\Field;
use Magento\Framework\Data\Form\Element\AbstractElement;

@@ -16,6 +17,25 @@
*/
class ColorPicker extends Field
{
/**
* @var SecureHtmlRendererInterface
*/
private $mfSecureRenderer;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param SecureHtmlRendererInterface $mfSecureRenderer
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
SecureHtmlRendererInterface $mfSecureRenderer,
array $data = []
) {
parent::__construct($context, $data);
$this->mfSecureRenderer = $mfSecureRenderer;
}

/**
* @param AbstractElement $element
* @return string
@@ -25,7 +45,7 @@ protected function _getElementHtml(AbstractElement $element)
$html = $element->getElementHtml();
$value = $this->escapeHtml($element->getData('value'));

$html .= '<script>
$script = '
require(["jquery", "jquery/colorpicker/js/colorpicker", "domReady!"], function ($) {
var el = $("#' . $element->getHtmlId() . '");
@@ -42,7 +62,8 @@ protected function _getElementHtml(AbstractElement $element)
el.css("background-color", "#" + value);
});
});
</script>';
';
$html .= $this->mfSecureRenderer->renderTag('script', [], $script, false);

return $html;
}
Loading