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,20 @@
<script>
require(['jquery'], function ($) {
'use strict';
$(document).on('change', '.esun-blog-use-default input', function () {
var $checkbox = $(this),
$field = $($checkbox.attr('data-target')),
disabled = $checkbox.is(':checked'),
editor;
$field.prop('disabled', disabled);
if (window.tinyMCE && $field.attr('id')) {
editor = window.tinyMCE.get($field.attr('id'));
if (editor && editor.mode && editor.mode.set) {
editor.mode.set(disabled ? 'readonly' : 'design');
}
}
});
});
</script>
@@ -0,0 +1,40 @@
<?php
/** @var \Magento\Backend\Block\Template $block */
?>
<?php if ($block->getAuthorization()->isAllowed('Esun_MultiLocaleTranslation::queue_add')): ?>
<div class="esun-mlt-category-selection" data-role="esun-category-selection">
<div class="esun-mlt-category-selection__title">
<?= $block->escapeHtml(__('Batch Translation')) ?>
</div>
<form action="<?= $block->escapeUrl($block->getUrl('localetranslate/queue/prepareCategories')) ?>"
method="post"
data-role="esun-category-selection-form">
<?= $block->getBlockHtml('formkey') ?>
<input type="hidden" name="entity_ids" value="" data-role="esun-category-ids"/>
<div class="esun-mlt-category-selection__summary" data-role="esun-category-summary">
<?= $block->escapeHtml(__('No categories selected.')) ?>
</div>
<div class="esun-mlt-category-selection__actions">
<button type="button" class="action-secondary" data-action="select-loaded">
<span><?= $block->escapeHtml(__('Select Loaded')) ?></span>
</button>
<button type="button" class="action-secondary" data-action="clear-selection">
<span><?= $block->escapeHtml(__('Clear')) ?></span>
</button>
<button type="submit" class="action-primary" data-action="translate-selected" disabled>
<span><?= $block->escapeHtml(__('Translate Selected')) ?></span>
</button>
</div>
</form>
</div>
<script type="text/x-magento-init">
{
"*": {
"Esun_MultiLocaleTranslation/js/category-tree-selection": {
"treeSelector": "#tree-div",
"formSelector": "[data-role=esun-category-selection-form]"
}
}
}
</script>
<?php endif; ?>
@@ -0,0 +1,99 @@
<?php
/** @var \Esun\MultiLocaleTranslation\Block\Adminhtml\Queue\Form $block */
$selection = $block->getSelection();
$entityType = (string)($selection['entity_type'] ?? 'product');
$entityCount = count($selection['entity_ids'] ?? []);
?>
<form action="<?= $block->escapeUrl($block->getSubmitUrl()) ?>" method="post" class="admin__scope-old">
<input type="hidden" name="form_key" value="<?= $block->escapeHtmlAttr($block->getFormKeyValue()) ?>"/>
<input type="hidden" name="token" value="<?= $block->escapeHtmlAttr($block->getToken()) ?>"/>
<fieldset class="admin__fieldset">
<?php if ($selection): ?>
<input type="hidden" name="entity_type" value="<?= $block->escapeHtmlAttr($entityType) ?>"/>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Selected Items')) ?></span></label>
<div class="admin__field-control">
<div class="admin__field-value">
<?= $block->escapeHtml(__('%1: %2 item(s)', $entityType, $entityCount)) ?>
</div>
</div>
</div>
<?php else: ?>
<div class="admin__field _required">
<label class="admin__field-label" for="entity_type"><span><?= $block->escapeHtml(__('Entity Type')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" id="entity_type" name="entity_type" required>
<option value="product"><?= $block->escapeHtml(__('Product')) ?></option>
<option value="category"><?= $block->escapeHtml(__('Category')) ?></option>
<option value="cms_page"><?= $block->escapeHtml(__('CMS Page')) ?></option>
<option value="cms_block"><?= $block->escapeHtml(__('CMS Block')) ?></option>
<option value="blog_post"><?= $block->escapeHtml(__('Blog Post')) ?></option>
<option value="wiki_category"><?= $block->escapeHtml(__('Wiki Category')) ?></option>
<option value="wiki_homepage"><?= $block->escapeHtml(__('Wiki Homepage')) ?></option>
</select>
</div>
</div>
<div class="admin__field _required">
<label class="admin__field-label" for="entity_ids"><span><?= $block->escapeHtml(__('Entity IDs')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" id="entity_ids" name="entity_ids" rows="5" required></textarea>
<div class="note"><?= $block->escapeHtml(__('Enter multiple IDs separated by commas, spaces, or new lines. For categories, use the Category IDs shown in the category tree/editor URL.')) ?></div>
</div>
</div>
<?php endif; ?>
<div class="admin__field _required">
<label class="admin__field-label" for="source_store_id"><span><?= $block->escapeHtml(__('Source Store View')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" id="source_store_id" name="source_store_id" required>
<option value="0"><?= $block->escapeHtml(__('Default Store View (0)')) ?></option>
<?php foreach ($block->getStoreGroups() as $storeGroup): ?>
<optgroup label="<?= $block->escapeHtmlAttr($storeGroup['website']) ?>">
<?php foreach ($storeGroup['stores'] as $store): ?>
<option value="<?= (int)$store['store_id'] ?>">
<?= $block->escapeHtml($store['label'] . ' (' . $store['code'] . ' · ' . $store['locale'] . ')') ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="admin__field _required">
<label class="admin__field-label" for="target_store_ids"><span><?= $block->escapeHtml(__('Target Store Views')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-multiselect" id="target_store_ids" name="target_store_ids[]" multiple size="12" required>
<?php foreach ($block->getStoreGroups() as $storeGroup): ?>
<optgroup label="<?= $block->escapeHtmlAttr($storeGroup['website']) ?>">
<?php foreach ($storeGroup['stores'] as $store): ?>
<option value="<?= (int)$store['store_id'] ?>">
<?= $block->escapeHtml($store['label'] . ' (' . $store['code'] . ' · ' . $store['locale'] . ')') ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
<div class="note"><?= $block->escapeHtml(__('Each selected entity and target Store View creates one queue task.')) ?></div>
</div>
</div>
<div class="admin__field _required">
<label class="admin__field-label" for="provider"><span><?= $block->escapeHtml(__('Translation Provider')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" id="provider" name="provider" required>
<?php foreach ($block->getProviders() as $provider): ?>
<option value="<?= $block->escapeHtmlAttr($provider['code']) ?>"
<?= $provider['code'] === $block->getDefaultProvider() ? ' selected' : '' ?>>
<?= $block->escapeHtml($provider['label']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
</fieldset>
<div class="page-actions">
<a class="action-secondary" href="<?= $block->escapeUrl($block->getQueueUrl()) ?>"><?= $block->escapeHtml(__('View Queue')) ?></a>
<button type="submit" class="action-primary"><span><?= $block->escapeHtml(__('Add to Translation Queue')) ?></span></button>
</div>
</form>
@@ -0,0 +1,72 @@
<?php
/**
* @var \Esun\MultiLocaleTranslation\Block\Adminhtml\Translate\Index $block
*/
$entityType = $block->getEntityType();
$entityId = $block->getEntityId();
$sourceStoreId = $block->getSourceStoreId();
$storeOptions = $block->getStoreOptions();
?>
<div id="esun-mlt-root" class="admin__scope-old">
<div class="page-title">
<h1 class="page-title">
<?= $block->escapeHtml(__('Translate %1', strtoupper($entityType))) ?>
</h1>
<p>
<?= $block->escapeHtml(__('Entity ID: %1', $entityId)) ?>
<span style="margin-left: 16px;">
<?= $block->escapeHtml(__('Source: %1', $block->getSourceStoreIdName())) ?>
</span>
</p>
</div>
<div class="admin__fieldset">
<div class="admin__field">
<label class="admin__field-label" for="mlt-target-store">
<span><?= $block->escapeHtml(__('Target Store View')) ?></span>
</label>
<div class="admin__field-control">
<select id="mlt-target-store" class="admin__control-select">
<?php foreach ($storeOptions as $storeOption): ?>
<?php if ((int)$storeOption['store_id'] === (int)$sourceStoreId) {
continue;
} ?>
<option value="<?= (int)$storeOption['store_id'] ?>">
<?= $block->escapeHtml($storeOption['label']) ?> (<?= $block->escapeHtml($storeOption['code']) ?>)
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div style="margin-top: 16px;">
<button id="mlt-load-btn" class="action-primary" type="button">
<?= $block->escapeHtml(__('Load Fields')) ?>
</button>
</div>
</div>
<div id="mlt-fields" style="margin-top: 18px;"></div>
<div class="admin__field" style="margin-top: 20px; display: none;" id="mlt-save-area">
<button id="mlt-save-btn" class="action-secondary" type="button">
<?= $block->escapeHtml(__('Save Translation')) ?>
</button>
</div>
</div>
<script type="text/x-magento-init">
{
"#esun-mlt-root": {
"Esun_MultiLocaleTranslation/js/translate-form": {
"entityType": "<?= $block->escapeJs($entityType) ?>",
"entityId": <?= (int)$entityId ?>,
"sourceStoreId": <?= (int)$sourceStoreId ?>,
"fieldsUrl": "<?= $block->escapeJs($block->getFieldsUrl()) ?>",
"applyUrl": "<?= $block->escapeJs($block->getApplyUrl()) ?>",
"formKey": "<?= $block->escapeJs($block->getFormKeyValue()) ?>"
}
}
}
</script>