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

10
classes/Extend.php

@ -2,6 +2,7 @@
namespace Wms\Menu\Classes; namespace Wms\Menu\Classes;
use Backend\Classes\SideMenuItem;
use Backend\Models\User; use Backend\Models\User;
use System\Classes\PluginManager; use System\Classes\PluginManager;
@ -51,13 +52,20 @@ class Extend
if ($page) { if ($page) {
self::$navigation['sideMenu'][$name] = [ self::$navigation['sideMenu'][$name] = [
'label' => isset($page['label']) ? $page['label'] : 'wms.menu::lang.no-name', 'label' => isset($page['label']) ? $page['label'] : 'wms.menu::lang.no-name',
'group' => $group,
'url' => isset($page['url']) ? $page['url'] : '#', 'url' => isset($page['url']) ? $page['url'] : '#',
'icon' => isset($page['icon']) ? $page['icon'] : 'icon-leaf', 'icon' => isset($page['icon']) ? $page['icon'] : 'icon-leaf',
'attributes' => [
'group' => $group,
'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '', 'icon_base64' => isset($page['icon_base64']) ? $page['icon_base64'] : '',
'icon_base64_minimized' => isset($page['icon_base64_minimized']) ? $page['icon_base64_minimized'] : '', '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.*'], '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'] ? $_COOKIE['sidenav_treegroupStatus']
: null : null
); );
$categories = []; $categories = [];
foreach ($sideMenuItems as $sideItemCode => $item) { 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"> <ul class="top-level">
@ -37,16 +30,16 @@
)) ))
? 'active' ? 'active'
: null; : null;
?>" data-keywords="<?= e(trans($item->keywords)) ?>">
?>" data-keywords="<?= e(trans($item->attributes['keywords'])) ?>">
<a href="<?= $item->url ?>"> <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> <i class="<?= $item->icon ?>"></i>
<?php endif;?> <?php endif;?>
<span class="header"><?= e(trans($item->label)) ?></span> <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> </a>
</li> </li>
<?php endforeach ?> <?php endforeach ?>

Loading…
Cancel
Save