Browse Source

* move sideMenuItem group, icon_bas64, icon_base64_minimized to attributes property & support them october >1.0.467

* EventEmmiter with AssetMaker for correctly add assets from Plugin
master
dimti 5 years ago
parent
commit
047fc8c93a
  1. 2
      Plugin.php
  2. 14
      classes/Extend.php
  3. 25
      partials/menu/main/_system_sidebar_menu.phtml

2
Plugin.php

@ -7,6 +7,7 @@ use Cms\Classes\Controller as CmsController;
use Cms\Classes\Page as CmsPage;
use System\Classes\PluginBase;
use System\Traits\AssetMaker;
use System\Traits\EventEmitter;
/**
* Menu Plugin Information File
@ -16,6 +17,7 @@ class Plugin extends PluginBase
const ICON = 'icon-sliders';
use AssetMaker;
use EventEmitter;
/**
* @var CmsController

14
classes/Extend.php

@ -2,6 +2,7 @@
namespace Wms\Menu\Classes;
use Backend\Classes\SideMenuItem;
use Backend\Models\User;
use System\Classes\PluginManager;
@ -51,13 +52,20 @@ class Extend
if ($page) {
self::$navigation['sideMenu'][$name] = [
'label' => isset($page['label']) ? $page['label'] : 'wms.menu::lang.no-name',
'group' => $group,
'url' => isset($page['url']) ? $page['url'] : '#',
'icon' => isset($page['icon']) ? $page['icon'] : 'icon-leaf',
'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '',
'icon_base64_minimized' => isset($page['icon_base64_minimized']) ? $page['icon_base64_minimized'] : '',
'attributes' => [
'group' => $group,
'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '',
'icon_base64_minimized' => isset($page['icon_base64_minimized']) ? $page['icon_base64_minimized'] : '',
'keywords' => isset($page['keywords']) ? $page['keywords'] : '',
'description' => isset($page['description']) ? $page['description'] : ''
],
'permissions' => isset($page['permissions']) ? $page['permissions'] : ['wms.*'],
];
/**
* @see SideMenuItem::createFromArray()
*/
}
}
}

25
partials/menu/main/_system_sidebar_menu.phtml

@ -5,18 +5,11 @@
? $_COOKIE['sidenav_treegroupStatus']
: null
);
$categories = [];
foreach ($sideMenuItems as $sideItemCode => $item) {
if(!property_exists($item, 'group')) {
$item->group = 'default';
}
if(!property_exists($item, 'keywords')) {
$item->keywords = '';
}
if(!property_exists($item, 'description')) {
$item->description = '';
}
$categories[$item->group][$sideItemCode] = $item;
$categories[$item->attributes['group']][$sideItemCode] = $item;
}
?>
<ul class="top-level">
@ -37,16 +30,16 @@
))
? 'active'
: null;
?>" data-keywords="<?= e(trans($item->keywords)) ?>">
?>" data-keywords="<?= e(trans($item->attributes['keywords'])) ?>">
<a href="<?= $item->url ?>">
<?php if ($item->icon_base64):?>
<img src="<?=$item->icon_base64?>" alt="<?= e(trans($item->label)) ?>" title="<?= e(trans($item->label)) ?>">
<img src="<?=$item->icon_base64_minimized ? : $item->icon_base64?>" class="minimized" alt="<?= e(trans($item->label)) ?>" title="<?= e(trans($item->label)) ?>">
<?php else: ?>
<?php if ($item->attributes['icon_base64']):?>
<img src="<?=$item->attributes['icon_base64']?>" alt="<?= e(trans($item->label)) ?>" title="<?= e(trans($item->label)) ?>">
<img src="<?=$item->attributes['icon_base64_minimized'] ? : $item->attributes['icon_base64']?>" class="minimized" alt="<?= e(trans($item->label)) ?>" title="<?= e(trans($item->label)) ?>">
<?php elseif (isset($item->icon)): ?>
<i class="<?= $item->icon ?>"></i>
<?php endif;?>
<span class="header"><?= e(trans($item->label)) ?></span>
<span class="description"><?= e(trans($item->description)) ?></span>
<span class="description"><?= e(trans($item->attributes['description'])) ?></span>
</a>
</li>
<?php endforeach ?>

Loading…
Cancel
Save