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,230 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Block\Adminhtml\Category;
use Esun\Wiki\Model\Category;
use Esun\Wiki\Model\CategoryFactory;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\System\Store as SystemStore;
class EditBlock extends Template
{
private ?Category $category = null;
public function __construct(
Context $context,
private readonly CategoryFactory $categoryFactory,
private readonly CollectionFactory $collectionFactory,
private readonly FormFactory $formFactory,
private readonly WysiwygConfig $wysiwygConfig,
private readonly SystemStore $systemStore,
array $data = []
) {
parent::__construct($context, $data);
}
public function getCategory(): Category
{
if ($this->category === null) {
$this->category = $this->categoryFactory->create();
$id = (int) $this->getRequest()->getParam('id');
if ($id > 0) {
$this->category->load($id);
}
}
return $this->category;
}
public function getSaveUrl(): string
{
return $this->getUrl('esun_wiki/category/save');
}
public function getBackUrl(): string
{
return $this->getUrl('esun_wiki/category/index');
}
public function getPreviewUrl(): string
{
$id = (int) $this->getCategory()->getId();
$customPath = trim((string) $this->getCategory()->getData('custom_url_path'), '/');
$baseUrl = rtrim($this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_LINK), '/');
if ($id > 0 && $customPath !== '' && $this->getCategory()->isClickable()) {
return $baseUrl . '/' . $customPath;
}
return $id > 0 && $this->getCategory()->isClickable()
? $baseUrl . '/wiki/index/view/slug/'
. rawurlencode((string) $this->getCategory()->getData('slug')) . '/'
: '';
}
public function getContentEditorHtml(): string
{
$form = $this->formFactory->create();
$editor = $form->addField('content', 'editor', [
'name' => 'content',
'label' => __('Wiki Content'),
'title' => __('Wiki Content'),
'style' => 'width:100%;height:36em',
'required' => false,
'value' => (string) $this->getCategory()->getData('content'),
'config' => $this->wysiwygConfig->getConfig([
'add_variables' => false,
'add_widgets' => true,
'add_images' => true,
'is_pagebuilder_enabled' => true,
'pagebuilder_button' => true,
]),
]);
return $editor->getElementHtml();
}
public function getLogoUrl(): string
{
$path = trim((string) $this->getCategory()->getData('logo_path'));
if ($path === '') {
return '';
}
return rtrim($this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA), '/')
. '/' . ltrim($path, '/');
}
/**
* @return int[]
*/
public function getSelectedStoreIds(): array
{
if (!$this->getCategory()->getId()) {
return [0];
}
$storeIds = array_map('intval', (array) $this->getCategory()->getData('store_ids'));
return $storeIds ?: [0];
}
/**
* @return array<int, array{value:int|string,label:string,disabled:bool}>
*/
public function getStoreOptions(): array
{
$options = [];
foreach ($this->systemStore->getStoreValuesForForm(false, true) as $option) {
$children = $option['value'] ?? null;
if (!is_array($children)) {
$options[] = [
'value' => (int) $children,
'label' => (string) $option['label'],
'disabled' => false,
];
continue;
}
$options[] = [
'value' => '',
'label' => (string) $option['label'],
'disabled' => true,
];
foreach ($children as $child) {
$options[] = [
'value' => (int) $child['value'],
'label' => (string) $child['label'],
'disabled' => false,
];
}
}
return $options;
}
/**
* @return array<int, array{value:int,label:string}>
*/
public function getParentOptions(): array
{
$currentId = (int) $this->getCategory()->getId();
$excludedIds = $currentId > 0 ? $this->getExcludedParentIds($currentId) : [];
$nodes = [];
foreach ($this->collectionFactory->create()->addTreeOrder() as $category) {
$id = (int) $category->getId();
if (isset($excludedIds[$id])) {
continue;
}
$nodes[$id] = [
'id' => $id,
'parent_id' => (int) $category->getData('parent_id'),
'title' => (string) $category->getData('title'),
'children' => [],
];
}
foreach ($nodes as $id => $node) {
$parentId = (int) $node['parent_id'];
if ($parentId > 0 && isset($nodes[$parentId])) {
$nodes[$parentId]['children'][$id] = &$nodes[$id];
}
}
$options = [['value' => 0, 'label' => (string) __('Root Category')]];
foreach ($nodes as $id => $node) {
if ((int) $node['parent_id'] === 0 || !isset($nodes[(int) $node['parent_id']])) {
$this->appendOption($options, $node, 0);
}
}
return $options;
}
/**
* @return array<int, bool>
*/
private function getExcludedParentIds(int $currentId): array
{
$childrenByParent = [];
foreach ($this->collectionFactory->create() as $category) {
$childrenByParent[(int) $category->getData('parent_id')][] = (int) $category->getId();
}
$excluded = [$currentId => true];
$queue = $childrenByParent[$currentId] ?? [];
while ($queue) {
$id = (int) array_shift($queue);
$excluded[$id] = true;
foreach ($childrenByParent[$id] ?? [] as $childId) {
$queue[] = (int) $childId;
}
}
return $excluded;
}
/**
* @param array<int, array{value:int,label:string}> $options
* @param mixed[] $node
*/
private function appendOption(array &$options, array $node, int $depth): void
{
$options[] = [
'value' => (int) $node['id'],
'label' => str_repeat('-- ', $depth) . (string) $node['title'],
];
foreach ($node['children'] as $childNode) {
$this->appendOption($options, $childNode, $depth + 1);
}
}
}
@@ -0,0 +1,82 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Block\Adminhtml\Homepage;
use Esun\Wiki\Model\Homepage;
use Esun\Wiki\Model\HomepageFactory;
use Esun\Wiki\Model\ResourceModel\Homepage\CollectionFactory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
use Magento\Framework\Data\FormFactory;
use Magento\Framework\UrlInterface;
class EditBlock extends Template
{
private ?Homepage $homepage = null;
public function __construct(
Context $context,
private readonly HomepageFactory $homepageFactory,
private readonly CollectionFactory $collectionFactory,
private readonly FormFactory $formFactory,
private readonly WysiwygConfig $wysiwygConfig,
array $data = []
) {
parent::__construct($context, $data);
}
public function getHomepage(): Homepage
{
if ($this->homepage === null) {
$homepage = $this->collectionFactory->create()
->setPageSize(1)
->getFirstItem();
$this->homepage = $homepage->getId() ? $homepage : $this->homepageFactory->create();
if (!$this->homepage->getData('title')) {
$this->homepage->setData('title', 'eSUN Wiki');
}
}
return $this->homepage;
}
public function getSaveUrl(): string
{
return $this->getUrl('esun_wiki/homepage/save');
}
public function getCategoriesUrl(): string
{
return $this->getUrl('esun_wiki/category/index');
}
public function getPreviewUrl(): string
{
return rtrim($this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_LINK), '/') . '/wiki';
}
public function getContentEditorHtml(): string
{
$form = $this->formFactory->create();
$editor = $form->addField('content', 'editor', [
'name' => 'content',
'label' => __('Homepage Content'),
'title' => __('Homepage Content'),
'style' => 'height:36em',
'required' => false,
'value' => (string) $this->getHomepage()->getData('content'),
'config' => $this->wysiwygConfig->getConfig([
'add_variables' => false,
'add_widgets' => true,
'add_images' => true,
'is_pagebuilder_enabled' => true,
'pagebuilder_button' => true,
]),
]);
return $editor->getElementHtml();
}
}
@@ -0,0 +1,211 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Block\Wiki;
use Esun\Catalog\Model\ResourceModel\SpecificationBrand\CollectionFactory as BrandCollectionFactory;
use Esun\Catalog\Model\ResourceModel\SpecificationFile\CollectionFactory as FileCollectionFactory;
use Esun\Catalog\Model\ResourceModel\SpecificationImport\CollectionFactory as ImportCollectionFactory;
use Esun\Catalog\Model\SpecificationMedia;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\Template;
use Magento\Store\Model\StoreManagerInterface;
class DownloadCenter extends Template
{
private ?array $items = null;
private ?array $archives = null;
private ?array $activeBrands = null;
public function __construct(
Template\Context $context,
private readonly FileCollectionFactory $fileCollectionFactory,
private readonly BrandCollectionFactory $brandCollectionFactory,
private readonly ImportCollectionFactory $importCollectionFactory,
private readonly SpecificationMedia $media,
private readonly StoreManagerInterface $storeManager,
private readonly Json $json,
array $data = []
) {
parent::__construct($context, $data);
}
public function isTargetPage(): bool
{
$parent = $this->getParentBlock();
if (!($parent instanceof View)) {
return false;
}
$category = $parent->getCurrentCategory();
return $category !== null
&& (int) $category->getData('show_download_center') === 1;
}
public function hasSpecifications(): bool
{
return $this->isTargetPage() && (bool) ($this->getItems() || $this->getArchives());
}
public function getConfigJson(): string
{
$items = $this->getItems();
$archives = $this->getArchives();
$brands = [];
$modelsByBrand = [];
foreach ($archives as $archive) {
$brandId = (string) $archive['brand_id'];
$brands[$brandId] = [
'id' => $brandId,
'name' => $archive['brand_name'],
];
}
foreach ($items as $item) {
$brandId = (string) $item['brand_id'];
$brands[$brandId] = [
'id' => $brandId,
'name' => $item['brand_name'],
];
$modelsByBrand[$brandId][$item['model_name']] = $item['model_name'];
}
foreach ($modelsByBrand as $brandId => $models) {
$modelsByBrand[$brandId] = array_values($models);
sort($modelsByBrand[$brandId], SORT_NATURAL | SORT_FLAG_CASE);
}
return $this->json->serialize([
'items' => $items,
'archives' => $archives,
'brands' => array_values($brands),
'modelsByBrand' => $modelsByBrand,
]);
}
private function getItems(): array
{
if ($this->items !== null) {
return $this->items;
}
$activeBrands = $this->getActiveBrands();
if (!$activeBrands) {
return $this->items = [];
}
$mediaBaseUrl = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
$items = [];
$collection = $this->fileCollectionFactory->create()
->addFieldToFilter('brand_id', ['in' => array_keys($activeBrands)])
->setOrder('brand_name', 'ASC')
->setOrder('model_name', 'ASC')
->setOrder('file_name', 'ASC');
foreach ($collection as $file) {
$filePath = (string) $file->getData('file_path');
$brandId = (int) $file->getData('brand_id');
$logoPath = (string) $activeBrands[$brandId]['logo'];
$items[] = [
'id' => (int) $file->getId(),
'type' => 'file',
'brand_id' => $brandId,
'brand_name' => (string) $activeBrands[$brandId]['name'],
'brand_logo_url' => $logoPath !== '' ? $mediaBaseUrl . ltrim($logoPath, '/') : '',
'model_name' => (string) $file->getData('model_name'),
'file_name' => strtoupper((string) $file->getData('file_name')),
'file_url' => $mediaBaseUrl . ltrim($filePath, '/'),
'file_size_label' => $this->formatFileSize((int) $file->getData('file_size')),
'file_date' => $file->getData('file_mtime')
? date('Y-m-d', strtotime((string) $file->getData('file_mtime')))
: '',
];
}
return $this->items = $items;
}
private function getArchives(): array
{
if ($this->archives !== null) {
return $this->archives;
}
$activeBrands = $this->getActiveBrands();
if (!$activeBrands) {
return $this->archives = [];
}
$mediaBaseUrl = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
$archives = [];
$seenBrandIds = [];
$collection = $this->importCollectionFactory->create()
->addFieldToFilter('status', 1)
->addFieldToFilter('brand_id', ['in' => array_keys($activeBrands)])
->setOrder('updated_at', 'DESC');
foreach ($collection as $import) {
$brandId = (int) $import->getData('brand_id');
$archivePath = (string) $import->getData('archive_file');
if (isset($seenBrandIds[$brandId]) || $archivePath === '' || !$this->media->exists($archivePath)) {
continue;
}
$brand = $activeBrands[$brandId];
$logoPath = (string) $brand['logo'];
$archives[] = [
'id' => 'archive-' . (int) $import->getId(),
'type' => 'archive',
'brand_id' => $brandId,
'brand_name' => (string) $brand['name'],
'brand_logo_url' => $logoPath !== '' ? $mediaBaseUrl . ltrim($logoPath, '/') : '',
'model_name' => '',
'file_name' => basename($archivePath),
'file_url' => $mediaBaseUrl . ltrim($archivePath, '/'),
'file_size_label' => $this->formatFileSize($this->media->getFileSize($archivePath)),
'file_date' => $import->getData('updated_at')
? date('Y-m-d', strtotime((string) $import->getData('updated_at')))
: '',
];
$seenBrandIds[$brandId] = true;
}
usort($archives, static fn (array $a, array $b): int => strcasecmp($a['brand_name'], $b['brand_name']));
return $this->archives = $archives;
}
private function getActiveBrands(): array
{
if ($this->activeBrands !== null) {
return $this->activeBrands;
}
$brands = [];
$collection = $this->brandCollectionFactory->create()
->addFieldToFilter('status', 1)
->setOrder('sort_order', 'ASC')
->setOrder('brand_name', 'ASC');
foreach ($collection as $brand) {
$brands[(int) $brand->getId()] = [
'name' => (string) $brand->getData('brand_name'),
'logo' => (string) $brand->getData('brand_logo'),
];
}
return $this->activeBrands = $brands;
}
private function formatFileSize(int $bytes): string
{
if ($bytes >= 1048576) {
return round($bytes / 1048576, 1) . ' MB';
}
return round($bytes / 1024, 1) . ' KB';
}
}
@@ -0,0 +1,135 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Block\Wiki;
use Esun\Catalog\Model\PrintingParameter;
use Esun\Wiki\Model\PrintingParameterClassifier;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\Element\Template;
class ParameterComparison extends Template
{
private ?array $config = null;
public function __construct(
Template\Context $context,
private readonly PrintingParameter $printingParameter,
private readonly PrintingParameterClassifier $classifier,
private readonly Json $json,
array $data = []
) {
parent::__construct($context, $data);
}
public function isTargetPage(): bool
{
$parent = $this->getParentBlock();
if (!($parent instanceof View)) {
return false;
}
$category = $parent->getCurrentCategory();
return $category !== null
&& (int) $category->getData('show_parameter_comparison') === 1;
}
public function hasComparisonData(): bool
{
return $this->isTargetPage() && (bool) $this->getConfig()['products'];
}
public function getConfigJson(): string
{
return $this->json->serialize($this->getConfig());
}
public function getBaseOptions(): array
{
return $this->getConfig()['baseOptions'];
}
public function getApplicationOptions(): array
{
return $this->getConfig()['applicationOptions'];
}
public function getParameterGroups(): array
{
return $this->getConfig()['parameterGroups'];
}
private function getConfig(): array
{
if ($this->config !== null) {
return $this->config;
}
$products = [];
$parameterGroups = [];
$baseCounts = [];
$applicationCounts = [];
foreach ($this->printingParameter->getAll() as $rawName => $groups) {
$classification = $this->classifier->classify($rawName);
$cleanName = $this->classifier->cleanName($rawName);
$productGroups = [];
foreach ($groups as $groupName => $group) {
$items = is_array($group['items'] ?? null) ? $group['items'] : [];
if (!$items) {
continue;
}
$productGroups[$groupName] = $items;
foreach (array_keys($items) as $parameterName) {
$parameterGroups[$groupName][(string) $parameterName] = (string) $parameterName;
}
}
$products[] = [
'id' => $rawName,
'name' => $cleanName,
'base' => $classification['base'],
'applications' => $classification['applications'],
'groups' => $productGroups,
];
$baseCounts[$classification['base']] = ($baseCounts[$classification['base']] ?? 0) + 1;
foreach ($classification['applications'] as $application) {
$applicationCounts[$application] = ($applicationCounts[$application] ?? 0) + 1;
}
}
usort($products, static fn (array $a, array $b): int => strnatcasecmp($a['name'], $b['name']));
$baseOptions = $this->buildOptions($this->classifier->getBaseOptions(), $baseCounts);
$applicationOptions = $this->buildOptions($this->classifier->getApplicationOptions(), $applicationCounts);
foreach ($parameterGroups as $groupName => $items) {
$parameterGroups[$groupName] = array_values($items);
}
return $this->config = [
'products' => $products,
'baseOptions' => $baseOptions,
'applicationOptions' => $applicationOptions,
'parameterGroups' => $parameterGroups,
'messages' => [
'selectMaterials' => (string) __('Select 1 to 6 materials to view or compare.'),
'maximumMaterials' => (string) __('You can compare up to 6 materials.'),
'noMaterials' => (string) __('No materials match the selected filters.'),
'missingValue' => '—',
],
];
}
private function buildOptions(array $labels, array $counts): array
{
$options = [];
foreach ($labels as $value => $label) {
if (($counts[$value] ?? 0) > 0) {
$options[] = ['value' => $value, 'label' => $label, 'count' => $counts[$value]];
}
}
return $options;
}
}
+878
View File
@@ -0,0 +1,878 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Block\Wiki;
use Esun\Wiki\Model\Category;
use Esun\Wiki\Model\CategoryFactory;
use Esun\Wiki\Model\Homepage;
use Esun\Wiki\Model\HomepageFactory;
use Esun\Wiki\Model\ResourceModel\Category\Collection;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Esun\Wiki\Model\ResourceModel\Homepage\CollectionFactory as HomepageCollectionFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Block\Product\ImageBuilder;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Pricing\Price\FinalPrice;
use Magento\Catalog\Pricing\Price\RegularPrice;
use Magento\Checkout\Helper\Cart as CartHelper;
use Magento\Cms\Model\Template\FilterProvider;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\UrlInterface;
use Magento\Framework\Url\Helper\Data as UrlHelper;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Model\ScopeInterface;
class View extends Template implements IdentityInterface
{
private const XML_PATH_BANNER_IMAGE = 'esun_wiki/appearance/banner_image';
private const BANNER_MEDIA_PATH = 'esun/wiki/banner/';
private ?Collection $categories = null;
private ?Category $currentCategory = null;
/**
* @var array<int, Category>|null
*/
private ?array $categoryMap = null;
/**
* @var mixed[]|null
*/
private ?array $categoryTree = null;
private ?string $processedContent = null;
/**
* @var mixed[]
*/
private array $tooltips = [];
private int $tooltipCounter = 0;
/**
* @var Product[]
*/
private array $tooltipProducts = [];
/**
* @var mixed[]|null
*/
private ?array $anchors = null;
/**
* @var Category[]|null
*/
private ?array $searchResults = null;
/**
* @var Category[]|null
*/
private ?array $navigationCategories = null;
public function __construct(
Context $context,
private readonly CollectionFactory $collectionFactory,
private readonly CategoryFactory $categoryFactory,
private readonly FilterProvider $filterProvider,
private readonly ProductRepositoryInterface $productRepository,
private readonly ImageBuilder $imageBuilder,
private readonly PriceCurrencyInterface $priceCurrency,
private readonly CartHelper $cartHelper,
private readonly UrlHelper $urlHelper,
private readonly HomepageFactory $homepageFactory,
private readonly HomepageCollectionFactory $homepageCollectionFactory,
array $data = []
) {
parent::__construct($context, $data);
}
protected function _prepareLayout(): self
{
parent::_prepareLayout();
if ($this->hasSearchQuery()) {
$this->pageConfig->getTitle()->set((string) __('Esun Wiki'));
return $this;
}
$category = $this->getCurrentCategory();
if (!$category) {
$this->pageConfig->getTitle()->set((string) __('Esun Wiki'));
return $this;
}
$categoryTitle = (string) $category->getData('title');
$metaTitle = trim((string) $category->getData('meta_title'));
$this->pageConfig->getTitle()->set($categoryTitle);
$this->pageConfig->setMetaTitle($metaTitle !== '' ? $metaTitle : $categoryTitle);
$metaDescription = trim((string) $category->getData('meta_description'));
if ($metaDescription !== '') {
$this->pageConfig->setDescription($metaDescription);
}
$metaKeywords = trim((string) $category->getData('meta_keywords'));
if ($metaKeywords !== '') {
$this->pageConfig->setKeywords($metaKeywords);
}
return $this;
}
public function getWikiHomeUrl(): string
{
return $this->getUrl('wiki/index/index');
}
public function getSearchUrl(): string
{
return $this->getUrl('wiki/index/index');
}
public function getCategoryUrl(Category $category): string
{
$customPath = trim((string) $category->getData('custom_url_path'), '/');
if ($customPath !== '') {
return rtrim($this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_LINK), '/')
. '/' . $customPath;
}
return $this->getUrl('wiki/index/view', ['slug' => (string) $category->getData('slug')]);
}
public function getHeroBackgroundUrl(): string
{
$image = ltrim(trim((string) $this->_scopeConfig->getValue(
self::XML_PATH_BANNER_IMAGE,
ScopeInterface::SCOPE_STORE
)), '/');
if ($image !== '') {
return $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA)
. self::BANNER_MEDIA_PATH
. $image;
}
return $this->getViewFileUrl('Magento_Theme::images/wiki_top_banner.png');
}
public function getSearchQuery(): string
{
return trim((string) $this->getRequest()->getParam('q'));
}
public function hasSearchQuery(): bool
{
return $this->getSearchQuery() !== '';
}
/**
* @return Category[]
*/
public function getSearchResults(): array
{
if ($this->searchResults !== null) {
return $this->searchResults;
}
$query = $this->getSearchQuery();
if ($query === '') {
$this->searchResults = [];
return $this->searchResults;
}
$collection = $this->collectionFactory->create()
->addActiveFilter()
->addStoreFilter($this->getCurrentStoreId())
->addFieldToFilter(
['title', 'slug', 'summary', 'content'],
[
['like' => '%' . $query . '%'],
['like' => '%' . $query . '%'],
['like' => '%' . $query . '%'],
['like' => '%' . $query . '%'],
]
)
->addTreeOrder();
$this->searchResults = [];
foreach ($collection as $category) {
if (!$this->isCategoryClickable($category)) {
continue;
}
$this->searchResults[] = $category;
if (count($this->searchResults) >= 20) {
break;
}
}
return $this->searchResults;
}
public function getSearchSnippet(Category $category): string
{
$text = trim(strip_tags((string) $category->getData('summary')));
if ($text === '') {
$text = trim(strip_tags((string) $category->getData('content')));
}
if ($text === '') {
return (string) __('Open this wiki category to view details.');
}
return $this->truncate($text, 180);
}
public function getCurrentCategory(): ?Category
{
if ($this->currentCategory !== null) {
return $this->currentCategory->getId() ? $this->currentCategory : null;
}
if ($this->isHomepageRequest()) {
$homepage = $this->homepageCollectionFactory->create()
->setPageSize(1)
->getFirstItem();
$this->currentCategory = $homepage->getId()
? $homepage
: $this->homepageFactory->create();
return $this->currentCategory->getId() ? $this->currentCategory : null;
}
$category = null;
$id = (int) $this->getRequest()->getParam('id');
$slug = trim((string) $this->getRequest()->getParam('slug'));
if ($id > 0) {
$candidate = $this->collectionFactory->create()
->addActiveFilter()
->addStoreFilter($this->getCurrentStoreId())
->addFieldToFilter('category_id', $id)
->setPageSize(1)
->getFirstItem();
if ($candidate->getId() && $this->isCategoryClickable($candidate)) {
$category = $candidate;
}
}
if ($category === null && $slug !== '') {
$collection = $this->collectionFactory->create()
->addActiveFilter()
->addStoreFilter($this->getCurrentStoreId())
->addFieldToFilter('slug', $slug)
->setPageSize(1);
$category = $collection->getFirstItem();
if (!$category->getId() || !$this->isCategoryClickable($category)) {
$category = null;
}
}
if ($category === null) {
$firstClickableCategory = null;
foreach ($this->getCategories() as $candidate) {
if (!$this->isCategoryClickable($candidate)) {
continue;
}
$firstClickableCategory ??= $candidate;
if (trim((string) $candidate->getData('content')) !== '') {
$category = $candidate;
break;
}
}
$category ??= $firstClickableCategory;
}
$this->currentCategory = $category ?: $this->categoryFactory->create();
return $this->currentCategory->getId() ? $this->currentCategory : null;
}
public function isHomepage(): bool
{
return $this->getCurrentCategory() instanceof Homepage;
}
/**
* @return mixed[]
*/
public function getCategoryTree(): array
{
if ($this->categoryTree !== null) {
return $this->categoryTree;
}
$activeIds = [];
foreach ($this->getCategories() as $category) {
$activeIds[(int) $category->getId()] = true;
}
$childrenByParent = [];
foreach ($this->getCategories() as $category) {
$parentId = (int) $category->getData('parent_id');
if ($parentId > 0 && !isset($activeIds[$parentId])) {
$parentId = 0;
}
$childrenByParent[$parentId][] = $category;
}
$this->categoryTree = $this->buildTree($childrenByParent, 0);
return $this->categoryTree;
}
public function isCurrent(Category $category): bool
{
$current = $this->getCurrentCategory();
return $current instanceof Category
&& !($current instanceof Homepage)
&& (int) $current->getId() === (int) $category->getId();
}
public function isInCurrentPath(Category $category): bool
{
$current = $this->getCurrentCategory();
if (!$current) {
return false;
}
return isset($this->getCurrentPathIds()[(int) $category->getId()]);
}
public function isCategoryOpenByDefault(Category $category): bool
{
return $category->isOpenByDefault();
}
public function isCategoryClickable(Category $category): bool
{
return $category->isClickable();
}
public function getCategoryLogoUrl(Category $category): string
{
$path = trim((string) $category->getData('logo_path'));
if ($path === '') {
return '';
}
return rtrim($this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA), '/')
. '/' . ltrim($path, '/');
}
/**
* @return Category[]
*/
public function getBreadcrumbItems(): array
{
$current = $this->getCurrentCategory();
if (!$current || $current instanceof Homepage) {
return [];
}
$items = [$current];
$map = $this->getCategoryMap();
$parentId = (int) $current->getData('parent_id');
while ($parentId > 0 && isset($map[$parentId]) && count($items) < 20) {
array_unshift($items, $map[$parentId]);
$parentId = (int) $map[$parentId]->getData('parent_id');
}
return $items;
}
public function getPreviousCategory(): ?Category
{
return $this->getSiblingNavigationCategory(-1);
}
public function getNextCategory(): ?Category
{
return $this->getSiblingNavigationCategory(1);
}
public function getProcessedContent(): string
{
$this->prepareContent();
return $this->processedContent ?? '';
}
/**
* @return array<int, array{id:string,label:string,level:int}>
*/
public function getAnchors(): array
{
$this->prepareContent();
return $this->anchors ?? [];
}
/**
* @return mixed[]
*/
public function getTooltips(): array
{
$this->prepareContent();
return $this->tooltips;
}
/**
* @return string[]
*/
public function getIdentities(): array
{
$this->prepareContent();
$identities = [];
$current = $this->getCurrentCategory();
if ($current instanceof IdentityInterface) {
$identities = array_merge($identities, $current->getIdentities());
}
foreach ($this->tooltipProducts as $product) {
$identities = array_merge($identities, $product->getIdentities());
}
return array_values(array_unique($identities));
}
private function getSiblingNavigationCategory(int $offset): ?Category
{
$current = $this->getCurrentCategory();
if (!$current || $current instanceof Homepage) {
return null;
}
foreach ($this->getNavigationCategories() as $index => $category) {
if ((int) $category->getId() !== (int) $current->getId()) {
continue;
}
return $this->getNavigationCategories()[$index + $offset] ?? null;
}
return null;
}
/**
* @return Category[]
*/
private function getNavigationCategories(): array
{
if ($this->navigationCategories !== null) {
return $this->navigationCategories;
}
$this->navigationCategories = [];
$this->appendNavigationCategories($this->getCategoryTree(), $this->navigationCategories);
return $this->navigationCategories;
}
private function getCategories(): Collection
{
if ($this->categories === null) {
$this->categories = $this->collectionFactory->create()
->addActiveFilter()
->addStoreFilter($this->getCurrentStoreId())
->addTreeOrder();
}
return $this->categories;
}
private function getCurrentStoreId(): int
{
return (int) $this->_storeManager->getStore()->getId();
}
private function isHomepageRequest(): bool
{
return $this->getRequest()->getFullActionName() === 'wiki_index_index'
&& !$this->hasSearchQuery();
}
/**
* @param array<int, Category[]> $childrenByParent
* @return mixed[]
*/
private function buildTree(array $childrenByParent, int $parentId): array
{
$tree = [];
foreach ($childrenByParent[$parentId] ?? [] as $category) {
$tree[] = [
'category' => $category,
'children' => $this->buildTree($childrenByParent, (int) $category->getId()),
];
}
return $tree;
}
/**
* @param mixed[] $nodes
* @param Category[] $categories
*/
private function appendNavigationCategories(array $nodes, array &$categories): void
{
foreach ($nodes as $node) {
if ($this->isCategoryClickable($node['category'])) {
$categories[] = $node['category'];
}
$this->appendNavigationCategories($node['children'], $categories);
}
}
/**
* @return array<int, Category>
*/
private function getCategoryMap(): array
{
if ($this->categoryMap === null) {
$this->categoryMap = [];
foreach ($this->getCategories() as $category) {
$this->categoryMap[(int) $category->getId()] = $category;
}
}
return $this->categoryMap;
}
/**
* @return array<int, bool>
*/
private function getCurrentPathIds(): array
{
$ids = [];
foreach ($this->getBreadcrumbItems() as $category) {
$ids[(int) $category->getId()] = true;
}
return $ids;
}
private function prepareContent(): void
{
if ($this->processedContent !== null && $this->anchors !== null) {
return;
}
$current = $this->getCurrentCategory();
$rawContent = $current ? (string) $current->getData('content') : '';
$preparedContent = trim($this->replaceTooltipDirectives($rawContent));
$html = $preparedContent;
if ($html !== '') {
try {
$html = $this->filterProvider->getPageFilter()->filter($html);
} catch (\Throwable) {
$html = $preparedContent;
}
}
if (trim($html) === '') {
$message = $current instanceof Homepage
? __('This wiki homepage does not have content yet. Add content from the Magento admin.')
: __('This wiki category does not have content yet. Add content from the Magento admin.');
$html = '<p>' . $this->escapeHtml($message) . '</p>';
}
$anchors = [];
$usedIds = [];
$index = 0;
$html = (string) preg_replace_callback(
'/<h([1-2])([^>]*)>(.*?)<\/h\1>/is',
function (array $matches) use (&$anchors, &$usedIds, &$index): string {
$level = (int) $matches[1];
$attributes = (string) $matches[2];
$innerHtml = (string) $matches[3];
$label = trim(html_entity_decode(strip_tags($innerHtml), ENT_QUOTES, 'UTF-8'));
if ($label === '') {
return $matches[0];
}
if (preg_match('/\sid=(["\'])(.*?)\1/i', $attributes, $idMatches)) {
$id = $this->uniqueAnchorId((string) $idMatches[2], $usedIds);
$attributes = str_replace((string) $idMatches[0], ' id="' . $id . '"', $attributes);
} else {
$id = $this->uniqueAnchorId($this->createAnchorId($label, ++$index), $usedIds);
$attributes = rtrim($attributes) . ' id="' . $id . '"';
}
$anchors[] = [
'id' => $id,
'label' => $label,
'level' => $level,
];
return '<h' . $level . $attributes . '>' . $innerHtml . '</h' . $level . '>';
},
$html
);
$this->processedContent = $html;
$this->anchors = $anchors;
}
private function replaceTooltipDirectives(string $content): string
{
return (string) preg_replace_callback(
'/\{\{wiki_(product|term)\s+([^{}]*)\}\}/i',
function (array $matches): string {
$type = strtolower((string) $matches[1]);
$attributes = $this->parseDirectiveAttributes((string) $matches[2]);
return $type === 'product'
? $this->createProductTooltip($attributes)
: $this->createTermTooltip($attributes);
},
$content
);
}
/**
* @return array<string, string>
*/
private function parseDirectiveAttributes(string $source): array
{
$attributes = [];
preg_match_all(
'/([a-z_][a-z0-9_-]*)\s*=\s*(["\'])(.*?)\2/is',
$source,
$matches,
PREG_SET_ORDER
);
foreach ($matches as $match) {
$attributes[strtolower((string) $match[1])] = html_entity_decode(
(string) $match[3],
ENT_QUOTES | ENT_HTML5,
'UTF-8'
);
}
return $attributes;
}
/**
* @param array<string, string> $attributes
*/
private function createProductTooltip(array $attributes): string
{
$sku = trim($attributes['sku'] ?? '');
$fallbackLabel = trim($attributes['label'] ?? $sku);
if ($sku === '') {
return $this->escapeHtml($fallbackLabel);
}
try {
$storeId = (int) $this->_storeManager->getStore()->getId();
$product = $this->productRepository->get($sku, false, $storeId);
if (!$product->getId() || (int) $product->getStatus() !== Status::STATUS_ENABLED) {
return $this->escapeHtml($fallbackLabel);
}
} catch (\Throwable) {
return $this->escapeHtml($fallbackLabel);
}
$id = $this->nextTooltipId();
$label = $fallbackLabel !== '' ? $fallbackLabel : (string) $product->getName();
$finalPrice = $this->getPriceValue($product, FinalPrice::PRICE_CODE);
$regularPrice = $this->getPriceValue($product, RegularPrice::PRICE_CODE);
$isSaleable = (bool) $product->isSaleable();
$canAddToCart = $isSaleable
&& (bool) $product->getTypeInstance()->isPossibleBuyFromList($product);
$this->tooltips[] = [
'id' => $id,
'type' => 'product',
'sku' => (string) $product->getSku(),
'name' => (string) $product->getName(),
'product_url' => (string) $product->getProductUrl(),
'image_url' => $this->getProductImageUrl($product),
'final_price' => $this->formatPrice($finalPrice),
'regular_price' => $regularPrice > $finalPrice ? $this->formatPrice($regularPrice) : '',
'is_saleable' => $isSaleable,
'can_add_to_cart' => $canAddToCart,
'add_to_cart' => $canAddToCart ? $this->getAddToCartData($product) : [],
];
$this->tooltipProducts[(int) $product->getId()] = $product;
return $this->renderTooltipTrigger($id, $label, 'product');
}
/**
* @param array<string, string> $attributes
*/
private function createTermTooltip(array $attributes): string
{
$label = trim($attributes['label'] ?? '');
$title = trim($attributes['title'] ?? $label);
$description = trim($attributes['description'] ?? '');
$imageUrl = $this->resolveTermImageUrl(trim($attributes['image'] ?? ''));
if ($label === '' || ($title === '' && $description === '')) {
return $this->escapeHtml($label);
}
$id = $this->nextTooltipId();
$this->tooltips[] = [
'id' => $id,
'type' => 'term',
'title' => $title,
'description' => $description,
'image_url' => $imageUrl,
'image_alt' => trim($attributes['image_alt'] ?? $title),
'link_label' => trim($attributes['link_label'] ?? ''),
'link_url' => trim($attributes['link_url'] ?? ''),
];
return $this->renderTooltipTrigger($id, $label, 'term');
}
private function resolveTermImageUrl(string $image): string
{
if ($image === '') {
return '';
}
if (preg_match('#^(?:https?:)?//#i', $image) || str_starts_with($image, '/')) {
return $image;
}
$image = ltrim($image, '/');
if (str_starts_with($image, 'media/')) {
$image = substr($image, strlen('media/'));
}
return rtrim(
$this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA),
'/'
) . '/' . $image;
}
private function nextTooltipId(): string
{
$this->tooltipCounter++;
return 'esun-wiki-tooltip-' . $this->tooltipCounter;
}
private function renderTooltipTrigger(string $id, string $label, string $type): string
{
return sprintf(
'<button type="button" class="esun-wiki-tip-trigger is-%1$s" data-wiki-tip="%2$s" aria-controls="%2$s" aria-expanded="false">%3$s</button>',
$this->escapeHtmlAttr($type),
$this->escapeHtmlAttr($id),
$this->escapeHtml($label)
);
}
private function getProductImageUrl(Product $product): string
{
try {
return (string) $this->imageBuilder
->create($product, 'category_page_grid')
->getImageUrl();
} catch (\Throwable) {
return '';
}
}
private function getPriceValue(Product $product, string $priceCode): float
{
try {
return (float) $product->getPriceInfo()
->getPrice($priceCode)
->getAmount()
->getValue();
} catch (\Throwable) {
return (float) $product->getFinalPrice();
}
}
private function formatPrice(float $price): string
{
return $this->priceCurrency->format(
$price,
false,
PriceCurrencyInterface::DEFAULT_PRECISION,
$this->_storeManager->getStore()
);
}
/**
* @return array{action:string,product:int,uenc:string}
*/
private function getAddToCartData(Product $product): array
{
$action = $this->cartHelper->getAddUrl($product, ['_escape' => false]);
return [
'action' => $action,
'product' => (int) $product->getId(),
ActionInterface::PARAM_NAME_URL_ENCODED => $this->urlHelper->getEncodedUrl($action),
];
}
/**
* @param array<string, bool> $usedIds
*/
private function uniqueAnchorId(string $id, array &$usedIds): string
{
$base = $id !== '' ? $id : 'section';
$candidate = $base;
$counter = 2;
while (isset($usedIds[$candidate])) {
$candidate = $base . '-' . $counter;
$counter++;
}
$usedIds[$candidate] = true;
return $candidate;
}
private function createAnchorId(string $label, int $index): string
{
$id = strtolower(trim($label));
$id = (string) preg_replace('/[^a-z0-9]+/', '-', $id);
$id = trim($id, '-');
return $id !== '' ? $id : 'section-' . $index;
}
private function truncate(string $text, int $limit): string
{
$text = preg_replace('/\s+/', ' ', trim($text)) ?: '';
if (function_exists('mb_strlen') && function_exists('mb_substr')) {
if (mb_strlen($text) <= $limit) {
return $text;
}
return rtrim(mb_substr($text, 0, $limit - 1)) . '...';
}
if (strlen($text) <= $limit) {
return $text;
}
return rtrim(substr($text, 0, $limit - 1)) . '...';
}
}
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
use Esun\ImageManager\Model\MediaUploader;
use Esun\Wiki\Model\CategoryFactory;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Exception\LocalizedException;
class Delete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::categories_delete';
public function __construct(
Action\Context $context,
private readonly CategoryFactory $categoryFactory,
private readonly CollectionFactory $collectionFactory,
private readonly MediaUploader $mediaUploader
) {
parent::__construct($context);
}
public function execute()
{
try {
$category = $this->categoryFactory->create()->load((int) $this->getRequest()->getParam('id'));
if (!$category->getId()) {
throw new LocalizedException(__('The wiki category no longer exists.'));
}
$childrenCount = $this->collectionFactory->create()
->addFieldToFilter('parent_id', (int) $category->getId())
->getSize();
if ($childrenCount > 0) {
throw new LocalizedException(
__('This wiki category contains %1 child category(s). Move or delete them first.', $childrenCount)
);
}
$logoPath = (string) $category->getData('logo_path');
$category->delete();
if ($logoPath !== '') {
$this->mediaUploader->delete($logoPath);
}
$this->messageManager->addSuccessMessage(__('The wiki category has been deleted.'));
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
}
return $this->resultRedirectFactory->create()->setPath('esun_wiki/category/index');
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
use Esun\Wiki\Model\CategoryFactory;
use Magento\Backend\App\Action;
use Magento\Framework\View\Result\PageFactory;
class Edit extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::categories_save';
public function __construct(
Action\Context $context,
private readonly PageFactory $pageFactory,
private readonly CategoryFactory $categoryFactory
) {
parent::__construct($context);
}
public function execute()
{
$id = (int) $this->getRequest()->getParam('id');
if ($id > 0 && !$this->categoryFactory->create()->load($id)->getId()) {
$this->messageManager->addErrorMessage(__('The wiki category no longer exists.'));
return $this->resultRedirectFactory->create()->setPath('esun_wiki/category/index');
}
$page = $this->pageFactory->create();
$page->getConfig()->getTitle()->prepend($id ? __('Edit Wiki Category') : __('New Wiki Category'));
return $page;
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
use Magento\Backend\App\Action;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::categories';
public function __construct(
Action\Context $context,
private readonly PageFactory $pageFactory
) {
parent::__construct($context);
}
public function execute()
{
$page = $this->pageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Wiki Knowledge Base'));
return $page;
}
}
@@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
class NewAction extends Edit
{
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
use Esun\MultiLocaleTranslation\Model\Queue\SelectionRegistry;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Ui\Component\MassAction\Filter;
class PrepareTranslation extends Action implements HttpPostActionInterface
{
public const ADMIN_RESOURCE = 'Esun_MultiLocaleTranslation::queue_add';
public function __construct(
Action\Context $context,
private readonly SelectionRegistry $selectionRegistry,
private readonly Filter $filter,
private readonly CollectionFactory $collectionFactory
) {
parent::__construct($context);
}
public function execute(): Redirect
{
try {
if (!$this->_authorization->isAllowed('Esun_MultiLocaleTranslation::translate_wiki')) {
throw new \InvalidArgumentException((string) __('You are not allowed to translate Wiki content.'));
}
$collection = $this->filter->getCollection($this->collectionFactory->create());
$categoryIds = array_values(array_unique(array_map('intval', $collection->getAllIds())));
if ($categoryIds === []) {
throw new \InvalidArgumentException((string) __('Select at least one Wiki category.'));
}
$token = $this->selectionRegistry->save('wiki_category', $categoryIds);
return $this->resultRedirectFactory->create()->setPath(
'localetranslate/queue/new',
['token' => $token]
);
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
return $this->resultRedirectFactory->create()->setPath('esun_wiki/category/index');
}
}
}
@@ -0,0 +1,268 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Category;
use Esun\ImageManager\Model\MediaUploader;
use Esun\Wiki\Model\CategoryFactory;
use Esun\Wiki\Model\ResourceModel\Category as CategoryResource;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\LocalizedException;
use Magento\Store\Model\StoreManagerInterface;
class Save extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::categories_save';
public function __construct(
Action\Context $context,
private readonly CategoryFactory $categoryFactory,
private readonly CategoryResource $categoryResource,
private readonly CollectionFactory $collectionFactory,
private readonly MediaUploader $mediaUploader,
private readonly StoreManagerInterface $storeManager,
private readonly ResourceConnection $resourceConnection,
private readonly TypeListInterface $cacheTypeList
) {
parent::__construct($context);
}
public function execute()
{
$id = (int) $this->getRequest()->getParam('category_id');
$redirect = $this->resultRedirectFactory->create();
$uploadedLogo = null;
try {
$category = $this->categoryFactory->create();
if ($id > 0) {
$category->load($id);
if (!$category->getId()) {
throw new LocalizedException(__('The wiki category no longer exists.'));
}
}
$this->assertNavigationSettingsSchema();
$title = trim((string) $this->getRequest()->getParam('title'));
$slug = $this->normalizeSlug((string) $this->getRequest()->getParam('slug'));
$customUrlPath = $this->normalizeCustomUrlPath(
(string) $this->getRequest()->getParam('custom_url_path')
);
$parentId = (int) $this->getRequest()->getParam('parent_id');
$parentId = $parentId > 0 ? $parentId : null;
$storeIds = $this->normalizeStoreIds((array) $this->getRequest()->getParam('store_ids', []));
if ($title === '') {
throw new LocalizedException(__('Title is required.'));
}
if ($slug === '') {
$slug = $this->normalizeSlug($title);
}
if ($slug === '') {
throw new LocalizedException(__('Slug is required.'));
}
$this->assertUniqueSlug($slug, $id);
$this->assertUniqueCustomUrlPath($customUrlPath, $id);
$this->assertValidParent($parentId, $id);
if ($this->getRequest()->getParam('show_download_center') === '1'
&& ($this->getRequest()->getParam('is_active') === '0'
|| $this->getRequest()->getParam('is_clickable') === '0')
) {
throw new LocalizedException(
__('The download center page must be enabled and allow opening its content.')
);
}
if ($this->getRequest()->getParam('show_parameter_comparison') === '1'
&& ($this->getRequest()->getParam('is_active') === '0'
|| $this->getRequest()->getParam('is_clickable') === '0')
) {
throw new LocalizedException(
__('The parameter comparison page must be enabled and allow opening its content.')
);
}
$oldLogoPath = (string) $category->getData('logo_path');
$logoPath = $oldLogoPath;
$uploadedLogo = $this->mediaUploader->save('logo');
if ($uploadedLogo !== null) {
$logoPath = $uploadedLogo;
} elseif ($this->getRequest()->getParam('delete_logo')) {
$logoPath = '';
}
$category->addData([
'parent_id' => $parentId,
'title' => $title,
'slug' => $slug,
'custom_url_path' => $customUrlPath !== '' ? $customUrlPath : null,
'logo_path' => $logoPath,
'summary' => trim((string) $this->getRequest()->getParam('summary')),
'content' => (string) $this->getRequest()->getParam('content'),
'meta_title' => trim((string) $this->getRequest()->getParam('meta_title')),
'meta_description' => trim((string) $this->getRequest()->getParam('meta_description')),
'meta_keywords' => trim((string) $this->getRequest()->getParam('meta_keywords')),
'is_active' => $this->getRequest()->getParam('is_active') === '0' ? 0 : 1,
'is_default_open' => (string) $this->getRequest()->getParam('is_default_open') === '1' ? 1 : 0,
'is_clickable' => (string) $this->getRequest()->getParam('is_clickable') === '0' ? 0 : 1,
'show_download_center' => (string) $this->getRequest()->getParam('show_download_center') === '1' ? 1 : 0,
'show_parameter_comparison' => (string) $this->getRequest()->getParam('show_parameter_comparison') === '1' ? 1 : 0,
'sort_order' => (int) $this->getRequest()->getParam('sort_order'),
'store_ids' => $storeIds,
])->save();
if ((int) $category->getData('show_download_center') === 1) {
$this->categoryResource->clearOtherDownloadCenters((int) $category->getId());
}
if ((int) $category->getData('show_parameter_comparison') === 1) {
$this->categoryResource->clearOtherParameterComparisons((int) $category->getId());
}
$this->cacheTypeList->cleanType('block_html');
$this->cacheTypeList->cleanType('full_page');
if ($oldLogoPath !== '' && $oldLogoPath !== $logoPath) {
$this->mediaUploader->delete($oldLogoPath);
}
$this->messageManager->addSuccessMessage(__('The wiki category has been saved.'));
if ($this->getRequest()->getParam('back')) {
return $redirect->setPath('esun_wiki/category/edit', ['id' => (int) $category->getId()]);
}
return $redirect->setPath('esun_wiki/category/index');
} catch (\Throwable $exception) {
if ($uploadedLogo !== null) {
$this->mediaUploader->delete($uploadedLogo);
}
$this->messageManager->addErrorMessage($exception->getMessage());
return $redirect->setPath(
$id ? 'esun_wiki/category/edit' : 'esun_wiki/category/new',
$id ? ['id' => $id] : []
);
}
}
/**
* @param mixed[] $requestedStoreIds
* @return int[]
*/
private function normalizeStoreIds(array $requestedStoreIds): array
{
$storeIds = array_values(array_unique(array_filter(
array_map('intval', $requestedStoreIds),
static fn (int $storeId): bool => $storeId >= 0
)));
if (in_array(0, $storeIds, true)) {
return [0];
}
$validStoreIds = array_map('intval', array_keys($this->storeManager->getStores(false)));
$storeIds = array_values(array_intersect($storeIds, $validStoreIds));
if (!$storeIds) {
throw new LocalizedException(__('Select at least one Store View.'));
}
return $storeIds;
}
private function normalizeSlug(string $slug): string
{
$slug = strtolower(trim($slug));
$slug = (string) preg_replace('/[^a-z0-9_-]+/', '-', $slug);
return trim($slug, '-_');
}
private function assertUniqueSlug(string $slug, int $currentId): void
{
$collection = $this->collectionFactory->create()
->addFieldToFilter('slug', $slug);
if ($currentId > 0) {
$collection->addFieldToFilter('category_id', ['neq' => $currentId]);
}
if ($collection->getSize() > 0) {
throw new LocalizedException(__('The slug "%1" is already used by another wiki category.', $slug));
}
}
private function normalizeCustomUrlPath(string $path): string
{
$parsedPath = parse_url(trim($path), PHP_URL_PATH);
$path = strtolower(trim(is_string($parsedPath) ? $parsedPath : '', '/'));
$path = (string) preg_replace('#[^a-z0-9/_-]+#', '-', $path);
$path = (string) preg_replace('#/+#', '/', $path);
return trim($path, '-_/');
}
private function assertUniqueCustomUrlPath(string $path, int $currentId): void
{
if ($path === '') {
return;
}
$collection = $this->collectionFactory->create()
->addFieldToFilter('custom_url_path', $path);
if ($currentId > 0) {
$collection->addFieldToFilter('category_id', ['neq' => $currentId]);
}
if ($collection->getSize() > 0) {
throw new LocalizedException(__('The custom URL "%1" is already used by another wiki category.', $path));
}
}
private function assertValidParent(?int $parentId, int $currentId): void
{
if ($parentId === null || $currentId === 0) {
return;
}
if ($parentId === $currentId) {
throw new LocalizedException(__('A wiki category cannot be its own parent.'));
}
$categories = [];
foreach ($this->collectionFactory->create() as $category) {
$categories[(int) $category->getId()] = (int) $category->getData('parent_id');
}
$cursor = $parentId;
while ($cursor > 0) {
if ($cursor === $currentId) {
throw new LocalizedException(__('A child category cannot be selected as the parent.'));
}
$cursor = $categories[$cursor] ?? 0;
}
}
private function assertNavigationSettingsSchema(): void
{
$table = $this->resourceConnection->getTableName('esun_wiki_category');
$columns = $this->resourceConnection->getConnection()->describeTable($table);
if (!isset(
$columns['is_default_open'],
$columns['is_clickable'],
$columns['show_download_center'],
$columns['show_parameter_comparison'],
$columns['meta_title'],
$columns['meta_description'],
$columns['meta_keywords'],
$columns['custom_url_path']
)) {
throw new LocalizedException(__(
'The Wiki page settings are not installed. Run "bin/magento setup:upgrade" and try again.'
));
}
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Homepage;
use Magento\Backend\App\Action;
use Magento\Framework\View\Result\PageFactory;
class Edit extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::homepage';
public function __construct(
Action\Context $context,
private readonly PageFactory $pageFactory
) {
parent::__construct($context);
}
public function execute()
{
$page = $this->pageFactory->create();
$page->getConfig()->getTitle()->prepend(__('Edit Wiki Homepage'));
return $page;
}
}
@@ -0,0 +1,91 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Adminhtml\Homepage;
use Esun\Wiki\Model\HomepageFactory;
use Esun\Wiki\Model\ResourceModel\Homepage as HomepageResource;
use Esun\Wiki\Model\ResourceModel\Homepage\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\App\Cache\TypeListInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Exception\LocalizedException;
class Save extends Action
{
public const ADMIN_RESOURCE = 'Esun_Wiki::homepage';
public function __construct(
Action\Context $context,
private readonly HomepageFactory $homepageFactory,
private readonly HomepageResource $homepageResource,
private readonly CollectionFactory $collectionFactory,
private readonly ResourceConnection $resourceConnection,
private readonly TypeListInterface $cacheTypeList
) {
parent::__construct($context);
}
public function execute()
{
$redirect = $this->resultRedirectFactory->create();
try {
$this->assertSchema();
$title = trim((string) $this->getRequest()->getParam('title'));
if ($title === '') {
throw new LocalizedException(__('Title is required.'));
}
$homepage = $this->collectionFactory->create()
->setPageSize(1)
->getFirstItem();
if (!$homepage->getId()) {
$homepage = $this->homepageFactory->create();
}
$homepage->addData([
'title' => $title,
'content' => (string) $this->getRequest()->getParam('content'),
'meta_title' => trim((string) $this->getRequest()->getParam('meta_title')),
'meta_description' => trim((string) $this->getRequest()->getParam('meta_description')),
'meta_keywords' => trim((string) $this->getRequest()->getParam('meta_keywords')),
]);
$this->homepageResource->save($homepage);
$this->cacheTypeList->cleanType('block_html');
$this->cacheTypeList->cleanType('full_page');
$this->messageManager->addSuccessMessage(__('The wiki homepage has been saved.'));
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
}
return $redirect->setPath('esun_wiki/homepage/edit');
}
private function assertSchema(): void
{
$connection = $this->resourceConnection->getConnection();
$table = $this->resourceConnection->getTableName('esun_wiki_homepage');
if (!$connection->isTableExists($table)) {
throw new LocalizedException(__(
'The Wiki homepage is not installed. Run "bin/magento setup:upgrade" and try again.'
));
}
$columns = $connection->describeTable($table);
if (!isset(
$columns['title'],
$columns['content'],
$columns['meta_title'],
$columns['meta_description'],
$columns['meta_keywords']
)) {
throw new LocalizedException(__(
'The Wiki homepage schema is incomplete. Run "bin/magento setup:upgrade" and try again.'
));
}
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Index;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;
class Index implements HttpGetActionInterface
{
public function __construct(private readonly PageFactory $pageFactory)
{
}
public function execute()
{
return $this->pageFactory->create();
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller\Index;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;
class View implements HttpGetActionInterface
{
public function __construct(private readonly PageFactory $pageFactory)
{
}
public function execute()
{
return $this->pageFactory->create();
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Controller;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\App\Action\Forward;
use Magento\Framework\App\ActionFactory;
use Magento\Framework\App\ActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\RouterInterface;
use Magento\Store\Model\StoreManagerInterface;
class Router implements RouterInterface
{
public function __construct(
private readonly ActionFactory $actionFactory,
private readonly CollectionFactory $collectionFactory,
private readonly StoreManagerInterface $storeManager
) {
}
public function match(RequestInterface $request): ?ActionInterface
{
$path = strtolower(trim((string) $request->getPathInfo(), '/'));
if ($path === '') {
return null;
}
$category = $this->collectionFactory->create()
->addActiveFilter()
->addStoreFilter((int) $this->storeManager->getStore()->getId())
->addFieldToFilter('custom_url_path', $path)
->setPageSize(1)
->getFirstItem();
if (!$category->getId() || !$category->isClickable()) {
return null;
}
$request->setModuleName('wiki')
->setControllerName('index')
->setActionName('view')
->setParam('slug', (string) $category->getData('slug'));
return $this->actionFactory->create(Forward::class);
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model;
use Magento\Framework\Model\AbstractModel;
use Esun\Wiki\Model\ResourceModel\Category as CategoryResource;
class Category extends AbstractModel
{
public function isClickable(): bool
{
$value = $this->getData('is_clickable');
return $value === null || $value === '' || (int) $value !== 0;
}
public function isOpenByDefault(): bool
{
return (int) $this->getData('is_default_open') === 1;
}
protected function _construct(): void
{
$this->_init(CategoryResource::class);
}
}
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model\Config\Backend;
use Magento\Config\Model\Config\Backend\Image;
class BannerImage extends Image
{
/**
* @return string[]
*/
protected function _getAllowedExtensions()
{
return ['jpg', 'jpeg', 'gif', 'png', 'webp'];
}
public function afterSave()
{
$result = parent::afterSave();
$this->cleanPageCaches();
return $result;
}
public function afterDelete()
{
$result = parent::afterDelete();
$this->cleanPageCaches();
return $result;
}
private function cleanPageCaches(): void
{
$this->cacheTypeList->cleanType('block_html');
$this->cacheTypeList->cleanType('full_page');
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model;
use Esun\Wiki\Model\ResourceModel\Homepage as HomepageResource;
use Magento\Framework\DataObject\IdentityInterface;
class Homepage extends Category implements IdentityInterface
{
public const CACHE_TAG = 'esun_wiki_homepage';
protected $_cacheTag = self::CACHE_TAG;
protected $_eventPrefix = self::CACHE_TAG;
/**
* @return string[]
*/
public function getIdentities(): array
{
return $this->getId() ? [self::CACHE_TAG . '_' . $this->getId()] : [];
}
protected function _construct(): void
{
$this->_init(HomepageResource::class);
}
}
@@ -0,0 +1,141 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model;
class PrintingParameterClassifier
{
private const BASE_OPTIONS = [
'pla' => 'PLA Base',
'petg' => 'PET(G) Base',
'abs' => 'ABS Base',
'asa' => 'ASA Base',
'pa' => 'PA Base',
'pc' => 'PC Base',
'tpu' => 'TPU Base',
'peba' => 'PEBA Base',
'other' => 'Other',
];
private const APPLICATION_OPTIONS = [
'plus' => 'Plus Series',
'basic' => 'Basic Series',
'high_speed' => 'High Speed Series',
'flexible' => 'Flexible Series',
'high_elasticity' => 'High Elasticity Series',
'recycled' => 'Recycled Series',
'matte' => 'Matte Series',
'silk' => 'Silk Series',
'luminous' => 'Luminous Series',
'sparkle' => 'Sparkle Series',
'bionic' => 'Bionic Series',
'color_change' => 'Color Change Series',
'transparent' => 'Transparent Series',
'carbon_fiber' => 'Carbon Fiber',
'glass_fiber' => 'Glass Fiber',
'lightweight' => 'Lightweight',
'antistatic' => 'Antistatic',
'conductive' => 'Conductive',
'heat_resistant' => 'Heat Resistant',
'flame_retardant' => 'Flame Retardant',
'support' => 'Support Material',
'general_engineering' => 'General Engineering',
'special_engineering' => 'Special Engineering',
'other' => 'Other Series',
];
public function cleanName(string $name): string
{
$name = (string) preg_replace('/[\x{00A0}\x{2000}-\x{200B}\x{202F}\x{205F}\x{3000}]/u', ' ', $name);
return trim((string) preg_replace('/\s+/u', ' ', $name));
}
/**
* @return array{base: string, applications: string[]}
*/
public function classify(string $rawName): array
{
$name = $this->cleanName($rawName);
$base = $this->detectBase($name);
$applications = [];
$this->addWhen($applications, 'plus', str_contains($name, '+'));
$this->addWhen($applications, 'basic', (bool) preg_match('/Basic|PLA-SS|PLA-Lite/i', $name));
$this->addWhen($applications, 'high_speed', (bool) preg_match('/(?:^|[-+ ])(?:HS|HF)(?:$|[-+ (])/i', $name));
$this->addWhen($applications, 'flexible', in_array($base, ['tpu', 'peba'], true)
|| (bool) preg_match('/TPE|Flex/i', $name));
$this->addWhen($applications, 'high_elasticity', $base === 'peba'
|| (bool) preg_match('/^4D(?:-|$)/i', $name));
$this->addWhen($applications, 'recycled', (bool) preg_match('/Revive/i', $name));
$this->addWhen($applications, 'matte', (bool) preg_match('/Matte|^Mate$/i', $name));
$this->addWhen($applications, 'silk', (bool) preg_match('/Silk/i', $name));
$this->addWhen($applications, 'luminous', (bool) preg_match('/Luminous/i', $name));
$this->addWhen($applications, 'sparkle', (bool) preg_match('/Twinkling|Stars/i', $name));
$this->addWhen($applications, 'bionic', (bool) preg_match('/Rock|Marble|Wood|Coffee|Nature/i', $name));
$this->addWhen($applications, 'color_change', (bool) preg_match('/Color Change|Chameleon/i', $name));
$this->addWhen($applications, 'transparent', (bool) preg_match('/Clear|Transparent/i', $name));
$this->addWhen($applications, 'carbon_fiber', (bool) preg_match('/(?:^|[-+])CF(?:$|[-+ ])/i', $name));
$this->addWhen($applications, 'glass_fiber', (bool) preg_match('/(?:^|[-+])(?:GF|GK)(?:$|[-+ ])/i', $name));
$this->addWhen($applications, 'lightweight', (bool) preg_match('/(?:^|-)LW(?:$|\()/i', $name));
$this->addWhen($applications, 'antistatic', (bool) preg_match('/(?:^|-)ESD(?:$|-)/i', $name));
$this->addWhen($applications, 'conductive', (bool) preg_match('/Conduct/i', $name));
$this->addWhen($applications, 'heat_resistant', (bool) preg_match('/(?:^|-)HT(?:$|-)|PEEK|PPS/i', $name));
$this->addWhen($applications, 'flame_retardant', (bool) preg_match('/(?:^|-)FR(?:$|-)/i', $name));
$this->addWhen($applications, 'support', (bool) preg_match('/PVA|HIPS|^Clean$/i', $name));
$this->addWhen($applications, 'general_engineering', in_array($base, ['petg', 'abs', 'asa', 'pa', 'pc'], true));
$this->addWhen($applications, 'special_engineering', (bool) preg_match('/PEEK|PPS/i', $name));
if (!$applications) {
$applications[] = 'other';
}
return ['base' => $base, 'applications' => $applications];
}
public function getBaseOptions(): array
{
return self::BASE_OPTIONS;
}
public function getApplicationOptions(): array
{
return self::APPLICATION_OPTIONS;
}
private function detectBase(string $name): string
{
if (preg_match('/PLA/i', $name)) {
return 'pla';
}
if (preg_match('/PETG|(?:^|[^A-Z])PET(?:[^A-Z]|$)/i', $name)) {
return 'petg';
}
if (preg_match('/ABS/i', $name)) {
return 'abs';
}
if (preg_match('/ASA/i', $name)) {
return 'asa';
}
if (preg_match('/(?:^|[^A-Z])PA(?:12|HT)?(?:[^A-Z]|$)/i', $name)) {
return 'pa';
}
if (preg_match('/(?:^|[^A-Z])PC(?:[^A-Z]|$)/i', $name)) {
return 'pc';
}
if (preg_match('/TPU/i', $name)) {
return 'tpu';
}
if (preg_match('/PEBA/i', $name)) {
return 'peba';
}
return 'other';
}
private function addWhen(array &$applications, string $value, bool $condition): void
{
if ($condition) {
$applications[] = $value;
}
}
}
@@ -0,0 +1,101 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model\ResourceModel;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Category extends AbstractDb
{
protected function _construct(): void
{
$this->_init('esun_wiki_category', 'category_id');
}
/**
* @return int[]
*/
public function lookupStoreIds(int $categoryId): array
{
$select = $this->getConnection()->select()
->from($this->getTable('esun_wiki_category_store'), 'store_id')
->where('category_id = ?', $categoryId);
return array_map('intval', $this->getConnection()->fetchCol($select));
}
public function clearOtherDownloadCenters(int $categoryId): void
{
$this->getConnection()->update(
$this->getMainTable(),
['show_download_center' => 0],
[
'category_id != ?' => $categoryId,
'show_download_center = ?' => 1,
]
);
}
public function clearOtherParameterComparisons(int $categoryId): void
{
$this->getConnection()->update(
$this->getMainTable(),
['show_parameter_comparison' => 0],
[
'category_id != ?' => $categoryId,
'show_parameter_comparison = ?' => 1,
]
);
}
protected function _afterLoad(AbstractModel $object): self
{
if ($object->getId()) {
$object->setData('store_ids', $this->lookupStoreIds((int) $object->getId()));
}
parent::_afterLoad($object);
return $this;
}
protected function _afterSave(AbstractModel $object): self
{
if ($object->hasData('store_ids')) {
$this->saveStoreIds((int) $object->getId(), (array) $object->getData('store_ids'));
}
parent::_afterSave($object);
return $this;
}
/**
* @param int[] $storeIds
*/
private function saveStoreIds(int $categoryId, array $storeIds): void
{
$storeIds = array_values(array_unique(array_map('intval', $storeIds)));
$table = $this->getTable('esun_wiki_category_store');
$connection = $this->getConnection();
$oldStoreIds = $this->lookupStoreIds($categoryId);
$delete = array_diff($oldStoreIds, $storeIds);
if ($delete) {
$connection->delete($table, [
'category_id = ?' => $categoryId,
'store_id IN (?)' => $delete,
]);
}
$insert = array_diff($storeIds, $oldStoreIds);
if ($insert) {
$rows = [];
foreach ($insert as $storeId) {
$rows[] = ['category_id' => $categoryId, 'store_id' => (int) $storeId];
}
$connection->insertMultiple($table, $rows);
}
}
}
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model\ResourceModel\Category;
use Esun\Wiki\Model\Category;
use Esun\Wiki\Model\ResourceModel\Category as CategoryResource;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
private bool $storeFilterApplied = false;
protected function _construct(): void
{
$this->_init(Category::class, CategoryResource::class);
$this->_map['fields']['category_id'] = 'main_table.category_id';
}
public function addActiveFilter(): self
{
return $this->addFieldToFilter('is_active', 1);
}
public function addTreeOrder(): self
{
return $this->setOrder('parent_id', 'ASC')
->setOrder('sort_order', 'ASC')
->setOrder('category_id', 'ASC');
}
public function addStoreFilter(int $storeId, bool $withDefaultStore = true): self
{
if ($this->storeFilterApplied) {
return $this;
}
$storeIds = $withDefaultStore && $storeId !== 0 ? [0, $storeId] : [$storeId];
$this->getSelect()
->join(
['wiki_store' => $this->getTable('esun_wiki_category_store')],
'main_table.category_id = wiki_store.category_id',
[]
)
->where('wiki_store.store_id IN (?)', $storeIds)
->distinct(true);
$this->storeFilterApplied = true;
return $this;
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Homepage extends AbstractDb
{
protected function _construct(): void
{
$this->_init('esun_wiki_homepage', 'homepage_id');
}
}
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Model\ResourceModel\Homepage;
use Esun\Wiki\Model\Homepage;
use Esun\Wiki\Model\ResourceModel\Homepage as HomepageResource;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
protected function _construct(): void
{
$this->_init(Homepage::class, HomepageResource::class);
}
}
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AssignExistingCategoriesToAllStores implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup
) {
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$categoryTable = $this->moduleDataSetup->getTable('esun_wiki_category');
$storeTable = $this->moduleDataSetup->getTable('esun_wiki_category_store');
$connection->startSetup();
$categoryIds = array_map(
'intval',
$connection->fetchCol($connection->select()->from($categoryTable, 'category_id'))
);
if ($categoryIds) {
$rows = array_map(
static fn (int $categoryId): array => ['category_id' => $categoryId, 'store_id' => 0],
$categoryIds
);
$connection->insertOnDuplicate($storeTable, $rows, []);
}
$connection->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [InstallDefaultWikiContent::class];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class ConfigureWikiCustomUrls implements DataPatchInterface
{
private const URLS = [
'material-datasheets' => 'page-filter',
'printing-parameters-download' => 'parameters-download',
];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup
) {
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_wiki_category');
foreach (self::URLS as $slug => $customPath) {
$connection->update(
$table,
['custom_url_path' => $customPath],
['slug = ?' => $slug]
);
}
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class CreateDefaultWikiHomepage implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup
) {
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_wiki_homepage');
$connection->startSetup();
if ((int) $connection->fetchOne($connection->select()->from($table, 'COUNT(*)')) === 0) {
$connection->insert($table, [
'title' => 'eSUN Wiki',
'content' => '',
'meta_title' => '',
'meta_description' => '',
'meta_keywords' => '',
]);
}
$connection->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class EnableDownloadCenterForPrintingParameters implements DataPatchInterface
{
private const TARGET_SLUG = 'printing-parameters-download';
public function __construct(private readonly ModuleDataSetupInterface $moduleDataSetup)
{
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_wiki_category');
$connection->startSetup();
$connection->update($table, ['show_download_center' => 0]);
$connection->update(
$table,
['show_download_center' => 1],
['slug = ?' => self::TARGET_SLUG]
);
$connection->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [AssignExistingCategoriesToAllStores::class];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class EnableExistingCategoriesForContentOpening implements DataPatchInterface
{
public function __construct(private readonly ModuleDataSetupInterface $moduleDataSetup)
{
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_wiki_category');
$this->moduleDataSetup->startSetup();
if ($connection->isTableExists($table)) {
$columns = $connection->describeTable($table);
if (isset($columns['is_clickable'])) {
$connection->update($table, ['is_clickable' => 1]);
}
}
$this->moduleDataSetup->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [InstallDefaultWikiContent::class];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class EnableParameterComparisonForPrintingParameters implements DataPatchInterface
{
private const TARGET_SLUG = 'printing-parameters-download';
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup
) {
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_wiki_category');
$connection->update($table, ['show_parameter_comparison' => 0]);
$connection->update(
$table,
['show_parameter_comparison' => 1],
['slug = ?' => self::TARGET_SLUG]
);
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,163 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Setup\Patch\Data;
use Esun\Wiki\Model\CategoryFactory;
use Esun\Wiki\Model\ResourceModel\Category as CategoryResource;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class InstallDefaultWikiContent implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly CategoryFactory $categoryFactory,
private readonly CategoryResource $categoryResource,
private readonly CollectionFactory $collectionFactory
) {
}
public function apply(): self
{
$this->moduleDataSetup->getConnection()->startSetup();
if ($this->collectionFactory->create()->getSize() > 0) {
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
$industryKnowledgeId = $this->createCategory([
'title' => 'Industry Knowledge',
'slug' => 'industry-knowledge',
'summary' => 'eSUN Wiki industry knowledge base.',
'sort_order' => 10,
]);
$productKnowledgeId = $this->createCategory([
'title' => 'Material & eSUN Product Knowledge',
'slug' => 'material-esun-product-knowledge',
'summary' => 'Material guides, product tips, and application knowledge for eSUN users.',
'sort_order' => 20,
]);
$this->createCategory([
'parent_id' => $industryKnowledgeId,
'title' => 'Overview of 3D Printing',
'slug' => 'overview-of-3d-printing',
'summary' => 'Introduction to various 3D printing technologies: filament, resin, powder, metal and more.',
'content' => $this->overviewContent(),
'sort_order' => 10,
]);
$fdmId = $this->createCategory([
'parent_id' => $productKnowledgeId,
'title' => 'FDM Materials for 3D Printing',
'slug' => 'fdm-materials-for-3d-printing',
'summary' => 'Understand PLA, PETG, ABS and other common FDM/FFF 3D printing materials.',
'content' => $this->fdmContent(),
'sort_order' => 20,
]);
foreach (['PLA', 'PETG(PET)', 'ABS', 'ASA', 'TPU', 'PA', 'PP', 'PC', 'PPS', 'PEBA'] as $index => $title) {
$this->createCategory([
'parent_id' => $fdmId,
'title' => $title,
'slug' => $this->slugify($title),
'summary' => sprintf('%s material quick reference.', $title),
'content' => $this->materialContent($title),
'sort_order' => ($index + 1) * 10,
]);
}
$this->moduleDataSetup->getConnection()->endSetup();
return $this;
}
/**
* @param mixed[] $data
*/
private function createCategory(array $data): int
{
$category = $this->categoryFactory->create();
$category->addData(array_merge([
'parent_id' => null,
'summary' => '',
'content' => '',
'is_active' => 1,
'sort_order' => 0,
], $data));
$this->categoryResource->save($category);
return (int) $category->getId();
}
private function overviewContent(): string
{
return <<<'HTML'
<h2>Introduction to Various 3D Printing Technologies</h2>
<p>3D printing covers several process families including FDM/FFF filament printing, resin printing, powder-based printing, and metal additive manufacturing. Each process has its own material range, accuracy, strength profile, and post-processing workflow.</p>
<h2>How to Choose a Process</h2>
<p>For beginners and daily prototyping, FDM printing is often the easiest entry point. Resin printing is useful for fine details, while powder and metal processes are commonly chosen for industrial production scenarios.</p>
HTML;
}
private function fdmContent(): string
{
return <<<'HTML'
<p><a href="#pla">PLA (Polylactic Acid)</a> is the most popular and widely used thermoplastic filament for FDM/FFF 3D printing. Derived from renewable organic resources such as corn starch and sugarcane, it is a biodegradable bioplastic that offers a perfect balance of printability, affordability, and environmental friendliness.</p>
<p>FDM materials differ in toughness, heat resistance, surface finish, flexibility, and engineering performance. Choosing the right filament starts with the application environment and the level of mechanical stress the part will face.</p>
<figure class="esun-wiki-content-figure">
<img src="{{view url='Magento_Theme::images/background-1.png'}}" alt="eSUN material knowledge">
</figure>
<h2 id="pla">PLA</h2>
<p>PLA is easy to print, has low warping, and is suitable for prototypes, educational models, display pieces, and general-purpose fixtures. It is a strong first choice for new users because it prints well on most desktop FDM printers.</p>
<h2>PETG(PET)</h2>
<p>PETG balances strength, toughness, and chemical resistance. It is often used for functional parts that need more durability than PLA while still remaining approachable to print.</p>
<h2>ABS</h2>
<p>ABS offers better heat resistance and impact strength, but it requires a controlled print environment and ventilation to reduce warping and odor during printing.</p>
<h2>ASA</h2>
<p>ASA is selected for outdoor applications because it has improved UV and weather resistance compared with ABS while maintaining similar engineering properties.</p>
<h2>TPU</h2>
<p>TPU is a flexible material for soft-touch parts, protective covers, grips, seals, and elastic components. Print speed and extrusion control are important for stable TPU printing.</p>
<h2>PA</h2>
<p>PA, commonly known as nylon, provides high toughness and wear resistance. It absorbs moisture easily, so drying and storage are essential before printing.</p>
<h2>PP</h2>
<p>PP is lightweight, fatigue-resistant, and chemically resistant. Bed adhesion and warping control are the key challenges when printing PP.</p>
<h2>PC</h2>
<p>PC offers high strength and temperature resistance for demanding functional parts. It usually requires a high-temperature printer setup.</p>
<h2>PPS</h2>
<p>PPS is an advanced material with excellent chemical and thermal resistance, used in specialized industrial scenarios.</p>
<h2>PEBA</h2>
<p>PEBA is a flexible engineering material with elasticity and resilience, often selected where flexibility and low-temperature performance are required.</p>
HTML;
}
private function materialContent(string $title): string
{
return sprintf(
'<h2>%1$s Overview</h2><p>%1$s is part of the eSUN FDM material knowledge base. Add detailed printing settings, application cases, product recommendations, storage guidance, and troubleshooting content from the Magento admin.</p><h2>Printing Tips</h2><p>Keep material dry, verify nozzle and bed temperatures, and tune print speed according to the product data sheet.</p>',
$title
);
}
private function slugify(string $value): string
{
$value = strtolower(trim($value));
$value = (string) preg_replace('/[^a-z0-9]+/', '-', $value);
return trim($value, '-') ?: 'wiki-category';
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Ui\Component\Listing\Columns\Column;
class Actions extends Column
{
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
private readonly UrlInterface $urlBuilder,
private readonly StoreManagerInterface $storeManager,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource): array
{
if (!isset($dataSource['data']['items'])) {
return $dataSource;
}
$fieldName = (string) $this->getData('name');
foreach ($dataSource['data']['items'] as &$item) {
if (!isset($item['category_id'])) {
continue;
}
$id = (int) $item['category_id'];
$title = (string) ($item['raw_title'] ?? $item['title'] ?? '');
$item[$fieldName]['edit'] = [
'href' => $this->urlBuilder->getUrl('esun_wiki/category/edit', ['id' => $id]),
'label' => __('Edit'),
];
if ((int) ($item['is_clickable'] ?? 1) === 1) {
$item[$fieldName]['preview'] = [
'href' => $this->getPreviewUrl($item),
'label' => __('Preview'),
'target' => '_blank',
];
}
$item[$fieldName]['delete'] = [
'href' => $this->urlBuilder->getUrl('esun_wiki/category/delete', ['id' => $id]),
'label' => __('Delete'),
'confirm' => [
'title' => __('Delete %1', $title),
'message' => __('Delete this wiki category?'),
],
];
}
unset($item);
return $dataSource;
}
/**
* @param mixed[] $item
*/
private function getPreviewUrl(array $item): string
{
$baseUrl = rtrim($this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_LINK), '/');
$customPath = (string) ($item['raw_custom_url_path'] ?? '');
if ($customPath !== '') {
return $baseUrl . '/' . $customPath;
}
return $baseUrl . '/wiki/index/view/slug/' . rawurlencode((string) ($item['slug'] ?? '')) . '/';
}
}
@@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
namespace Esun\Wiki\Ui\DataProvider\Category;
use Esun\Wiki\Model\ResourceModel\Category\CollectionFactory;
use Magento\Framework\Api\Filter;
use Magento\Framework\App\RequestInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;
class ListingDataProvider extends AbstractDataProvider
{
public function __construct(
string $name,
string $primaryFieldName,
string $requestFieldName,
private readonly CollectionFactory $collectionFactory,
RequestInterface $request,
array $meta = [],
array $data = []
) {
$this->collection = $this->collectionFactory->create();
if (!$request->getParam('sorting')) {
$this->collection->addTreeOrder();
}
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
public function addFilter(Filter $filter): void
{
if ($filter->getField() !== 'fulltext') {
parent::addFilter($filter);
return;
}
$value = '%' . (string) $filter->getValue() . '%';
$this->collection->addFieldToFilter(
['title', 'slug', 'custom_url_path', 'summary', 'content'],
[
['like' => $value],
['like' => $value],
['like' => $value],
['like' => $value],
['like' => $value],
]
);
}
public function getData(): array
{
$data = parent::getData();
if (empty($data['items'])) {
return $data;
}
$categoryMap = $this->getCategoryMap();
foreach ($data['items'] as &$item) {
$id = (int) ($item['category_id'] ?? 0);
$parentId = (int) ($item['parent_id'] ?? 0);
$title = (string) ($item['title'] ?? '');
$depth = $this->getDepth($id, $categoryMap);
$item['raw_title'] = $title;
$item['title'] = ($depth > 0 ? str_repeat("\u{00A0}", $depth * 4) . '↳ ' : '') . $title;
$item['parent_title'] = $parentId > 0 && isset($categoryMap[$parentId])
? $categoryMap[$parentId]['title']
: (string) __('Root');
$customPath = trim((string) ($item['custom_url_path'] ?? ''), '/');
$item['raw_custom_url_path'] = $customPath;
$item['custom_url_path'] = $customPath !== '' ? '/' . $customPath : '—';
}
unset($item);
return $data;
}
/**
* @return array<int, array{parent_id:int,title:string}>
*/
private function getCategoryMap(): array
{
$map = [];
foreach ($this->collectionFactory->create() as $category) {
$map[(int) $category->getId()] = [
'parent_id' => (int) $category->getData('parent_id'),
'title' => (string) $category->getData('title'),
];
}
return $map;
}
/**
* @param array<int, array{parent_id:int,title:string}> $categoryMap
*/
private function getDepth(int $id, array $categoryMap): int
{
$depth = 0;
$visited = [];
$parentId = $categoryMap[$id]['parent_id'] ?? 0;
while ($parentId > 0 && isset($categoryMap[$parentId]) && !isset($visited[$parentId]) && $depth < 20) {
$visited[$parentId] = true;
$depth++;
$parentId = $categoryMap[$parentId]['parent_id'];
}
return $depth;
}
}
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Catalog::catalog">
<resource id="Esun_Wiki::root" title="Esun Wiki" sortOrder="88">
<resource id="Esun_Wiki::homepage" title="Manage Wiki Homepage" sortOrder="5"/>
<resource id="Esun_Wiki::categories" title="Manage Wiki Categories" sortOrder="10">
<resource id="Esun_Wiki::categories_save" title="Save Wiki Categories" sortOrder="10"/>
<resource id="Esun_Wiki::categories_delete" title="Delete Wiki Categories" sortOrder="20"/>
</resource>
</resource>
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Esun_Wiki::config" title="Esun Wiki Configuration" sortOrder="90"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Esun_Wiki::root" title="Wiki Knowledge Base" module="Esun_Wiki"
sortOrder="60" parent="Esun_ImageManager::esun" resource="Esun_Wiki::root"/>
<add id="Esun_Wiki::homepage_menu" title="Wiki Homepage" module="Esun_Wiki"
sortOrder="10" parent="Esun_Wiki::root"
action="esun_wiki/homepage/edit" resource="Esun_Wiki::homepage"/>
<add id="Esun_Wiki::categories_menu" title="Wiki Categories" module="Esun_Wiki"
sortOrder="20" parent="Esun_Wiki::root"
action="esun_wiki/category/index" resource="Esun_Wiki::categories"/>
<add id="Esun_Wiki::config_menu" title="Wiki Configuration" module="Esun_Wiki"
sortOrder="30" parent="Esun_Wiki::root"
action="adminhtml/system_config/edit/section/esun_wiki" resource="Esun_Wiki::config"/>
</menu>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="esun_wiki" frontName="esun_wiki">
<module name="Esun_Wiki" before="Magento_Backend"/>
</route>
</router>
</config>
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="esun" translate="label" sortOrder="300">
<label>Esun</label>
</tab>
<section id="esun_wiki" translate="label" type="text" sortOrder="925"
showInDefault="1" showInWebsite="1" showInStore="1">
<label>Wiki</label>
<tab>esun</tab>
<resource>Esun_Wiki::config</resource>
<group id="appearance" translate="label" type="text" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="1">
<label>Appearance</label>
<field id="banner_image" translate="label comment" type="image" sortOrder="10"
showInDefault="1" showInWebsite="1" showInStore="1">
<label>Top Banner Image</label>
<backend_model>Esun\Wiki\Model\Config\Backend\BannerImage</backend_model>
<upload_dir config="system/filesystem/media" scope_info="1">esun/wiki/banner</upload_dir>
<base_url type="media" scope_info="1">esun/wiki/banner</base_url>
<comment><![CDATA[
Used on the top of all Wiki pages. If empty, wiki_top_banner.png from the theme is used.
Allowed file types: jpg, jpeg, gif, png and webp.
]]></comment>
</field>
</group>
</section>
</system>
</config>
+91
View File
@@ -0,0 +1,91 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="esun_wiki_category" resource="default" engine="innodb" comment="Esun Wiki Categories">
<column xsi:type="int" name="category_id" unsigned="true" nullable="false" identity="true" comment="Category ID"/>
<column xsi:type="int" name="parent_id" unsigned="true" nullable="true" comment="Parent Category ID"/>
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
<column xsi:type="varchar" name="slug" nullable="false" length="160" comment="URL Slug"/>
<column xsi:type="varchar" name="custom_url_path" nullable="true" length="255" comment="Custom URL Path"/>
<column xsi:type="varchar" name="logo_path" nullable="true" length="512" comment="Navigation Logo Path"/>
<column xsi:type="text" name="summary" nullable="true" comment="Summary"/>
<column xsi:type="mediumtext" name="content" nullable="true" comment="Wiki Content"/>
<column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Meta Title"/>
<column xsi:type="text" name="meta_description" nullable="true" comment="Meta Description"/>
<column xsi:type="text" name="meta_keywords" nullable="true" comment="Meta Keywords"/>
<column xsi:type="smallint" name="is_active" unsigned="true" nullable="false" default="1" comment="Is Active"/>
<column xsi:type="smallint" name="is_default_open" unsigned="true" nullable="false" default="0"
comment="Is Open by Default"/>
<column xsi:type="smallint" name="is_clickable" unsigned="true" nullable="false" default="1"
comment="Can Open Wiki Content"/>
<column xsi:type="smallint" name="show_download_center" unsigned="true" nullable="false" default="0"
comment="Show Download Center"/>
<column xsi:type="smallint" name="show_parameter_comparison" unsigned="true" nullable="false" default="0"
comment="Show Parameter Comparison"/>
<column xsi:type="int" name="sort_order" unsigned="false" nullable="false" default="0" comment="Sort Order"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="true" comment="Updated At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="category_id"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_WIKI_CATEGORY_SLUG">
<column name="slug"/>
</constraint>
<constraint xsi:type="unique" referenceId="ESUN_WIKI_CATEGORY_CUSTOM_URL_PATH">
<column name="custom_url_path"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_WIKI_CATEGORY_PARENT_ID_ESUN_WIKI_CATEGORY_CATEGORY_ID"
table="esun_wiki_category" column="parent_id"
referenceTable="esun_wiki_category" referenceColumn="category_id"
onDelete="SET NULL"/>
<index referenceId="ESUN_WIKI_CATEGORY_PARENT_SORT" indexType="btree">
<column name="parent_id"/>
<column name="sort_order"/>
<column name="category_id"/>
</index>
<index referenceId="ESUN_WIKI_CATEGORY_ACTIVE_SORT" indexType="btree">
<column name="is_active"/>
<column name="sort_order"/>
<column name="category_id"/>
</index>
</table>
<table name="esun_wiki_category_store" resource="default" engine="innodb"
comment="Esun Wiki Category Store Relations">
<column xsi:type="int" name="category_id" unsigned="true" nullable="false" comment="Category ID"/>
<column xsi:type="smallint" name="store_id" unsigned="true" nullable="false" comment="Store ID"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="category_id"/>
<column name="store_id"/>
</constraint>
<constraint xsi:type="foreign" referenceId="ESUN_WIKI_CATEGORY_STORE_CATEGORY_ID_CATEGORY_CATEGORY_ID"
table="esun_wiki_category_store" column="category_id"
referenceTable="esun_wiki_category" referenceColumn="category_id"
onDelete="CASCADE"/>
<constraint xsi:type="foreign" referenceId="ESUN_WIKI_CATEGORY_STORE_STORE_ID_STORE_STORE_ID"
table="esun_wiki_category_store" column="store_id"
referenceTable="store" referenceColumn="store_id"
onDelete="CASCADE"/>
<index referenceId="ESUN_WIKI_CATEGORY_STORE_STORE_ID" indexType="btree">
<column name="store_id"/>
</index>
</table>
<table name="esun_wiki_homepage" resource="default" engine="innodb" comment="Esun Wiki Homepage">
<column xsi:type="int" name="homepage_id" unsigned="true" nullable="false" identity="true"
comment="Homepage ID"/>
<column xsi:type="varchar" name="title" nullable="false" length="255" comment="Title"/>
<column xsi:type="mediumtext" name="content" nullable="true" comment="Homepage Content"/>
<column xsi:type="varchar" name="meta_title" nullable="true" length="255" comment="Meta Title"/>
<column xsi:type="text" name="meta_description" nullable="true" comment="Meta Description"/>
<column xsi:type="text" name="meta_keywords" nullable="true" comment="Meta Keywords"/>
<column xsi:type="timestamp" name="created_at" nullable="false" default="CURRENT_TIMESTAMP"
comment="Created At"/>
<column xsi:type="timestamp" name="updated_at" nullable="false" default="CURRENT_TIMESTAMP"
on_update="true" comment="Updated At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="homepage_id"/>
</constraint>
</table>
</schema>
@@ -0,0 +1,64 @@
{
"esun_wiki_category": {
"column": {
"category_id": true,
"parent_id": true,
"title": true,
"slug": true,
"custom_url_path": true,
"logo_path": true,
"summary": true,
"content": true,
"meta_title": true,
"meta_description": true,
"meta_keywords": true,
"is_active": true,
"is_default_open": true,
"is_clickable": true,
"show_download_center": true,
"show_parameter_comparison": true,
"sort_order": true,
"created_at": true,
"updated_at": true
},
"constraint": {
"PRIMARY": true,
"ESUN_WIKI_CATEGORY_SLUG": true,
"ESUN_WIKI_CATEGORY_CUSTOM_URL_PATH": true,
"ESUN_WIKI_CATEGORY_PARENT_ID_ESUN_WIKI_CATEGORY_CATEGORY_ID": true
},
"index": {
"ESUN_WIKI_CATEGORY_PARENT_SORT": true,
"ESUN_WIKI_CATEGORY_ACTIVE_SORT": true
}
},
"esun_wiki_category_store": {
"column": {
"category_id": true,
"store_id": true
},
"constraint": {
"PRIMARY": true,
"ESUN_WIKI_CATEGORY_STORE_CATEGORY_ID_CATEGORY_CATEGORY_ID": true,
"ESUN_WIKI_CATEGORY_STORE_STORE_ID_STORE_STORE_ID": true
},
"index": {
"ESUN_WIKI_CATEGORY_STORE_STORE_ID": true
}
},
"esun_wiki_homepage": {
"column": {
"homepage_id": true,
"title": true,
"content": true,
"meta_title": true,
"meta_description": true,
"meta_keywords": true,
"created_at": true,
"updated_at": true
},
"constraint": {
"PRIMARY": true
}
}
}
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\App\RouterList">
<arguments>
<argument name="routerList" xsi:type="array">
<item name="esun_wiki_custom_url" xsi:type="array">
<item name="class" xsi:type="string">Esun\Wiki\Controller\Router</item>
<item name="disable" xsi:type="boolean">false</item>
<item name="sortOrder" xsi:type="string">45</item>
</item>
</argument>
</arguments>
</type>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="wiki" frontName="wiki">
<module name="Esun_Wiki"/>
</route>
</router>
</config>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Esun_Wiki">
<sequence>
<module name="Magento_Backend"/>
<module name="Magento_Catalog"/>
<module name="Magento_Checkout"/>
<module name="Magento_Cms"/>
<module name="Magento_Config"/>
<module name="Magento_PageBuilder"/>
<module name="Magento_Store"/>
<module name="Esun_Catalog"/>
<module name="Esun_ImageManager"/>
</sequence>
</module>
</config>
+6
View File
@@ -0,0 +1,6 @@
<?php
declare(strict_types=1);
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Esun_Wiki', __DIR__);
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Esun_Wiki::css/wiki-category-edit.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Adminhtml\Category\EditBlock"
name="esun.wiki.category.edit"
template="Esun_Wiki::category/edit.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<uiComponent name="esun_wiki_category_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Esun_Wiki::css/wiki-category-edit.css"/>
</head>
<body>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Adminhtml\Category\EditBlock"
name="esun.wiki.category.new"
template="Esun_Wiki::category/edit.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Adminhtml\Homepage\EditBlock"
name="esun.wiki.homepage.edit"
template="Esun_Wiki::homepage/edit.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,304 @@
<?php
/** @var \Esun\Wiki\Block\Adminhtml\Category\EditBlock $block */
$category = $block->getCategory();
$previewUrl = $block->getPreviewUrl();
$productTipExample = '{{wiki_product sku="PRODUCT-SKU" label="eSUN PLA+ 1.75mm 3D Filament 1KG"}}';
$termTipExample = '{{wiki_term label="PLA (Polylactic Acid)" image="wysiwyg/wiki/pla.jpg" image_alt="PLA filament" link_label="External Link To" link_url="#pla" title="FDM Materials for 3D Printing" description="PLA is a popular thermoplastic filament for FDM/FFF 3D printing."}}';
?>
<form class="wiki-category-edit" method="post" action="<?= $block->escapeUrl($block->getSaveUrl()) ?>"
enctype="multipart/form-data">
<?= $block->getBlockHtml('formkey') ?>
<input type="hidden" name="category_id" value="<?= (int) $category->getId() ?>">
<div class="page-main-actions">
<div class="page-actions">
<a class="action-secondary wiki-action-back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
<span><?= $block->escapeHtml(__('Back')) ?></span>
</a>
<?php if ($previewUrl !== ''): ?>
<a class="action-secondary wiki-action-preview" href="<?= $block->escapeUrl($previewUrl) ?>" target="_blank" rel="noopener">
<span><?= $block->escapeHtml(__('Preview')) ?></span>
</a>
<?php endif; ?>
<button class="action-secondary wiki-action-save-continue" type="submit" name="back" value="1">
<span><?= $block->escapeHtml(__('Save and Continue')) ?></span>
</button>
<button class="action-primary wiki-action-save" type="submit">
<span><?= $block->escapeHtml(__('Save Wiki Category')) ?></span>
</button>
</div>
</div>
<div class="wiki-category-tabs"
data-mage-init='{"Esun_Wiki/js/wiki-category-tabs":{}}'>
<nav class="wiki-category-tab-nav" role="tablist"
aria-label="<?= $block->escapeHtmlAttr(__('Wiki Category Sections')) ?>">
<div class="wiki-category-tab-nav-item _active">
<button class="wiki-category-tab-trigger" type="button" role="tab"
id="wiki-category-tab-general" aria-controls="wiki-category-panel-general"
aria-selected="true" data-wiki-tab="0">
<?= $block->escapeHtml(__('General')) ?>
</button>
</div>
<div class="wiki-category-tab-nav-item">
<button class="wiki-category-tab-trigger" type="button" role="tab"
id="wiki-category-tab-content" aria-controls="wiki-category-panel-content"
aria-selected="false" data-wiki-tab="1">
<?= $block->escapeHtml(__('Content')) ?>
</button>
</div>
<div class="wiki-category-tab-nav-item">
<button class="wiki-category-tab-trigger" type="button" role="tab"
id="wiki-category-tab-seo" aria-controls="wiki-category-panel-seo"
aria-selected="false" data-wiki-tab="2">
<?= $block->escapeHtml(__('Search Engine Optimization')) ?>
</button>
</div>
<div class="wiki-category-tab-nav-item">
<button class="wiki-category-tab-trigger" type="button" role="tab"
id="wiki-category-tab-display" aria-controls="wiki-category-panel-display"
aria-selected="false" data-wiki-tab="3">
<?= $block->escapeHtml(__('Display Settings')) ?>
</button>
</div>
</nav>
<div class="wiki-category-tab-panels">
<section class="wiki-category-tab-panel" role="tabpanel"
id="wiki-category-panel-general" aria-labelledby="wiki-category-tab-general">
<fieldset class="admin__fieldset">
<div class="admin__field _required">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Title')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="title" required
value="<?= $block->escapeHtmlAttr((string) $category->getData('title')) ?>">
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Navigation Logo')) ?></span></label>
<div class="admin__field-control">
<?php if ($block->getLogoUrl() !== ''): ?>
<div style="margin-bottom:1.5rem">
<img src="<?= $block->escapeUrl($block->getLogoUrl()) ?>"
alt="<?= $block->escapeHtmlAttr(__('Current navigation logo')) ?>"
style="display:block;width:64px;height:64px;object-fit:contain;margin-bottom:1rem;border:1px solid #d6d6d6;background:#fff;padding:.5rem">
<label>
<input type="checkbox" name="delete_logo" value="1">
<?= $block->escapeHtml(__('Delete current logo')) ?>
</label>
</div>
<?php endif; ?>
<input type="file" name="logo" accept="image/jpeg,image/png,image/gif,image/webp">
<p class="note">
<?= $block->escapeHtml(__('Allowed: JPG, PNG, GIF and WebP. A transparent square image is recommended.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Parent Category')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="parent_id">
<?php foreach ($block->getParentOptions() as $option): ?>
<option value="<?= (int) $option['value'] ?>"
<?= (int) $option['value'] === (int) $category->getData('parent_id') ? 'selected' : '' ?>>
<?= $block->escapeHtml($option['label']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Slug')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="slug"
value="<?= $block->escapeHtmlAttr((string) $category->getData('slug')) ?>">
<p class="note">
<?= $block->escapeHtml(__('Lowercase URL key. Leave empty to generate it from the title.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Custom URL')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="custom_url_path"
value="<?= $block->escapeHtmlAttr((string) $category->getData('custom_url_path')) ?>"
placeholder="parameters-download">
<p class="note">
<?= $block->escapeHtml(__('Optional path shown in frontend links. Do not include the domain or leading slash.')) ?>
</p>
</div>
</div>
<div class="admin__field _required">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Store View')) ?></span></label>
<div class="admin__field-control">
<?php $selectedStoreIds = $block->getSelectedStoreIds(); ?>
<select class="admin__control-multiselect" name="store_ids[]" multiple required size="12">
<?php foreach ($block->getStoreOptions() as $option): ?>
<option value="<?= $block->escapeHtmlAttr((string) $option['value']) ?>"
<?= $option['disabled'] ? 'disabled' : '' ?>
<?= !$option['disabled'] && in_array((int) $option['value'], $selectedStoreIds, true)
? 'selected' : '' ?>>
<?= $block->escapeHtml($option['label']) ?>
</option>
<?php endforeach; ?>
</select>
<p class="note">
<?= $block->escapeHtml(__('Select All Store Views or one or more individual Store Views.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Summary')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" name="summary" rows="4"><?= $block->escapeHtml((string) $category->getData('summary')) ?></textarea>
</div>
</div>
</fieldset>
</section>
<section class="wiki-category-tab-panel" role="tabpanel"
id="wiki-category-panel-content" aria-labelledby="wiki-category-tab-content" hidden>
<fieldset class="admin__fieldset">
<div class="admin__field wiki-category-content-field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Wiki Content')) ?></span></label>
<div class="admin__field-control">
<?= /* @noEscape */ $block->getContentEditorHtml() ?>
<p class="note">
<?= $block->escapeHtml(__('Supports Page Builder, HTML, and Magento CMS directives. Headings such as h2/h3 are used to build the right-side anchors.')) ?>
</p>
<div class="message message-notice" style="margin-top: 1.5rem;">
<strong><?= $block->escapeHtml(__('Wiki hover popup directives')) ?></strong>
<p><?= $block->escapeHtml(__('Insert either directive in the content HTML. Product details are loaded from the current store by SKU.')) ?></p>
<p><code><?= $block->escapeHtml($productTipExample) ?></code></p>
<p><code><?= $block->escapeHtml($termTipExample) ?></code></p>
</div>
</div>
</div>
</fieldset>
</section>
<section class="wiki-category-tab-panel" role="tabpanel"
id="wiki-category-panel-seo" aria-labelledby="wiki-category-tab-seo" hidden>
<fieldset class="admin__fieldset">
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Title')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="meta_title" maxlength="255"
value="<?= $block->escapeHtmlAttr((string) $category->getData('meta_title')) ?>">
<p class="note">
<?= $block->escapeHtml(__('Used as the browser page title. The Wiki category title is used when this field is empty.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Description')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" name="meta_description" rows="4"><?= $block->escapeHtml((string) $category->getData('meta_description')) ?></textarea>
<p class="note">
<?= $block->escapeHtml(__('Used for the page meta description.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Keywords')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" name="meta_keywords" rows="3"><?= $block->escapeHtml((string) $category->getData('meta_keywords')) ?></textarea>
<p class="note">
<?= $block->escapeHtml(__('Comma-separated keywords used for the page meta keywords.')) ?>
</p>
</div>
</div>
</fieldset>
</section>
<section class="wiki-category-tab-panel" role="tabpanel"
id="wiki-category-panel-display" aria-labelledby="wiki-category-tab-display" hidden>
<fieldset class="admin__fieldset">
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Status')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="is_active">
<option value="1" <?= !$category->getId() || (int) $category->getData('is_active') === 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Enabled')) ?>
</option>
<option value="0" <?= $category->getId() && (int) $category->getData('is_active') === 0 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Disabled')) ?>
</option>
</select>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Display Download Center')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="show_download_center">
<option value="0" <?= (int) $category->getData('show_download_center') !== 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('No')) ?>
</option>
<option value="1" <?= (int) $category->getData('show_download_center') === 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Yes')) ?>
</option>
</select>
<p class="note">
<?= $block->escapeHtml(__('Only one Wiki page can display the download center. Selecting Yes moves it from the previously selected page.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Display Parameter Comparison')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="show_parameter_comparison">
<option value="0" <?= (int) $category->getData('show_parameter_comparison') !== 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('No')) ?>
</option>
<option value="1" <?= (int) $category->getData('show_parameter_comparison') === 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Yes')) ?>
</option>
</select>
<p class="note">
<?= $block->escapeHtml(__('Only one Wiki page can display parameter comparison. Selecting Yes moves it from the previously selected page.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Open by Default')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="is_default_open">
<option value="0" <?= (int) $category->getData('is_default_open') !== 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('No')) ?>
</option>
<option value="1" <?= (int) $category->getData('is_default_open') === 1 ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Yes')) ?>
</option>
</select>
<p class="note">
<?= $block->escapeHtml(__('Automatically expands this category and displays its child categories in the frontend navigation.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Allow Opening Content')) ?></span></label>
<div class="admin__field-control">
<select class="admin__control-select" name="is_clickable">
<option value="1" <?= $category->isClickable() ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('Yes')) ?>
</option>
<option value="0" <?= !$category->isClickable() ? 'selected' : '' ?>>
<?= $block->escapeHtml(__('No')) ?>
</option>
</select>
<p class="note">
<?= $block->escapeHtml(__('When disabled, the category remains in navigation but its title cannot open Wiki content. Child categories can still be expanded.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Sort Order')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="number" name="sort_order"
value="<?= (int) $category->getData('sort_order') ?>">
</div>
</div>
</fieldset>
</section>
</div>
</div>
</form>
@@ -0,0 +1,73 @@
<?php
/** @var \Esun\Wiki\Block\Adminhtml\Homepage\EditBlock $block */
$homepage = $block->getHomepage();
$productTipExample = '{{wiki_product sku="PRODUCT-SKU" label="eSUN PLA+ 1.75mm 3D Filament 1KG"}}';
$termTipExample = '{{wiki_term label="PLA (Polylactic Acid)" image="wysiwyg/wiki/pla.jpg" image_alt="PLA filament" link_label="External Link To" link_url="#pla" title="FDM Materials for 3D Printing" description="PLA is a popular thermoplastic filament for FDM/FFF 3D printing."}}';
?>
<form method="post" action="<?= $block->escapeUrl($block->getSaveUrl()) ?>">
<?= $block->getBlockHtml('formkey') ?>
<div class="page-main-actions">
<div class="page-actions">
<a class="action-secondary" href="<?= $block->escapeUrl($block->getCategoriesUrl()) ?>">
<span><?= $block->escapeHtml(__('Wiki Categories')) ?></span>
</a>
<a class="action-secondary" href="<?= $block->escapeUrl($block->getPreviewUrl()) ?>"
target="_blank" rel="noopener">
<span><?= $block->escapeHtml(__('Preview')) ?></span>
</a>
<button class="action-primary" type="submit">
<span><?= $block->escapeHtml(__('Save Wiki Homepage')) ?></span>
</button>
</div>
</div>
<fieldset class="admin__fieldset">
<div class="admin__field _required">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Title')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="title" required maxlength="255"
value="<?= $block->escapeHtmlAttr((string) $homepage->getData('title')) ?>">
<p class="note">
<?= $block->escapeHtml(__('Displayed as the homepage heading and browser page title.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Meta Title')) ?></span></label>
<div class="admin__field-control">
<input class="admin__control-text" type="text" name="meta_title" maxlength="255"
value="<?= $block->escapeHtmlAttr((string) $homepage->getData('meta_title')) ?>">
<p class="note">
<?= $block->escapeHtml(__('Used for the meta title value. The visible browser title uses the homepage title above.')) ?>
</p>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Description')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" name="meta_description" rows="4"><?= $block->escapeHtml((string) $homepage->getData('meta_description')) ?></textarea>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('SEO Keywords')) ?></span></label>
<div class="admin__field-control">
<textarea class="admin__control-textarea" name="meta_keywords" rows="3"><?= $block->escapeHtml((string) $homepage->getData('meta_keywords')) ?></textarea>
</div>
</div>
<div class="admin__field">
<label class="admin__field-label"><span><?= $block->escapeHtml(__('Homepage Content')) ?></span></label>
<div class="admin__field-control">
<?= /* @noEscape */ $block->getContentEditorHtml() ?>
<p class="note">
<?= $block->escapeHtml(__('Supports Page Builder, HTML, Magento CMS directives, content anchors, and Wiki hover popup directives.')) ?>
</p>
<div class="message message-notice" style="margin-top: 1.5rem;">
<strong><?= $block->escapeHtml(__('Wiki hover popup directives')) ?></strong>
<p><?= $block->escapeHtml(__('Product details are loaded from the current store by SKU.')) ?></p>
<p><code><?= $block->escapeHtml($productTipExample) ?></code></p>
<p><code><?= $block->escapeHtml($termTipExample) ?></code></p>
</div>
</div>
</div>
</fieldset>
</form>
@@ -0,0 +1,179 @@
<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">esun_wiki_category_listing.esun_wiki_category_listing_data_source</item>
</item>
</argument>
<settings>
<buttons>
<button name="add">
<url path="esun_wiki/category/new"/>
<class>primary</class>
<label translate="true">Add Wiki Category</label>
<aclResource>Esun_Wiki::categories_save</aclResource>
</button>
</buttons>
<spinner>esun_wiki_category_columns</spinner>
<deps>
<dep>esun_wiki_category_listing.esun_wiki_category_listing_data_source</dep>
</deps>
</settings>
<dataSource name="esun_wiki_category_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<storageConfig>
<param name="indexField" xsi:type="string">category_id</param>
</storageConfig>
<updateUrl path="mui/index/render"/>
</settings>
<aclResource>Esun_Wiki::categories</aclResource>
<dataProvider class="Esun\Wiki\Ui\DataProvider\Category\ListingDataProvider"
name="esun_wiki_category_listing_data_source">
<settings>
<requestFieldName>id</requestFieldName>
<primaryFieldName>category_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<listingToolbar name="listing_top">
<settings>
<sticky>true</sticky>
</settings>
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<filterSearch name="fulltext">
<settings>
<placeholder translate="true">Search Wiki</placeholder>
</settings>
</filterSearch>
<filters name="listing_filters"/>
<massaction name="listing_massaction">
<action name="add_to_translation_queue">
<settings>
<url path="esun_wiki/category/prepareTranslation"/>
<type>add_to_translation_queue</type>
<label translate="true">Add Selected to Translation Queue</label>
</settings>
</action>
</massaction>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="esun_wiki_category_columns">
<selectionsColumn name="ids" sortOrder="0">
<settings>
<indexField>category_id</indexField>
<resizeEnabled>false</resizeEnabled>
<resizeDefaultWidth>55</resizeDefaultWidth>
</settings>
</selectionsColumn>
<column name="category_id" sortOrder="10">
<settings>
<filter>textRange</filter>
<label translate="true">ID</label>
</settings>
</column>
<column name="title" sortOrder="20">
<settings>
<filter>text</filter>
<label translate="true">Title</label>
</settings>
</column>
<column name="parent_title" sortOrder="30">
<settings>
<filter>false</filter>
<sortable>false</sortable>
<label translate="true">Parent</label>
</settings>
</column>
<column name="slug" sortOrder="40">
<settings>
<filter>text</filter>
<label translate="true">Slug</label>
</settings>
</column>
<column name="custom_url_path" sortOrder="50">
<settings>
<filter>text</filter>
<label translate="true">Custom URL</label>
</settings>
</column>
<column name="is_active" component="Magento_Ui/js/grid/columns/select" sortOrder="60">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Enabledisable</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Status</label>
</settings>
</column>
<column name="is_default_open" component="Magento_Ui/js/grid/columns/select" sortOrder="70">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Open by Default</label>
</settings>
</column>
<column name="is_clickable" component="Magento_Ui/js/grid/columns/select" sortOrder="80">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Open Content</label>
</settings>
</column>
<column name="show_download_center" component="Magento_Ui/js/grid/columns/select" sortOrder="90">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Download Center</label>
</settings>
</column>
<column name="show_parameter_comparison" component="Magento_Ui/js/grid/columns/select" sortOrder="100">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Parameter Comparison</label>
</settings>
</column>
<column name="sort_order" sortOrder="110">
<settings>
<filter>textRange</filter>
<dataType>number</dataType>
<label translate="true">Sort Order</label>
</settings>
</column>
<column name="updated_at" class="Magento\Ui\Component\Listing\Columns\Date"
component="Magento_Ui/js/grid/columns/date" sortOrder="120">
<settings>
<filter>dateRange</filter>
<dataType>date</dataType>
<label translate="true">Updated</label>
</settings>
</column>
<actionsColumn name="actions"
class="Esun\Wiki\Ui\Component\Listing\Column\Actions"
sortOrder="130">
<settings>
<indexField>category_id</indexField>
<resizeEnabled>false</resizeEnabled>
<resizeDefaultWidth>160</resizeDefaultWidth>
</settings>
</actionsColumn>
</columns>
</listing>
@@ -0,0 +1,159 @@
.wiki-category-edit .page-actions {
display: flex;
flex-wrap: wrap;
gap: 1.2rem;
align-items: center;
justify-content: flex-end;
}
.wiki-category-edit .page-actions .action-primary,
.wiki-category-edit .page-actions .action-secondary {
display: inline-flex;
box-sizing: border-box;
min-height: 4.4rem;
margin: 0;
padding: 0 2.4rem;
align-items: center;
justify-content: center;
line-height: 1.2;
white-space: nowrap;
}
.wiki-category-edit .wiki-action-back {
order: 10;
}
.wiki-category-edit .wiki-action-preview {
order: 20;
}
.wiki-category-edit .wiki-action-save {
order: 30;
}
.wiki-category-edit .wiki-action-save-continue {
order: 40;
}
.wiki-category-edit .page-actions button[onclick*="translate-modal"] {
order: 50;
}
.wiki-category-tabs {
display: grid;
grid-template-columns: 24rem minmax(0, 1fr);
gap: 2.4rem;
align-items: start;
}
.wiki-category-tab-nav {
overflow: hidden;
border: 1px solid #adadad;
background: #f1f1f1;
}
.wiki-category-tab-nav-item + .wiki-category-tab-nav-item {
border-top: 1px solid #d6d6d6;
}
.wiki-category-tab-trigger {
display: block;
width: 100%;
padding: 1.6rem 1.8rem;
border: 0;
background: transparent;
color: #303030;
font-size: 1.4rem;
font-weight: 600;
line-height: 1.4;
text-align: left;
cursor: pointer;
}
.wiki-category-tab-trigger:hover,
.wiki-category-tab-trigger:focus {
background: #e3e3e3;
color: #eb5202;
}
.wiki-category-tab-nav-item._active .wiki-category-tab-trigger {
position: relative;
background: #fff;
color: #eb5202;
}
.wiki-category-tab-nav-item._active .wiki-category-tab-trigger::before {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 0.4rem;
background: #eb5202;
content: '';
}
.wiki-category-tab-panels {
min-width: 0;
}
.wiki-category-tab-panel {
min-height: 38rem;
padding: 2.4rem;
border: 1px solid #d6d6d6;
background: #fff;
}
.wiki-category-tab-panel[hidden] {
display: none !important;
}
.wiki-category-tab-panel > .admin__fieldset {
padding-top: 0;
padding-bottom: 0;
}
.wiki-category-tab-panel .admin__control-text,
.wiki-category-tab-panel .admin__control-textarea,
.wiki-category-tab-panel .admin__control-select,
.wiki-category-tab-panel .admin__control-multiselect {
max-width: none;
}
.wiki-category-content-field > .admin__field-label {
float: none;
width: 100%;
margin: 0 0 1.2rem;
padding: 0;
text-align: left;
}
.wiki-category-content-field > .admin__field-control {
float: none;
width: 100%;
margin: 0;
}
.wiki-category-content-field .admin__control-wysiwig,
.wiki-category-content-field .tox-tinymce {
width: 100% !important;
max-width: none;
}
@media (max-width: 767px) {
.wiki-category-tabs {
grid-template-columns: minmax(0, 1fr);
}
.wiki-category-tab-nav {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wiki-category-tab-nav-item + .wiki-category-tab-nav-item {
border-top: 0;
}
.wiki-category-tab-panel {
padding: 1.6rem;
}
}
@@ -0,0 +1,27 @@
define([
'jquery'
], function ($) {
'use strict';
return function (config, element) {
var $container = $(element),
$tabs = $container.find('.wiki-category-tab-trigger'),
$panels = $container.find('.wiki-category-tab-panel');
$tabs.on('click.wikiCategoryTabs', function (event) {
var index = Number($(this).attr('data-wiki-tab'));
event.preventDefault();
$tabs.attr('aria-selected', 'false')
.parent()
.removeClass('_active');
$(this).attr('aria-selected', 'true')
.parent()
.addClass('_active');
$panels.attr('hidden', true);
$panels.eq(index).removeAttr('hidden');
});
};
});
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Esun_Wiki::css/download-center.css"/>
</head>
<body>
<referenceBlock name="esun.wiki.view">
<block class="Esun\Wiki\Block\Wiki\DownloadCenter"
name="esun.wiki.download.center"
as="download_center"
template="Esun_Wiki::wiki/download-center.phtml"/>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Esun_Wiki::css/parameter-comparison.css"/>
</head>
<body>
<referenceBlock name="esun.wiki.view">
<block class="Esun\Wiki\Block\Wiki\ParameterComparison"
name="esun.wiki.parameter.comparison"
as="parameter_comparison"
template="Esun_Wiki::wiki/parameter-comparison.phtml"/>
</referenceBlock>
</body>
</page>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="esun_wiki_download_center"/>
<update handle="esun_wiki_parameter_comparison"/>
<head>
<css src="Esun_Wiki::css/wiki.css"/>
</head>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Wiki\View"
name="esun.wiki.view"
template="Esun_Wiki::wiki/view.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="esun_wiki_download_center"/>
<update handle="esun_wiki_parameter_comparison"/>
<head>
<css src="Esun_Wiki::css/wiki.css"/>
</head>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceContainer name="content">
<block class="Esun\Wiki\Block\Wiki\View"
name="esun.wiki.view"
template="Esun_Wiki::wiki/view.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,39 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\DownloadCenter $block */
if (!$block->hasSpecifications()) {
return;
}
?>
<section class="esun-wiki-download-center"
aria-label="<?= $block->escapeHtmlAttr(__('Download Specifications')) ?>">
<div class="esun-download-specifications"
data-mage-init='{"Esun_Wiki/js/download-center":<?= /* @noEscape */ $block->getConfigJson() ?>}'>
<div class="esun-download-specifications__filters">
<label class="esun-download-specifications__field">
<span><?= $block->escapeHtml(__('Brand')) ?></span>
<select data-role="spec-brand">
<option value=""><?= $block->escapeHtml(__('All Brands')) ?></option>
</select>
</label>
<label class="esun-download-specifications__field">
<span><?= $block->escapeHtml(__('Model')) ?></span>
<select data-role="spec-model">
<option value=""><?= $block->escapeHtml(__('All Models')) ?></option>
</select>
</label>
</div>
<div class="esun-download-specifications__count">
<span><?= $block->escapeHtml(__('Download List')) ?></span>
<strong data-role="spec-count">0</strong>
</div>
<div class="esun-download-specifications__empty" data-role="spec-empty">
<span class="esun-download-specifications__empty-icon"></span>
<strong><?= $block->escapeHtml(__('Find your printer driver')) ?></strong>
<p><?= $block->escapeHtml(__('Select a brand or printer model to browse available downloads.')) ?></p>
</div>
<div class="esun-download-specifications__list" data-role="spec-list"></div>
<nav class="esun-download-specifications__pagination"
data-role="spec-pagination"
aria-label="<?= $block->escapeHtmlAttr(__('Download list pagination')) ?>"></nav>
</div>
</section>
@@ -0,0 +1,87 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\ParameterComparison $block */
if (!$block->hasComparisonData()) {
return;
}
$safeConfigJson = str_replace(
['<', '>', '&'],
['\\u003C', '\\u003E', '\\u0026'],
$block->getConfigJson()
);
$baseOptions = $block->getBaseOptions();
?>
<section class="esun-parameter-comparison"
aria-label="<?= $block->escapeHtmlAttr(__('Material Parameter Comparison')) ?>">
<div class="esun-parameter-comparison__app"
data-mage-init='{"Esun_Wiki/js/parameter-comparison":{}}'>
<script type="application/json" data-role="parameter-config"><?= /* @noEscape */ $safeConfigJson ?></script>
<div class="esun-parameter-comparison__selector">
<div class="esun-parameter-comparison__selector-row">
<header class="esun-parameter-comparison__row-title">
<strong>1 · <?= $block->escapeHtml(__('Base Materials')) ?></strong>
<span><?= $block->escapeHtml(__('Choose a material family')) ?></span>
</header>
<div class="esun-parameter-comparison__base-options">
<?php foreach ($baseOptions as $index => $option): ?>
<label>
<input type="radio" name="parameter_base_material" data-role="base-filter"
value="<?= $block->escapeHtmlAttr($option['value']) ?>"
<?= $index === 0 ? 'checked' : '' ?>>
<span class="esun-parameter-comparison__dot"></span>
<span><?= $block->escapeHtml($option['label']) ?></span>
<small><?= (int) $option['count'] ?></small>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="esun-parameter-comparison__selector-row esun-parameter-comparison__selector-row--series">
<header class="esun-parameter-comparison__row-title">
<strong>2 · <?= $block->escapeHtml(__('Application Series')) ?></strong>
<span><?= $block->escapeHtml(__('Select up to 6 materials from a series')) ?></span>
</header>
<div class="esun-parameter-comparison__series-area">
<div class="esun-parameter-comparison__series-summary">
<span><strong data-role="result-count">0</strong> <?= $block->escapeHtml(__('materials')) ?></span>
<span>·</span>
<span><strong data-role="selection-count">0</strong>/6 <?= $block->escapeHtml(__('selected')) ?></span>
</div>
<div class="esun-parameter-comparison__series-list" data-role="series-list"></div>
<p class="esun-parameter-comparison__notice" data-role="material-notice" aria-live="polite"></p>
<div class="esun-parameter-comparison__selected" data-role="selected-materials"></div>
</div>
</div>
</div>
<div class="esun-parameter-comparison__comparison">
<div class="esun-parameter-comparison__comparison-head">
<div>
<h2><?= $block->escapeHtml(__('Material Parameter Comparison')) ?></h2>
<p><span data-role="comparison-count">0</span> <?= $block->escapeHtml(__('selected materials.')) ?></p>
</div>
<div class="esun-parameter-comparison__modes" role="tablist"
aria-label="<?= $block->escapeHtmlAttr(__('Comparison display mode')) ?>">
<button type="button" class="is-active" data-role="comparison-mode" data-mode="key">
<?= $block->escapeHtml(__('Key Parameters')) ?>
</button>
<button type="button" data-role="comparison-mode" data-mode="all">
<?= $block->escapeHtml(__('All Parameters')) ?>
</button>
<button type="button" data-role="comparison-mode" data-mode="differences">
<?= $block->escapeHtml(__('Differences Only')) ?>
</button>
</div>
</div>
<div class="esun-parameter-comparison__placeholder" data-role="comparison-placeholder">
<?= $block->escapeHtml(__('Select a material above to view its parameters.')) ?>
</div>
<div class="esun-parameter-comparison__table-wrap" data-role="comparison-table-wrap">
<table>
<thead data-role="comparison-head"></thead>
<tbody data-role="comparison-body"></tbody>
</table>
</div>
</div>
</div>
</section>
@@ -0,0 +1,351 @@
<?php
/** @var \Esun\Wiki\Block\Wiki\View $block */
$currentCategory = $block->getCurrentCategory();
$isHomepage = $block->isHomepage();
$searchQuery = $block->getSearchQuery();
$anchors = $block->getAnchors();
$tooltips = $block->getTooltips();
$previousCategory = $block->getPreviousCategory();
$nextCategory = $block->getNextCategory();
$renderTree = function (array $nodes, int $level = 0) use (&$renderTree, $block): void {
if (!$nodes) {
return;
}
?>
<ul class="esun-wiki-tree esun-wiki-tree-level-<?= (int) $level ?>">
<?php foreach ($nodes as $node): ?>
<?php
$category = $node['category'];
$children = $node['children'];
$hasChildren = !empty($children);
$isCurrent = $block->isCurrent($category);
$isClickable = $block->isCategoryClickable($category);
$isOpen = $hasChildren && (
$isCurrent
|| $block->isInCurrentPath($category)
|| $block->isCategoryOpenByDefault($category)
);
$logoUrl = $block->getCategoryLogoUrl($category);
?>
<li class="esun-wiki-tree-item <?= $isCurrent ? 'is-active' : '' ?> <?= $isOpen ? 'is-open' : '' ?> <?= !$isClickable ? 'is-not-clickable' : '' ?>">
<div class="esun-wiki-tree-row">
<?php if ($isClickable): ?>
<a class="esun-wiki-tree-link"
href="<?= $block->escapeUrl($block->getCategoryUrl($category)) ?>">
<?php else: ?>
<span class="esun-wiki-tree-link is-disabled" aria-disabled="true">
<?php endif; ?>
<?php if ($logoUrl !== ''): ?>
<img class="esun-wiki-tree-logo"
src="<?= $block->escapeUrl($logoUrl) ?>"
alt=""
loading="lazy">
<?php endif; ?>
<span class="esun-wiki-tree-title">
<?= $block->escapeHtml((string) $category->getData('title')) ?>
</span>
<?php if ($isClickable): ?>
</a>
<?php else: ?>
</span>
<?php endif; ?>
<?php if ($hasChildren): ?>
<button class="esun-wiki-tree-toggle"
type="button"
aria-label="<?= $block->escapeHtmlAttr(__('Toggle category')) ?>"
aria-expanded="<?= $isOpen ? 'true' : 'false' ?>">
<span aria-hidden="true"></span>
</button>
<?php endif; ?>
</div>
<?php if ($hasChildren): ?>
<div class="esun-wiki-tree-children">
<?php $renderTree($children, $level + 1); ?>
</div>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php
};
?>
<div class="esun-wiki-page" data-mage-init='{"Esun_Wiki/js/wiki": {}}'>
<section class="esun-wiki-hero"
style="background-image:linear-gradient(90deg, rgba(14, 18, 22, .42), rgba(14, 18, 22, .12)), url('<?= $block->escapeUrl($block->getHeroBackgroundUrl()) ?>')">
<div class="esun-wiki-title"><?= $block->escapeHtml(__('eSUN Wiki')) ?></div>
<form class="esun-wiki-search" method="get" action="<?= $block->escapeUrl($block->getSearchUrl()) ?>">
<input type="search"
name="q"
value="<?= $block->escapeHtmlAttr($searchQuery) ?>"
placeholder="<?= $block->escapeHtmlAttr(__('Search......')) ?>"
aria-label="<?= $block->escapeHtmlAttr(__('Search wiki')) ?>">
<button class="esun-wiki-search-clear <?= $searchQuery !== '' ? 'is-visible' : '' ?>" type="button"
aria-label="<?= $block->escapeHtmlAttr(__('Clear search')) ?>"></button>
<button class="esun-wiki-search-submit" type="submit"
aria-label="<?= $block->escapeHtmlAttr(__('Search')) ?>">
<svg t="1785230095468" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="39389" width="30" height="30"><path d="M727.893457 795.690762a446.634481 446.634481 0 0 1-280.575883 98.901292C200.277677 894.592054 0.000427 694.314804 0.000427 447.317574a446.293147 446.293147 0 0 1 154.453269-338.133193A445.653148 445.653148 0 0 1 447.317574 0.000427c247.039897 0 447.27448 200.27725 447.27448 447.317147a446.165147 446.165147 0 0 1-98.901292 280.618549l212.650578 212.650578a47.914647 47.914647 0 1 1-67.754639 67.797306z m-280.575883 3.071999a351.573187 351.573187 0 0 0 333.397194-239.9999 351.445187 351.445187 0 0 0-333.397194-462.933141 349.866521 349.866521 0 0 0-230.058571 85.759964 351.445187 351.445187 0 0 0 230.058571 617.13041z m0-607.061081a47.914647 47.914647 0 1 1 0 95.829294 159.743933 159.743933 0 0 0-159.7866 159.7866 47.914647 47.914647 0 0 1-95.829294 0 255.573227 255.573227 0 0 1 255.573227-255.615894z" fill="#17a957" p-id="39390"></path></svg>
</button>
</form>
</section>
<div class="esun-wiki-drawer-backdrop"
data-wiki-drawer-close
aria-hidden="true"></div>
<div class="esun-wiki-shell <?= $anchors ? 'has-toc' : 'has-no-toc' ?>">
<div class="esun-wiki-mobile-actions" aria-label="<?= $block->escapeHtmlAttr(__('Wiki navigation')) ?>">
<button class="esun-wiki-mobile-trigger"
type="button"
data-wiki-drawer-open="categories"
aria-controls="esun-wiki-category-drawer"
aria-expanded="false"
aria-label="<?= $block->escapeHtmlAttr(__('Open wiki categories')) ?>"
title="<?= $block->escapeHtmlAttr(__('Wiki categories')) ?>">
<span class="esun-wiki-mobile-trigger-icon esun-wiki-mobile-trigger-icon--menu"
aria-hidden="true"></span>
</button>
<?= $block->escapeHtmlAttr(__('Wiki Menu')) ?>
</div>
<aside class="esun-wiki-sidebar esun-wiki-drawer esun-wiki-drawer--left"
id="esun-wiki-category-drawer"
data-wiki-drawer="categories"
aria-label="<?= $block->escapeHtmlAttr(__('Wiki categories')) ?>">
<div class="esun-wiki-drawer-header">
<strong><?= $block->escapeHtml(__('Wiki categories')) ?></strong>
<button class="esun-wiki-drawer-close"
type="button"
data-wiki-drawer-close
aria-label="<?= $block->escapeHtmlAttr(__('Close wiki categories')) ?>">
<span aria-hidden="true"></span>
</button>
</div>
<nav>
<?php $renderTree($block->getCategoryTree()); ?>
</nav>
</aside>
<main class="esun-wiki-main" id="wiki-top">
<?php if ($currentCategory && !$isHomepage): ?>
<div class="esun-wiki-breadcrumbs">
<a href="<?= $block->escapeUrl($block->getWikiHomeUrl()) ?>">
<?= $block->escapeHtml(__('esun wiki')) ?>
</a>
<?php foreach ($block->getBreadcrumbItems() as $breadcrumb): ?>
<span aria-hidden="true">/</span>
<?php if ($block->isCategoryClickable($breadcrumb)): ?>
<a href="<?= $block->escapeUrl($block->getCategoryUrl($breadcrumb)) ?>">
<?= $block->escapeHtml((string) $breadcrumb->getData('title')) ?>
</a>
<?php else: ?>
<span><?= $block->escapeHtml((string) $breadcrumb->getData('title')) ?></span>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($block->hasSearchQuery()): ?>
<section class="esun-wiki-search-results">
<h2><?= $block->escapeHtml(__('Search results for "%1"', $searchQuery)) ?></h2>
<?php $results = $block->getSearchResults(); ?>
<?php if (!$results): ?>
<p class="esun-wiki-empty">
<?= $block->escapeHtml(__('No wiki content matched your search.')) ?>
</p>
<?php endif; ?>
<?php foreach ($results as $result): ?>
<article class="esun-wiki-result">
<a href="<?= $block->escapeUrl($block->getCategoryUrl($result)) ?>">
<?= $block->escapeHtml((string) $result->getData('title')) ?>
</a>
<p><?= $block->escapeHtml($block->getSearchSnippet($result)) ?></p>
</article>
<?php endforeach; ?>
</section>
<?php elseif ($currentCategory): ?>
<article class="esun-wiki-article">
<h1<?= $isHomepage ? ' class="wiki-homepage-title"' : '' ?>>
<?= $block->escapeHtml((string) $currentCategory->getData('title')) ?>
</h1>
<div class="esun-wiki-content">
<?= /* @noEscape */ $block->getProcessedContent() ?>
</div>
<?php if (!$isHomepage): ?>
<?= /* @noEscape */ $block->getChildHtml('parameter_comparison') ?>
<?= /* @noEscape */ $block->getChildHtml('download_center') ?>
<?php endif; ?>
</article>
<?php if ($previousCategory || $nextCategory): ?>
<nav class="esun-wiki-bottom-nav" aria-label="<?= $block->escapeHtmlAttr(__('Wiki previous and next')) ?>">
<?php if ($previousCategory): ?>
<a class="esun-wiki-bottom-link esun-wiki-bottom-link-previous"
href="<?= $block->escapeUrl($block->getCategoryUrl($previousCategory)) ?>">
<span class="esun-wiki-bottom-arrow" aria-hidden="true"></span>
<span class="esun-wiki-bottom-text">
<strong><?= $block->escapeHtml(__('Previous')) ?></strong>
<span><?= $block->escapeHtml((string) $previousCategory->getData('title')) ?></span>
</span>
</a>
<?php else: ?>
<span class="esun-wiki-bottom-link esun-wiki-bottom-link-previous is-disabled"></span>
<?php endif; ?>
<?php if ($nextCategory): ?>
<a class="esun-wiki-bottom-link esun-wiki-bottom-link-next"
href="<?= $block->escapeUrl($block->getCategoryUrl($nextCategory)) ?>">
<span class="esun-wiki-bottom-text">
<strong><?= $block->escapeHtml(__('Next')) ?></strong>
<span><?= $block->escapeHtml((string) $nextCategory->getData('title')) ?></span>
</span>
<span class="esun-wiki-bottom-arrow esun-wiki-bottom-arrow-next" aria-hidden="true"></span>
</a>
<?php else: ?>
<span class="esun-wiki-bottom-link esun-wiki-bottom-link-next is-disabled"></span>
<?php endif; ?>
</nav>
<?php endif; ?>
<?php else: ?>
<div class="esun-wiki-empty">
<?= $block->escapeHtml(__('No wiki categories are available yet. Add content from the Magento admin.')) ?>
</div>
<?php endif; ?>
</main>
<?php if ($anchors): ?>
<aside class="esun-wiki-toc esun-wiki-drawer esun-wiki-drawer--right"
id="esun-wiki-anchor-drawer"
data-wiki-drawer="anchors"
aria-label="<?= $block->escapeHtmlAttr(__('Wiki content anchors')) ?>">
<div class="esun-wiki-drawer-header">
<strong><?= $block->escapeHtml(__('On this page')) ?></strong>
<button class="esun-wiki-drawer-close"
type="button"
data-wiki-drawer-close
aria-label="<?= $block->escapeHtmlAttr(__('Close content anchors')) ?>">
<span aria-hidden="true"></span>
</button>
</div>
<div class="esun-wiki-toc-card">
<ul>
<?php foreach ($anchors as $anchor): ?>
<li class="level-<?= (int) $anchor['level'] ?>">
<a href="#<?= $block->escapeHtmlAttr($anchor['id']) ?>">
<?= $block->escapeHtml($anchor['label']) ?>
</a>
</li>
<?php endforeach; ?>
</ul>
</div>
</aside>
<?php endif; ?>
</div>
<?php if ($tooltips): ?>
<div class="esun-wiki-tooltip-layer" aria-live="polite">
<?php foreach ($tooltips as $tooltip): ?>
<div class="esun-wiki-tooltip esun-wiki-tooltip--<?= $block->escapeHtmlAttr($tooltip['type']) ?>"
id="<?= $block->escapeHtmlAttr($tooltip['id']) ?>"
data-wiki-tooltip-id="<?= $block->escapeHtmlAttr($tooltip['id']) ?>"
role="dialog"
aria-label="<?= $block->escapeHtmlAttr(
$tooltip['type'] === 'product' ? $tooltip['name'] : $tooltip['title']
) ?>"
aria-modal="false"
aria-hidden="true">
<?php if ($tooltip['type'] === 'product'): ?>
<div class="esun-wiki-product-tip__visual">
<a href="<?= $block->escapeUrl($tooltip['product_url']) ?>"
aria-label="<?= $block->escapeHtmlAttr($tooltip['name']) ?>">
<?php if ($tooltip['image_url'] !== ''): ?>
<img src="<?= $block->escapeUrl($tooltip['image_url']) ?>"
alt="<?= $block->escapeHtmlAttr($tooltip['name']) ?>"
loading="lazy">
<?php endif; ?>
</a>
<div class="esun-wiki-product-tip__price">
<strong><?= $block->escapeHtml($tooltip['final_price']) ?></strong>
<?php if ($tooltip['regular_price'] !== ''): ?>
<del><?= $block->escapeHtml($tooltip['regular_price']) ?></del>
<?php endif; ?>
</div>
<div class="esun-wiki-product-tip__action">
<?php if ($tooltip['can_add_to_cart']): ?>
<form data-role="tocart-form"
data-product-sku="<?= $block->escapeHtmlAttr($tooltip['sku']) ?>"
action="<?= $block->escapeUrl($tooltip['add_to_cart']['action']) ?>"
data-mage-init='{"catalogAddToCart": {}}'
method="post">
<input type="hidden" name="product"
value="<?= (int) $tooltip['add_to_cart']['product'] ?>">
<input type="hidden" name="uenc"
value="<?= $block->escapeHtmlAttr($tooltip['add_to_cart']['uenc']) ?>">
<?= $block->getBlockHtml('formkey') ?>
<button class="esun-wiki-product-tip__cart" type="submit"
title="<?= $block->escapeHtmlAttr(__('Add to Cart')) ?>">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"/>
</svg>
<span><?= $block->escapeHtml(__('Add to Cart')) ?></span>
</button>
</form>
<?php elseif ($tooltip['is_saleable']): ?>
<a class="esun-wiki-product-tip__cart"
href="<?= $block->escapeUrl($tooltip['product_url']) ?>"
title="<?= $block->escapeHtmlAttr(__('Choose Options')) ?>">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"/>
</svg>
<span><?= $block->escapeHtml(__('Choose Options')) ?></span>
</a>
<?php else: ?>
<button class="esun-wiki-product-tip__cart is-disabled" type="button" disabled
title="<?= $block->escapeHtmlAttr(__('Out of stock')) ?>">
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z"/>
</svg>
<span><?= $block->escapeHtml(__('Out of stock')) ?></span>
</button>
<?php endif; ?>
</div>
</div>
<a class="esun-wiki-product-tip__name"
href="<?= $block->escapeUrl($tooltip['product_url']) ?>">
<?= $block->escapeHtml($tooltip['name']) ?>
</a>
<?php else: ?>
<?php if ($tooltip['image_url'] !== ''): ?>
<div class="esun-wiki-term-tip__image">
<img src="<?= $block->escapeUrl($tooltip['image_url']) ?>"
alt="<?= $block->escapeHtmlAttr($tooltip['image_alt']) ?>">
</div>
<?php endif; ?>
<?php if ($tooltip['link_label'] !== ''): ?>
<?php if ($tooltip['link_url'] !== ''): ?>
<a class="esun-wiki-term-tip__link"
href="<?= $block->escapeUrl($tooltip['link_url']) ?>">
<?= $block->escapeHtml($tooltip['link_label']) ?>
</a>
<?php else: ?>
<span class="esun-wiki-term-tip__link">
<?= $block->escapeHtml($tooltip['link_label']) ?>
</span>
<?php endif; ?>
<?php endif; ?>
<?php if ($tooltip['title'] !== ''): ?>
<strong class="esun-wiki-term-tip__title">
<?= $block->escapeHtml($tooltip['title']) ?>
</strong>
<?php endif; ?>
<?php if ($tooltip['description'] !== ''): ?>
<p class="esun-wiki-term-tip__description">
<?= $block->escapeHtml($tooltip['description']) ?>
</p>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
@@ -0,0 +1,329 @@
.esun-wiki-download-center {
margin-top: 48px;
}
.esun-wiki-download-center .esun-download-specifications__filters {
display: grid;
gap: 24px;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
margin: 0 0 46px;
}
.esun-wiki-download-center .esun-download-specifications__field {
color: #6c9b73;
display: grid;
font-size: 12px;
font-weight: 700;
gap: 8px;
letter-spacing: 2px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__field select {
background: #fbfffc;
border: 1px solid #dcefe4;
border-radius: 10px;
box-shadow: none;
color: #333;
font-size: 15px;
font-weight: 400;
height: 48px;
letter-spacing: 0;
padding: 0 18px;
text-transform: none;
width: 100%;
}
.esun-wiki-download-center .esun-download-specifications__count {
align-items: center;
color: #6c9b73;
display: flex;
font-size: 12px;
font-weight: 700;
gap: 8px;
letter-spacing: 2px;
margin: 0 0 22px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__count strong {
align-items: center;
background: #eef6f0;
border-radius: 8px;
color: #91a8bc;
display: inline-flex;
font-size: 12px;
height: 22px;
justify-content: center;
min-width: 22px;
padding: 0 7px;
}
.esun-wiki-download-center .esun-download-specifications__empty {
align-items: center;
border: 2px dashed #e4edf7;
border-radius: 16px;
color: #64748b;
display: flex;
flex-direction: column;
justify-content: center;
min-height: 220px;
padding: 44px 24px;
text-align: center;
}
.esun-wiki-download-center .esun-download-specifications__empty-icon {
border: 4px solid #e6eef7;
border-radius: 50%;
display: block;
height: 34px;
margin-bottom: 22px;
position: relative;
width: 34px;
}
.esun-wiki-download-center .esun-download-specifications__empty-icon::after {
background: #e6eef7;
content: "";
height: 14px;
position: absolute;
right: -8px;
top: 23px;
transform: rotate(-45deg);
width: 4px;
}
.esun-wiki-download-center .esun-download-specifications__empty strong {
color: #1f2937;
font-size: 20px;
margin-bottom: 12px;
}
.esun-wiki-download-center .esun-download-specifications__empty p {
line-height: 1.55;
margin: 0;
max-width: 420px;
}
.esun-wiki-download-center .esun-download-specifications__list {
display: grid;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__item {
align-items: center;
border: 1px solid #dcefe4;
border-radius: 12px;
color: #1f2937;
display: grid;
gap: 22px;
grid-template-columns: 48px minmax(0, 1fr) auto;
min-height: 110px;
padding: 22px 26px;
text-decoration: none;
}
.esun-wiki-download-center .esun-download-specifications__item:hover,
.esun-wiki-download-center .esun-download-specifications__item:focus {
border-color: #18a957;
color: #1f2937;
text-decoration: none;
}
.esun-wiki-download-center .esun-download-specifications__logo {
align-items: center;
background: #effaf3;
border-radius: 8px;
display: inline-flex;
height: 48px;
justify-content: center;
width: 48px;
}
.esun-wiki-download-center .esun-download-specifications__logo img {
max-height: 34px;
max-width: 34px;
object-fit: contain;
}
.esun-wiki-download-center .esun-download-specifications__body {
display: grid;
gap: 10px;
min-width: 0;
}
.esun-wiki-download-center .esun-download-specifications__meta {
align-items: center;
color: #75a67a;
display: flex;
flex-wrap: wrap;
font-size: 12px;
gap: 8px;
}
.esun-wiki-download-center .esun-download-specifications__brand {
border: 1px solid #9fe4b8;
border-radius: 5px;
color: #18a957;
font-size: 11px;
font-weight: 700;
padding: 2px 8px;
text-transform: uppercase;
}
.esun-wiki-download-center .esun-download-specifications__model::before {
content: "\2022";
margin-right: 8px;
}
.esun-wiki-download-center .esun-download-specifications__body strong {
color: #111827;
font-size: 22px;
line-height: 1.2;
}
.esun-wiki-download-center .esun-download-specifications__info {
color: #8db694;
display: flex;
font-size: 12px;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__action {
align-items: center;
display: inline-flex;
gap: 18px;
}
.esun-wiki-download-center .esun-download-specifications__download-text {
color: #333;
font-size: 16px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon {
align-items: center;
background: #18a957;
border-radius: 50%;
display: inline-flex;
height: 48px;
justify-content: center;
position: relative;
width: 48px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon::before {
border-bottom: 2px solid #fff;
border-left: 2px solid #fff;
content: "";
height: 10px;
margin-top: -4px;
transform: rotate(-45deg);
width: 10px;
}
.esun-wiki-download-center .esun-download-specifications__download-icon::after {
background: #fff;
content: "";
height: 16px;
left: 50%;
position: absolute;
top: 14px;
transform: translateX(-50%);
width: 2px;
}
.esun-wiki-download-center .esun-download-specifications__pagination {
align-items: center;
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
margin-top: 32px;
}
.esun-wiki-download-center .esun-download-specifications__pagination:empty {
display: none;
}
.esun-wiki-download-center .esun-download-specifications__page {
align-items: center;
background: #fff;
border: 1px solid #dcefe4;
border-radius: 8px;
color: #334155;
cursor: pointer;
display: inline-flex;
font-size: 14px;
height: 38px;
justify-content: center;
min-width: 38px;
padding: 0 12px;
}
.esun-wiki-download-center .esun-download-specifications__page:hover,
.esun-wiki-download-center .esun-download-specifications__page:focus-visible {
border-color: #18a957;
color: #18a957;
}
.esun-wiki-download-center .esun-download-specifications__page.is-active {
background: #18a957;
border-color: #18a957;
color: #fff;
font-weight: 700;
}
.esun-wiki-download-center .esun-download-specifications__page:disabled {
background: #f8fafc;
border-color: #e5e7eb;
color: #94a3b8;
cursor: default;
}
.esun-wiki-download-center .esun-download-specifications__ellipsis {
color: #94a3b8;
min-width: 24px;
text-align: center;
}
@media (max-width: 767px) {
.esun-wiki-download-center {
margin-top: 32px;
}
.esun-wiki-download-center .esun-download-specifications__filters {
grid-template-columns: 1fr;
margin-bottom: 32px;
}
.esun-wiki-download-center .esun-download-specifications__item {
gap: 16px;
grid-template-columns: 42px minmax(0, 1fr);
padding: 20px;
}
.esun-wiki-download-center .esun-download-specifications__logo {
height: 42px;
width: 42px;
}
.esun-wiki-download-center .esun-download-specifications__body strong {
font-size: 18px;
overflow-wrap: anywhere;
}
.esun-wiki-download-center .esun-download-specifications__action {
grid-column: 2;
justify-content: space-between;
}
.esun-wiki-download-center .esun-download-specifications__pagination {
margin-top: 24px;
}
.esun-wiki-download-center .esun-download-specifications__page {
height: 36px;
min-width: 36px;
padding: 0 10px;
}
}
@@ -0,0 +1,438 @@
.esun-parameter-comparison {
--pc-green: #17a957;
--pc-dark: #303631;
--pc-muted: #8a928d;
--pc-line: #d9eadf;
margin: 45px 0 55px;
color: var(--pc-dark);
font-size: 14px;
}
.esun-parameter-comparison__app {
width: 100%;
}
.esun-parameter-comparison__selector {
border: 1px solid var(--pc-line);
border-radius: 18px;
background: #fff;
overflow: hidden;
}
.esun-parameter-comparison__selector-row {
display: block;
padding: 28px 30px;
}
.esun-parameter-comparison__selector-row + .esun-parameter-comparison__selector-row {
border-top: 1px solid var(--pc-line);
}
.esun-parameter-comparison__row-title strong {
display: block;
color: #4d735e;
font-size: 13px;
font-weight: 700;
letter-spacing: .12em;
text-transform: uppercase;
}
.esun-parameter-comparison__row-title span {
display: block;
margin-top: 7px;
color: var(--pc-muted);
font-size: 13px;
}
.esun-parameter-comparison__row-title {
margin-bottom: 20px;
}
.esun-parameter-comparison__base-options {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.esun-parameter-comparison__base-options label {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 42px;
box-sizing: border-box;
padding: 0 15px;
border: 2px solid #cfe4d7;
border-radius: 999px;
color: #657069;
font-size: 13px;
cursor: pointer;
transition: .2s ease;
}
.esun-parameter-comparison__base-options input {
position: absolute;
opacity: 0;
pointer-events: none;
}
.esun-parameter-comparison__dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: #afbeb5;
}
.esun-parameter-comparison__base-options small {
color: #8d9891;
}
.esun-parameter-comparison__base-options label:has(input:checked) {
border-color: var(--pc-green);
background: #f2fbf6;
color: var(--pc-green);
}
.esun-parameter-comparison__base-options label:has(input:checked) .esun-parameter-comparison__dot {
background: var(--pc-green);
}
.esun-parameter-comparison__series-area {
min-width: 0;
}
.esun-parameter-comparison__series-summary {
display: flex;
justify-content: flex-end;
gap: 8px;
margin-bottom: 14px;
color: #747d77;
font-size: 13px;
}
.esun-parameter-comparison__series-summary strong {
color: var(--pc-green);
}
.esun-parameter-comparison__series-list {
column-count: 3;
column-gap: 12px;
}
.esun-parameter-comparison__series-row {
display: inline-block;
box-sizing: border-box;
width: 100%;
min-width: 0;
margin: 0 0 12px;
padding: 15px;
border: 1px solid #dcebe1;
border-radius: 12px;
background: #fbfdfc;
break-inside: avoid;
vertical-align: top;
}
.esun-parameter-comparison__series-name {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 8px;
padding: 0 0 11px;
}
.esun-parameter-comparison__series-name strong {
font-size: 14px;
}
.esun-parameter-comparison__series-name span {
min-width: 27px;
padding: 2px 7px;
border: 1px solid #cce6d6;
border-radius: 999px;
background: #f2faf5;
color: #55976f;
text-align: center;
}
.esun-parameter-comparison__series-products {
display: flex;
flex-wrap: wrap;
gap: 7px;
}
.esun-parameter-comparison__product {
min-height: 36px;
max-width: 100%;
padding: 0 12px;
border: 1px solid #cfe1d5;
border-radius: 999px;
background: #fff;
color: #68726c;
font-size: 13px;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.esun-parameter-comparison__product:hover,
.esun-parameter-comparison__product.is-selected {
border-color: var(--pc-green);
background: var(--pc-green);
color: #fff;
}
.esun-parameter-comparison__product:disabled {
opacity: .45;
cursor: not-allowed;
}
.esun-parameter-comparison__notice {
min-height: 20px;
margin: 7px 0 0;
color: #b43e32;
}
.esun-parameter-comparison__selected {
display: flex;
flex-wrap: wrap;
gap: 9px;
min-height: 40px;
margin-top: 5px;
}
.esun-parameter-comparison__selected-pill {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 7px 9px 7px 14px;
border: 1px solid #b9dfc8;
border-radius: 999px;
background: #f0faf4;
color: #315e43;
font-size: 13px;
}
.esun-parameter-comparison__selected-pill button,
.esun-parameter-comparison thead button {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
padding: 0;
border: 0;
border-radius: 50%;
background: #dcefe3;
color: #4c7a5e;
}
.esun-parameter-comparison__comparison {
margin-top: 36px;
}
.esun-parameter-comparison__comparison-head {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
margin-bottom: 16px;
}
.esun-parameter-comparison__comparison-head h2 {
margin: 0 0 4px;
font-size: 23px;
}
.esun-parameter-comparison__comparison-head p {
margin: 0;
color: var(--pc-muted);
font-size: 13px;
}
.esun-parameter-comparison__modes {
display: inline-flex;
padding: 4px;
border: 1px solid var(--pc-line);
border-radius: 10px;
background: #fff;
}
.esun-parameter-comparison__modes button {
padding: 9px 16px;
border: 0;
border-radius: 7px;
background: transparent;
color: #929a95;
font-size: 13px;
}
.esun-parameter-comparison__modes button.is-active {
background: var(--pc-green);
color: #fff;
}
.esun-parameter-comparison__placeholder {
padding: 52px 25px;
border: 1px solid var(--pc-line);
border-radius: 14px;
color: var(--pc-muted);
text-align: center;
}
.esun-parameter-comparison__table-wrap {
display: none;
max-height: 720px;
border: 1px solid var(--pc-line);
border-radius: 14px;
overflow: auto;
}
.esun-parameter-comparison table {
width: 100%;
min-width: 780px;
margin: 0;
border-collapse: separate;
border-spacing: 0;
font-size: 13px;
}
.esun-parameter-comparison__table-wrap.is-single table {
min-width: 0;
}
.esun-parameter-comparison__table-wrap.is-single th:first-child {
width: 46%;
min-width: 0;
}
.esun-parameter-comparison th,
.esun-parameter-comparison td {
padding: 15px 18px;
border-right: 1px solid #e3eee7;
border-bottom: 1px solid #e3eee7;
background: #fff;
color: var(--pc-dark);
vertical-align: top;
white-space: pre-line;
}
.esun-parameter-comparison thead th {
position: sticky;
top: 0;
z-index: 3;
background: #f4faf6;
color: var(--pc-dark) !important;
text-align: left;
}
.esun-parameter-comparison thead th span {
margin-right: 9px;
color: var(--pc-dark) !important;
}
.esun-parameter-comparison th:first-child {
position: sticky;
left: 0;
z-index: 2;
width: 29%;
min-width: 245px;
}
.esun-parameter-comparison thead th:first-child {
z-index: 4;
}
.esun-parameter-comparison__group-row th {
left: 0;
z-index: 2;
background: #eff9f3;
color: var(--pc-green);
font-size: 13px;
letter-spacing: .09em;
text-transform: uppercase;
}
@media (max-width: 900px) {
.esun-parameter-comparison__selector-row {
padding: 24px 22px;
}
.esun-parameter-comparison__series-list {
column-count: 2;
}
}
@media (max-width: 640px) {
.esun-parameter-comparison {
margin: 28px 0 40px;
}
.esun-parameter-comparison__selector-row {
padding: 18px 14px;
}
.esun-parameter-comparison__row-title {
margin-bottom: 15px;
}
.esun-parameter-comparison__base-options {
flex-wrap: nowrap;
padding-bottom: 5px;
overflow-x: auto;
}
.esun-parameter-comparison__base-options label {
flex: 0 0 auto;
min-height: 36px;
padding: 0 11px;
font-size: 12px;
}
.esun-parameter-comparison__base-options label:has(input:checked) {
padding: 0 11px;
}
.esun-parameter-comparison__series-row {
padding: 13px;
}
.esun-parameter-comparison__series-name {
justify-content: flex-start;
padding-top: 2px;
}
.esun-parameter-comparison__series-products {
gap: 7px;
}
.esun-parameter-comparison__series-list {
column-count: 1;
}
.esun-parameter-comparison__product {
min-height: 33px;
padding: 0 11px;
font-size: 12px;
}
.esun-parameter-comparison__comparison-head {
align-items: stretch;
flex-direction: column;
}
.esun-parameter-comparison__comparison-head h2 {
font-size: 20px;
}
.esun-parameter-comparison__modes {
overflow-x: auto;
}
.esun-parameter-comparison__modes button {
flex: 0 0 auto;
padding: 8px 11px;
font-size: 12px;
}
.esun-parameter-comparison th,
.esun-parameter-comparison td {
padding: 11px 12px;
font-size: 12px;
}
.esun-parameter-comparison__table-wrap:not(.is-single) table {
min-width: 680px;
}
.esun-parameter-comparison__table-wrap.is-single table {
width: 100%;
table-layout: fixed;
}
.esun-parameter-comparison__table-wrap.is-single th,
.esun-parameter-comparison__table-wrap.is-single td {
overflow-wrap: anywhere;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,211 @@
define(['jquery', 'mage/translate'], function ($, $t) {
'use strict';
return function (config, element) {
var $root = $(element),
items = config.items || [],
archives = config.archives || [],
brands = config.brands || [],
modelsByBrand = config.modelsByBrand || {},
pageSize = 20,
currentPage = 1,
$brand = $root.find('[data-role="spec-brand"]'),
$model = $root.find('[data-role="spec-model"]'),
$count = $root.find('[data-role="spec-count"]'),
$empty = $root.find('[data-role="spec-empty"]'),
$list = $root.find('[data-role="spec-list"]'),
$pagination = $root.find('[data-role="spec-pagination"]');
function renderBrands() {
$.each(brands, function (_, brandItem) {
$('<option/>', {
value: brandItem.id,
text: brandItem.name
}).appendTo($brand);
});
}
function renderModels() {
var brandId = $brand.val(),
models = brandId ? (modelsByBrand[brandId] || []).slice() : [];
if (!brandId) {
$.each(modelsByBrand, function (_, brandModels) {
$.each(brandModels, function (_, modelName) {
if ($.inArray(modelName, models) === -1) {
models.push(modelName);
}
});
});
models.sort();
}
$model.empty().append($('<option/>', {
value: '',
text: $t('All Models')
}));
$.each(models, function (_, modelName) {
$('<option/>', {
value: modelName,
text: modelName
}).appendTo($model);
});
}
function filterItems() {
var brandId = $brand.val(),
modelName = $model.val(),
results;
if (!brandId && !modelName) {
return archives.slice();
}
results = $.grep(items, function (item) {
return (!brandId || String(item.brand_id) === String(brandId)) &&
(!modelName || item.model_name === modelName);
});
if (brandId) {
results = $.grep(archives, function (archive) {
return String(archive.brand_id) === String(brandId);
}).concat(results);
}
return results;
}
function createPageButton(label, page, options) {
var settings = options || {},
$button = $('<button/>', {
'class': 'esun-download-specifications__page' + (settings.active ? ' is-active' : ''),
type: 'button',
text: label,
disabled: settings.disabled || false,
'aria-label': settings.ariaLabel || null,
'aria-current': settings.active ? 'page' : null
});
if (!settings.disabled && !settings.active) {
$button.on('click', function () {
currentPage = page;
renderList();
$root.get(0).scrollIntoView({behavior: 'smooth', block: 'start'});
});
}
return $button;
}
function renderPagination(totalPages) {
var pages = [],
previousPage = 0;
$pagination.empty();
if (totalPages <= 1) {
return;
}
$pagination.append(createPageButton($t('Previous'), currentPage - 1, {
disabled: currentPage === 1,
ariaLabel: $t('Previous page')
}));
for (var page = 1; page <= totalPages; page++) {
if (page === 1 || page === totalPages || Math.abs(page - currentPage) <= 2) {
pages.push(page);
}
}
$.each(pages, function (_, page) {
if (previousPage && page - previousPage > 1) {
$('<span/>', {
'class': 'esun-download-specifications__ellipsis',
text: '…',
'aria-hidden': 'true'
}).appendTo($pagination);
}
$pagination.append(createPageButton(String(page), page, {
active: page === currentPage,
ariaLabel: $t('Page %1').replace('%1', page)
}));
previousPage = page;
});
$pagination.append(createPageButton($t('Next'), currentPage + 1, {
disabled: currentPage === totalPages,
ariaLabel: $t('Next page')
}));
}
function renderItem(item) {
var $item = $('<a/>', {
'class': 'esun-download-specifications__item',
href: item.file_url,
download: item.file_name
}),
$logo = $('<span/>', {'class': 'esun-download-specifications__logo'}),
$body = $('<span/>', {'class': 'esun-download-specifications__body'}),
$meta = $('<span/>', {'class': 'esun-download-specifications__meta'}),
$info = $('<span/>', {'class': 'esun-download-specifications__info'}),
$action = $('<span/>', {'class': 'esun-download-specifications__action'});
if (item.brand_logo_url) {
$('<img/>', {src: item.brand_logo_url, alt: ''}).appendTo($logo);
}
$('<span/>', {'class': 'esun-download-specifications__brand', text: item.brand_name}).appendTo($meta);
if (item.model_name) {
$('<span/>', {'class': 'esun-download-specifications__model', text: item.model_name}).appendTo($meta);
}
$('<strong/>', {text: item.file_name}).appendTo($body);
$('<span/>', {text: item.file_size_label}).appendTo($info);
if (item.file_date) {
$('<span/>', {text: item.file_date}).appendTo($info);
}
$('<span/>', {
'class': 'esun-download-specifications__download-text',
text: $t('Download')
}).appendTo($action);
$('<span/>', {'class': 'esun-download-specifications__download-icon'}).appendTo($action);
$body.prepend($meta).append($info);
$item.append($logo, $body, $action).appendTo($list);
}
function renderList() {
var results = filterItems(),
totalPages = Math.ceil(results.length / pageSize),
start;
if (totalPages > 0 && currentPage > totalPages) {
currentPage = totalPages;
}
$count.text(results.length);
$list.empty();
$empty.toggle(results.length === 0);
$list.toggle(results.length > 0);
start = (currentPage - 1) * pageSize;
$.each(results.slice(start, start + pageSize), function (_, item) {
renderItem(item);
});
renderPagination(totalPages);
}
renderBrands();
renderModels();
renderList();
$brand.on('change', function () {
currentPage = 1;
renderModels();
renderList();
});
$model.on('change', function () {
currentPage = 1;
renderList();
});
};
});
@@ -0,0 +1,236 @@
define(['jquery', 'mage/translate'], function ($, $t) {
'use strict';
return function (config, element) {
var $root = $(element),
rawConfig = $root.find('[data-role="parameter-config"]').text(),
data = rawConfig ? JSON.parse(rawConfig) : {},
products = data.products || [],
applicationOptions = data.applicationOptions || [],
messages = data.messages || {},
maximum = 6,
selected = [],
mode = 'key',
keyParameters = [
'Density(g/cm3) (unit to be confirmed)',
'Heat Distortion Temperature(°C)',
'Tensile Strength (XY) (MPa)',
'Elongation at Break (XY) (%)',
'Flexural Strength (XY) (MPa)',
'Flexural Modulus (XY) (MPa)',
'IZOD Impact Strength (XY) (kJ/m²)',
'Extruder Temperature(°C)',
'Bed Temperature(°C)',
'Fan Speed(%)',
'Printing Speed(mm/s) (high-speed printing parameter)',
'Printing Recommendation',
'Drying'
],
$seriesList = $root.find('[data-role="series-list"]'),
$selectedMaterials = $root.find('[data-role="selected-materials"]'),
$notice = $root.find('[data-role="material-notice"]'),
$selectionCount = $root.find('[data-role="selection-count"]'),
$comparisonCount = $root.find('[data-role="comparison-count"]'),
$resultCount = $root.find('[data-role="result-count"]'),
$placeholder = $root.find('[data-role="comparison-placeholder"]'),
$tableWrap = $root.find('[data-role="comparison-table-wrap"]'),
$head = $root.find('[data-role="comparison-head"]'),
$body = $root.find('[data-role="comparison-body"]');
function selectedBase() {
return $root.find('[data-role="base-filter"]:checked').val() || '';
}
function productsForBase() {
var base = selectedBase();
return $.grep(products, function (product) { return product.base === base; });
}
function primaryApplication(product) {
return product.applications && product.applications.length ? product.applications[0] : 'other';
}
function applicationLabel(value) {
var option = applicationOptions.find(function (item) { return item.value === value; });
return option ? option.label : $t('Other Series');
}
function isSelected(id) {
return $.inArray(id, selected) !== -1;
}
function findProduct(id) {
return products.find(function (product) { return product.id === id; });
}
function renderSeries() {
var baseProducts = productsForBase(), groups = {};
$.each(baseProducts, function (_, product) {
var application = primaryApplication(product);
groups[application] = groups[application] || [];
groups[application].push(product);
});
$seriesList.empty();
$.each(applicationOptions, function (_, option) {
var groupProducts = groups[option.value] || [];
if (!groupProducts.length) {
return;
}
renderSeriesRow(option.label, groupProducts);
delete groups[option.value];
});
$.each(groups, function (application, groupProducts) {
renderSeriesRow(applicationLabel(application), groupProducts);
});
$resultCount.text(baseProducts.length);
updateSelection();
}
function renderSeriesRow(label, groupProducts) {
var $row = $('<div/>', {'class': 'esun-parameter-comparison__series-row'}),
$label = $('<div/>', {'class': 'esun-parameter-comparison__series-name'}),
$products = $('<div/>', {'class': 'esun-parameter-comparison__series-products'});
$label.append($('<strong/>', {text: label}), $('<span/>', {text: groupProducts.length}));
$.each(groupProducts, function (_, product) {
$('<button/>', {
type: 'button',
'class': 'esun-parameter-comparison__product' + (isSelected(product.id) ? ' is-selected' : ''),
text: product.name,
title: product.name,
disabled: !isSelected(product.id) && selected.length >= maximum,
'data-role': 'material-option',
'data-id': product.id
}).appendTo($products);
});
$row.append($label, $products).appendTo($seriesList);
}
function updateSelection() {
$selectionCount.text(selected.length);
$comparisonCount.text(selected.length);
$selectedMaterials.empty();
$.each(selected, function (_, id) {
var product = findProduct(id), $pill;
if (!product) {
return;
}
$pill = $('<span/>', {'class': 'esun-parameter-comparison__selected-pill'});
$pill.append(
$('<span/>', {text: product.name}),
$('<button/>', {
type: 'button',
text: '×',
'aria-label': $t('Remove %1').replace('%1', product.name),
'data-role': 'remove-material',
'data-id': id
})
).appendTo($selectedMaterials);
});
renderComparison();
}
function removeMaterial(id) {
selected = $.grep(selected, function (selectedId) { return selectedId !== id; });
$notice.text('');
renderSeries();
}
function parameterIsVisible(name, values) {
if (mode === 'key' && $.inArray(name, keyParameters) === -1) {
return false;
}
if (mode === 'differences') {
return values.filter(function (value, index, array) {
return array.indexOf(value) === index;
}).length > 1;
}
return true;
}
function renderComparison() {
var selectedProducts = $.map(selected, findProduct),
groups = data.parameterGroups || {};
$head.empty();
$body.empty();
if (selectedProducts.length < 1) {
$placeholder.show();
$tableWrap.hide();
return;
}
$tableWrap.toggleClass('is-single', selectedProducts.length === 1);
var $headerRow = $('<tr/>').append($('<th/>', {text: $t('Parameter')}));
$.each(selectedProducts, function (_, product) {
var $name = $('<span/>', {text: product.name}),
$remove = $('<button/>', {
type: 'button', text: '×',
'aria-label': $t('Remove %1').replace('%1', product.name),
'data-role': 'remove-material', 'data-id': product.id
});
$headerRow.append($('<th/>').append($name, $remove));
});
$head.append($headerRow);
$.each(groups, function (groupName, parameters) {
var rows = [];
$.each(parameters, function (_, parameterName) {
var values = $.map(selectedProducts, function (product) {
var value = product.groups[groupName] && product.groups[groupName][parameterName];
return value === undefined || value === null || value === ''
? (messages.missingValue || '—') : String(value);
});
if (!parameterIsVisible(parameterName, values)) {
return;
}
var $row = $('<tr/>').append($('<th/>', {scope: 'row', text: parameterName}));
$.each(values, function (_, value) { $row.append($('<td/>').text(value)); });
rows.push($row);
});
if (rows.length) {
$body.append($('<tr/>', {'class': 'esun-parameter-comparison__group-row'})
.append($('<th/>', {colspan: selectedProducts.length + 1, text: groupName})));
$.each(rows, function (_, row) { $body.append(row); });
}
});
$placeholder.hide();
$tableWrap.show();
}
$root.on('change', '[data-role="base-filter"]', function () {
selected = [];
$notice.text('');
renderSeries();
});
$root.on('click', '[data-role="material-option"]', function () {
var id = $(this).data('id');
if (isSelected(id)) {
removeMaterial(id);
return;
}
if (selected.length >= maximum) {
$notice.text($t('You can compare up to 6 materials.'));
return;
}
selected.push(id);
$notice.text('');
renderSeries();
});
$root.on('click', '[data-role="remove-material"]', function () {
removeMaterial($(this).data('id'));
});
$root.on('click', '[data-role="comparison-mode"]', function () {
mode = $(this).data('mode');
$root.find('[data-role="comparison-mode"]').removeClass('is-active');
$(this).addClass('is-active');
renderComparison();
});
renderSeries();
};
});
@@ -0,0 +1,296 @@
define([
'jquery'
], function ($) {
'use strict';
return function (config, element) {
var $root = $(element),
$activeTrigger = $(),
$activeTooltip = $(),
$drawers = $root.find('[data-wiki-drawer]'),
$drawerBackdrop = $root.find('.esun-wiki-drawer-backdrop'),
$activeDrawer = $(),
$activeDrawerTrigger = $(),
drawerMedia = window.matchMedia('(max-width: 860px)'),
hideTimer = null;
function syncSearchClear($input) {
var hasValue = $.trim($input.val()).length > 0;
$input.closest('form').find('.esun-wiki-search-clear').toggleClass('is-visible', hasValue);
}
function cancelTooltipHide() {
if (hideTimer) {
window.clearTimeout(hideTimer);
hideTimer = null;
}
}
function positionTooltip($trigger, $tooltip) {
var triggerRect = $trigger[0].getBoundingClientRect(),
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
gutter = 14,
gap = 18,
tooltipWidth,
tooltipHeight,
left,
top,
arrowLeft,
showBelow;
$tooltip
.addClass('is-active')
.css({left: 0, top: 0, visibility: 'hidden'});
tooltipWidth = $tooltip.outerWidth();
tooltipHeight = $tooltip.outerHeight();
left = triggerRect.left + (triggerRect.width / 2) - (tooltipWidth / 2);
left = Math.max(gutter, Math.min(left, viewportWidth - tooltipWidth - gutter));
top = triggerRect.top - tooltipHeight - gap;
showBelow = top < gutter;
if (showBelow) {
top = triggerRect.bottom + gap;
}
top = Math.max(gutter, Math.min(top, viewportHeight - tooltipHeight - gutter));
arrowLeft = triggerRect.left + (triggerRect.width / 2) - left;
arrowLeft = Math.max(26, Math.min(arrowLeft, tooltipWidth - 26));
$tooltip
.toggleClass('is-below', showBelow)
.css({
left: Math.round(left),
top: Math.round(top),
visibility: 'visible',
'--esun-wiki-tip-arrow-left': Math.round(arrowLeft) + 'px'
});
}
function closeTooltip(restoreFocus) {
cancelTooltipHide();
if ($activeTooltip.length) {
$activeTooltip
.removeClass('is-active is-below')
.attr('aria-hidden', 'true')
.removeAttr('style');
}
if ($activeTrigger.length) {
$activeTrigger.attr('aria-expanded', 'false');
if (restoreFocus) {
$activeTrigger.trigger('focus');
}
}
$activeTrigger = $();
$activeTooltip = $();
}
function showTooltip($trigger) {
var tooltipId = $trigger.attr('data-wiki-tip'),
$tooltip = $root.find('[data-wiki-tooltip-id="' + tooltipId + '"]');
if (!$tooltip.length) {
return;
}
cancelTooltipHide();
if ($activeTooltip.length && $activeTooltip[0] !== $tooltip[0]) {
closeTooltip(false);
}
$activeTrigger = $trigger;
$activeTooltip = $tooltip;
$trigger.attr('aria-expanded', 'true');
$tooltip.attr('aria-hidden', 'false');
positionTooltip($trigger, $tooltip);
}
function scheduleTooltipHide() {
cancelTooltipHide();
hideTimer = window.setTimeout(function () {
closeTooltip(false);
}, 140);
}
function closeDrawer(restoreFocus) {
var $trigger = $activeDrawerTrigger;
$drawers.removeClass('is-open');
$root.find('[data-wiki-drawer-open]').attr('aria-expanded', 'false');
$drawerBackdrop.removeClass('is-visible').attr('aria-hidden', 'true');
$('html, body').removeClass('esun-wiki-drawer-lock');
if (restoreFocus && $trigger.length) {
$trigger.trigger('focus');
}
if (drawerMedia.matches) {
$drawers.attr('aria-hidden', 'true');
} else {
$drawers.removeAttr('aria-hidden');
}
$activeDrawer = $();
$activeDrawerTrigger = $();
}
function openDrawer(name, $trigger) {
var $drawer;
if (!drawerMedia.matches) {
return;
}
$drawer = $drawers.filter('[data-wiki-drawer="' + name + '"]');
if (!$drawer.length) {
return;
}
closeTooltip(false);
closeDrawer(false);
$activeDrawer = $drawer;
$activeDrawerTrigger = $trigger;
$drawer.addClass('is-open').attr('aria-hidden', 'false');
$trigger.attr('aria-expanded', 'true');
$drawerBackdrop.addClass('is-visible').attr('aria-hidden', 'false');
$('html, body').addClass('esun-wiki-drawer-lock');
window.setTimeout(function () {
if ($drawer.hasClass('is-open')) {
$drawer.find('.esun-wiki-drawer-close').first().trigger('focus');
}
}, 220);
}
function syncDrawerMode() {
closeDrawer(false);
}
function trapDrawerFocus(event) {
var $focusable,
first,
last;
if (event.key !== 'Tab' || !$activeDrawer.length) {
return;
}
$focusable = $activeDrawer
.find('a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])')
.filter(':visible');
if (!$focusable.length) {
event.preventDefault();
return;
}
first = $focusable[0];
last = $focusable[$focusable.length - 1];
if (event.shiftKey && document.activeElement === first) {
event.preventDefault();
$(last).trigger('focus');
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault();
$(first).trigger('focus');
}
}
$root.find('.esun-wiki-search input[type="search"]').each(function () {
syncSearchClear($(this));
});
$root.on('click', '.esun-wiki-tree-toggle', function () {
var $button = $(this),
$item = $button.closest('.esun-wiki-tree-item'),
isOpen = !$item.hasClass('is-open');
$item.toggleClass('is-open', isOpen);
$button.attr('aria-expanded', isOpen ? 'true' : 'false');
});
$root.on('input change', '.esun-wiki-search input[type="search"]', function () {
syncSearchClear($(this));
});
$root.on('click', '.esun-wiki-search-clear', function () {
var $form = $(this).closest('form'),
$input = $form.find('input[type="search"]');
$input.val('').trigger('focus');
syncSearchClear($input);
if (window.location.search.indexOf('q=') !== -1) {
window.location.href = $form.attr('action');
}
});
$root.on('click', '[data-wiki-drawer-open]', function () {
openDrawer($(this).attr('data-wiki-drawer-open'), $(this));
});
$root.on('click', '[data-wiki-drawer-close]', function () {
closeDrawer(true);
});
$root.on('click', '.esun-wiki-toc a, .esun-wiki-sidebar a.esun-wiki-tree-link', function () {
if (drawerMedia.matches) {
closeDrawer(false);
}
});
$root.on('mouseenter focusin', '.esun-wiki-tip-trigger', function () {
showTooltip($(this));
});
$root.on('mouseleave focusout', '.esun-wiki-tip-trigger', scheduleTooltipHide);
$root.on('click', '.esun-wiki-tip-trigger', function (event) {
event.preventDefault();
showTooltip($(this));
});
$root.on('mouseenter focusin', '.esun-wiki-tooltip', cancelTooltipHide);
$root.on('mouseleave focusout', '.esun-wiki-tooltip', scheduleTooltipHide);
$(window).on('resize.esunWikiTooltip', function () {
if ($activeTrigger.length && $activeTooltip.length) {
positionTooltip($activeTrigger, $activeTooltip);
}
});
$(window).on('scroll.esunWikiTooltip', function () {
if ($activeTrigger.length && $activeTooltip.length) {
positionTooltip($activeTrigger, $activeTooltip);
}
});
$(document).on('mousedown.esunWikiTooltip touchstart.esunWikiTooltip', function (event) {
if (!$(event.target).closest('.esun-wiki-tip-trigger, .esun-wiki-tooltip').length) {
closeTooltip(false);
}
});
$(document).on('keydown.esunWikiTooltip', function (event) {
if (event.key === 'Escape' && $activeDrawer.length) {
closeDrawer(true);
} else if (event.key === 'Escape' && $activeTooltip.length) {
closeTooltip(true);
}
trapDrawerFocus(event);
});
if (drawerMedia.addEventListener) {
drawerMedia.addEventListener('change', syncDrawerMode);
} else {
drawerMedia.addListener(syncDrawerMode);
}
syncDrawerMode();
};
});