This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,181 @@
<?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
*/
use Magento\Framework\Escaper;
/** @var Escaper $escaper */
?>
<div id="category-edit-container" class="category-content">
<?= $block->getChildHtml('form') ?>
</div>
<script>
require([
"jquery",
"tinymce<?= /** @noEscape */ $block->getMagentoVersion() ?>",
"loadingPopup",
"mage/backend/floating-header"
], function (jQuery, tinyMCE) {
//<![CDATA[
function categoryReset (url, useAjax) {
if (useAjax) {
var params = {active_tab_id: false};
updateContent(url, params);
} else {
location.href = url;
}
}
/**
* Delete some Category
* This routine get categoryId explicitly, so even if currently selected tree node is out of sync
* with this form, we surely delete same Category in the tree and at backend
*/
function categoryDelete (url) {
if (confirm('<?= $escaper->escapeHtml(__('Are you sure you want to delete this Category?')) ?>')) {
location.href = url;
}
}
/**
* Update Category content area
*/
function updateContent (url, params, refreshTree) {
var node = tree.getNodeById(tree.currentNodeId),
parentNode = node && node.parentNode,
parentId,
redirectUrl;
params = jQuery.extend(params || {}, {
form_key: FORM_KEY
});
if (params.node_name) {
node.setText(params.node_name);
}
(function ($) {
var $categoryContainer = $('#category-edit-container'),
messagesContainer = $('.messages');
messagesContainer.html('');
$.ajax({
url: url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true'),
data: params,
context: $('body'),
showLoader: true
}).done(function (data) {
if (data.content) {
var pageActions = $('.page-actions');
for (var i = 0; i < pageActions.length; i++){
if ($(pageActions[i]).data('floatingHeader')) {
$(pageActions[i]).floatingHeader('destroy');
}
}
try {
$('#category-edit-container .wysiwyg-editor').each(function (index, element) {
tinyMCE.execCommand('mceRemoveControl', false, $(element).attr('id'));
});
$categoryContainer.html('');
} catch (e) {
alert(e.message);
}
$categoryContainer.html(data.content).trigger('contentUpdated');
setTimeout(function () {
$('#category-edit-container .wysiwyg-editor').each(function (index, element) {
tinyMCE.execCommand('mceRemoveControl', false, $(element).attr('id'));
tinyMCE.execCommand('mceAddControl', true, $(element).attr('id'));
});
$('.page-actions').floatingHeader({
'title': '.category-edit-title'
});
$('body').trigger('contentUpdated');
try {
if (refreshTree) {
window.refreshTreeArea();
}
} catch (e) {
alert(e.message);
}
}, 25);
}
if (data.messages && data.messages.length > 0) {
messagesContainer.html(data.messages);
}
if (data.toolbar) {
$('[data-ui-id="page-actions-toolbar-content-header"]').replaceWith(data.toolbar)
}
});
})(jQuery);
}
/**
* Refresh tree nodes after saving or deleting a category
*/
function refreshTreeArea (transport) {
var config,
url;
if (tree && window.editingCategoryBreadcrumbs) {
if (tree.nodeForDelete) {
var node = tree.getNodeById(tree.nodeForDelete);
tree.nodeForDelete = false;
if (node) {
// Check maybe tree became somehow not synced with ajax and we're trying to delete unknown node
node.parentNode.removeChild(node);
tree.currentNodeId = false;
}
}
// category created - add its node
else if (tree.addNodeTo) {
var parent = tree.getNodeById(tree.addNodeTo);
tree.addNodeTo = false;
if (parent) {
// Check maybe tree became somehow not synced with ajax and we're trying to add to unknown node
config = editingCategoryBreadcrumbs[editingCategoryBreadcrumbs.length - 1];
window.location.href = tree.buildUrl(config.id);
}
}
// update all affected categories nodes names
for (var i = 0; i < editingCategoryBreadcrumbs.length; i++){
var node = tree.getNodeById(editingCategoryBreadcrumbs[i].id);
if (node) {
node.setText(editingCategoryBreadcrumbs[i].text);
}
}
}
}
function displayLoadingMask () {
jQuery('body').loadingPopup();
}
window.refreshTreeArea = refreshTreeArea;
window.updateContent = updateContent;
window.categoryDelete = categoryDelete;
window.categoryReset = categoryReset;
window.displayLoadingMask = displayLoadingMask;
//]]>
});
</script>
@@ -0,0 +1,188 @@
<?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
*/
use Mageplaza\Blog\Block\Adminhtml\Category\Edit\Form;
use Magento\Framework\Escaper;
/** @var Form $block */
/** @var Escaper $escaper */
$parentId = $block->getParentCategoryId();
$categoryId = $block->getCategoryId();
$blockGrid = $block->getLayout()->getBlock('mageplaza_blog_category_edit_tab_post');
$gridJsObjectName = $blockGrid->getJsObjectName();
?>
<div data-mage-init='{"floatingHeader": {}}' class="page-actions">
<?= $block->getAdditionalButtonsHtml(); ?>
</div>
<?= $block->getTabsHtml() ?>
<iframe name="iframeSave" style="display:none; width:100%;"
src="<?= $escaper->escapeUrl($block->getViewFileUrl('blank.html')) ?>"></iframe>
<form id="category_edit_form" name="category-edit-form"
action="<?= $escaper->escapeUrl($block->getSaveUrl()) ?>" method="post"
enctype="multipart/form-data">
<div class="no-display">
<input type="hidden" name="isIframe" value="1"/>
<input name="form_key" type="hidden" value="<?= /** @noEscape */
$block->getFormKey() ?>"/>
<input type="hidden" name="active_tab_id" id="active_tab_id" value=""/>
<?php if ($parentId !== 0) : ?>
<input type="hidden" name="parent" value="<?= /** @noEscape */
$parentId ?>"/>
<?php endif; ?>
<?php if ($categoryId !== 0) : ?>
<input type="hidden" name="category_id" value="<?= /** @noEscape */
$categoryId ?>"/>
<?php endif; ?>
<input type="hidden" name="selected_products" id="in_category_products" value=""/>
<script type="text/x-magento-init">
{
"*": {
"Magento_Catalog/catalog/category/assign-products": {
"selectedProducts": <?= /** @noEscape */ $block->getPostsJson() ?>,
"gridJsObjectName": <?= '"' . $gridJsObjectName . '"' ?: '{}'; ?>
}
}
}
</script>
</div>
<div id="category_tab_content"></div>
</form>
<div data-id="information-dialog-category" class="messages" style="display: none;">
<div class="message message-notice">
<div><?= $escaper->escapeHtml(__('This operation can take a long time')) ?></div>
</div>
</div>
<script>
require(['jquery', 'jquery/ui', "mage/mage", "mage/translate"], function ($) {
var mageDialog = (function ($) {
var self = {dialogOpened: false, callback: [], needShow: false};
self.callback = {ok: [], cancel: []};
self.createDialog = function () {
var onEvent = function (type, dialog) {
self.callback[type].forEach(function (call) {
call();
});
$(dialog).dialog("close");
};
self.dialog = $('[data-id="information-dialog-category"]').dialog({
autoOpen: false,
modal: true,
dialogClass: 'popup-window',
resizable: false,
width: '75%',
title: $.mage.__('Warning message'),
buttons: [{
text: $.mage.__('Ok'),
'class': 'action-primary',
click: function () {
onEvent('ok', this);
}
}, {
text: $.mage.__('Cancel'),
'class': 'action-close',
click: function () {
onEvent('cancel', this);
}
}],
open: function () {
$(this).closest('.ui-dialog').addClass('ui-dialog-active');
var topMargin = $(this).closest('.ui-dialog').children('.ui-dialog-titlebar').outerHeight() + 30;
$(this).closest('.ui-dialog').css('margin-top', topMargin);
self.dialogOpened = true;
self.callback.ok.push(function () {
self.needShow = false;
});
},
close: function (event, ui) {
$(this).dialog('destroy');
self.dialogOpened = false;
self.callback = {ok: [], cancel: []};
delete self.dialog;
}
});
};
return {
needToShow: function () {
self.needShow = true && !!$('[data-ui-id="tabs-tab-general-information-fieldset-element-hidden-general-id"]').length;
return this;
},
isNeedShow: function () {
return self.needShow;
},
onOk: function (call) {
self.callback.ok.push(call);
return this;
},
onCancel: function (call) {
self.callback.cancel.push(call);
return this;
},
show: function () {
if (self.dialog == undefined) {
self.createDialog();
}
if (self.dialogOpened == false) {
self.dialog.dialog('open');
}
return this;
}
};
})(jQuery);
$(document).on('change', '[data-ui-id="urlkeyrenderer-text-general-url-key"]', function () {
mageDialog.needToShow();
});
$('#category_edit_form')
.mage('categoryForm', {refreshUrl: '<?= /** @noEscape */ $block->getRefreshPathUrl() ?>'})
.mage('validation', {
submitHandler: function (form) {
if (mageDialog.isNeedShow()) {
mageDialog.onOk(function () {
form.submit();
displayLoadingMask();
}).show();
} else {
form.submit();
displayLoadingMask();
}
}
});
});
<?php if ($block->isAjax()
&& ($tabsBlock = $block->getLayout()->getBlock('tabs'))
&& ($_tabsJsObject = $tabsBlock->getJsObjectName())) : ?>
require(["jquery", "mage/backend/tabs"], function ($) {
var activeAnchor = $('#<?= /** @noEscape */ $tabsBlock->getId() ?>').tabs('activeAnchor');
if (activeAnchor.length) {
$('active_tab_id').value = activeAnchor.prop('id');
}
$('active_tab_id').tabsJsObject = $('#<?= /** @noEscape */ $tabsBlock->getId() ?>');
});
<?php endif; ?>
</script>
@@ -0,0 +1,157 @@
<?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
*/
use Mageplaza\Blog\Block\Adminhtml\Import\Edit\Import;
use Magento\Framework\Escaper;
/** @var Import $block */
/** @var Escaper $escaper */
?>
<script>
require(['jquery'], function ($) {
var dataImport = {},
defaultTablePrefix = ['wp_', 'm1_', 'm2_'],
imagePathHint = [
'*Please copy the <b>wp_content/uploads</b> folder to <b>pub/media/wysiwyg/</b> folder for post image content <br>' +
'*Please copy the <b>wp_content/uploads</b> folder to <b>pub/media/mageplaza/blog/post/</b> folder for post image banner <br>',
'*Please copy the <b>media</b> folder to <b>pub/media/</b> folder',
'*Please copy the <b>pub/media/magefan_blog</b> folder to <b>pub/media/mageplaza/blog/post/</b> folder for post image banner '
];
mpBlogImport = {
typeSelector: <?= /** noEscape */ $block->getTypeSelector() ?>,
initImportFieldsSet: function () {
for (var i = 0; i < this.typeSelector.length; i++){
if ($('#import_type').val() === this.typeSelector[i]) {
this.showFieldSet('#' + this.typeSelector[i] + '_fieldset');
dataImport = {
type: this.typeSelector[i],
importName: '#' + this.typeSelector[i] + '_import_name',
dbName: '#' + this.typeSelector[i] + '_db_name',
userName: '#' + this.typeSelector[i] + '_user_name',
pwd: '#' + this.typeSelector[i] + '_db_password',
host: '#' + this.typeSelector[i] + '_db_host',
tablePrefix: '#' + this.typeSelector[i] + '_table_prefix',
behaviourSelector: '#' + this.typeSelector[i] + '_import_behaviour',
expandBehaviourSelector: '#' + this.typeSelector[i] + '_import_behaviour_expand'
};
$(dataImport.tablePrefix).val(defaultTablePrefix[i]);
$("#" + this.typeSelector[i] + "_import_image_path").html(imagePathHint[i]);
$("#" + this.typeSelector[i] + "_db_name").addClass('required-entry');
$("#" + this.typeSelector[i] + "_user_name").addClass('required-entry');
$("#" + this.typeSelector[i] + "_db_host").addClass('required-entry');
} else {
this.hideFieldSet('#' + this.typeSelector[i] + '_fieldset');
$("#" + this.typeSelector[i] + "_db_name").removeClass('required-entry');
$("#" + this.typeSelector[i] + "_user_name").removeClass('required-entry');
$("#" + this.typeSelector[i] + "_db_host").removeClass('required-entry');
}
}
},
initExpandBehaviour: function () {
if ($(dataImport.behaviourSelector).attr("value") === 'update') {
$(dataImport.expandBehaviourSelector).parent().parent().removeClass('hidden');
} else {
$(dataImport.expandBehaviourSelector).parent().parent().addClass('hidden');
}
},
showFieldSet: function (selector) {
$(selector).show();
},
hideFieldSet: function (selector) {
$(selector).hide();
},
initImportCheckConnection: function () {
if ($('#edit_form').valid()) {
$('body').loader('show');
var url = '<?= $escaper->escapeUrl($block->getUrl(
'mageplaza_blog/import/validate',
['form_key' => $block->getFormKey()]
)) ?>';
$.ajax({
url: url,
data: {
type: dataImport.type,
import_name: $(dataImport.importName).val(),
database: $(dataImport.dbName).val(),
user_name: $(dataImport.userName).val(),
password: $(dataImport.pwd).val(),
host: $(dataImport.host).val(),
table_prefix: $(dataImport.tablePrefix).val(),
behaviour: $(dataImport.behaviourSelector).val(),
expand_behaviour: $(dataImport.expandBehaviourSelector).val()
},
cache: false,
success: function (result) {
var messageHtml;
if (result.status === 'false') {
messageHtml = '<?= $block->getMessagesHtml(
'adderror',
'False connection. Please check the credentials and try again!'
) ?>';
$(".message-error").hide();
$(messageHtml).appendTo($(".page-columns"));
$(".message-success").hide();
} else {
messageHtml = '<?= $block->getMessagesHtml(
'addsuccess',
'Connect successfully. To start import process press "Import" button'
. $block->getImportButtonHtml()
) ?>';
$(".message-success").hide();
$(messageHtml).appendTo($(".page-columns"));
$(".message-error").hide();
}
},
complete: function () {
$('body').loader('hide');
}
});
}
},
importAction: function () {
$('body').loader('show');
$.ajax({
url: '<?= $escaper->escapeUrl($block->getUrl(
'mageplaza_blog/import/import',
['form_key' => $block->getFormKey()]
))?>',
cache: false,
success: function (result) {
var statisticMessage = result.statistic;
$(".message-success").hide();
$(".message-error").hide();
$(statisticMessage).appendTo($(".page-columns"));
},
complete: function () {
$('body').loader('hide');
}
});
}
};
});
</script>