Beispiel #1
0
 /**
  * Test menu output html.
  *
  * @return void
  */
 public function testSimpleRender()
 {
     $expected = '<ul class="menu" id="level-1">' . '<li class="li-link li-1">' . '<a href="/link" title="Dashboard" class="link-1 un-link">' . '<span class="un-link-title">' . '<i class="un-icon fa fa-dashboard"></i>' . ' Dashboard' . PHP_EOL . '<i class="arrow un-icon fa fa-caret-down"></i>' . '</span>' . '</a>' . '<ul class="menu" id="nav-test_menu-2">' . '<li class="li-link li-1">' . '<a href="/link-2" title="Children 1" class="link-1 un-link">' . '<span class="un-link-title">Children 1</span>' . '</a>' . '</li>' . '</ul>' . '</li>' . '</ul>';
     $actual = $this->Nav->render('test_menu', Nav::items('test_menu'), ['type' => false]);
     $this->assertEquals(trim($expected), $actual);
     $_SERVER['REQUEST_URI'] = '/link';
     $expected = '<ul class="menu" id="level-1">' . '<li class="li-link li-1 active">' . '<a href="javascript:void(0);" title="Dashboard" class="link-1 un-link" data-toggle="collapse" data-target="#nav-collapse-2">' . '<span class="un-link-title">' . '<i class="un-icon fa fa-dashboard"></i> ' . 'Dashboard' . PHP_EOL . '<i class="arrow un-icon fa fa-caret-down"></i>' . '</span>' . '</a>' . '<ul class="collapse treeview-menu" id="nav-collapse-2">' . '<li class="li-link li-1">' . '<a href="/link-2" title="Children 1" class="link-1 un-link">' . '<span class="un-link-title">Children 1</span>' . '</a>' . '</li>' . '</ul>' . '</li>' . '</ul>';
     $this->assertEquals($expected, $this->Nav->render('collapse', Nav::items('test_menu'), ['type' => NavHelper::MENU_TYPE_COLLAPSE]));
     $expected = '<ul class="menu" id="level-1">' . '<li class="li-link li-1 customLiClass dropdown active">' . '<a href="javascript:void(0);" title="Dashboard" class="link-1 customClass dropdown un-link" data-toggle="dropdown">' . '<span class="un-link-title">' . '<i class="un-icon fa fa-dashboard"></i> ' . 'Dashboard' . PHP_EOL . '<i class="arrow un-icon fa fa-caret-down"></i>' . '</span>' . '</a>' . '<ul class="dropdown-menu dropdown-custom dropdown-menu-right" id="nav-collapse-2">' . '<li class="li-link li-1">' . '<a href="/link-2" title="Children 1" class="link-1 un-link">' . '<span class="un-link-title">Children 1</span>' . '</a>' . '</li>' . '</ul>' . '</li>' . '</ul>';
     $this->assertEquals($expected, $this->Nav->render('collapse', Nav::items('test_menu_2'), ['type' => NavHelper::MENU_TYPE_DROP_DOWN]));
 }
Beispiel #2
0
<?php

/**
 * UnionCMS Core
 *
 * This file is part of the of the simple cms based on CakePHP 3.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Core
 * @license   MIT
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
 * @link      https://github.com/UnionCMS/Core
 * @author    Sergey Kalistratov <*****@*****.**>
 */
use Union\Core\Nav;
use Union\Core\Plugin;
$plugin = 'Union/Core';
Nav::add('sidebar', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'icon' => 'dashboard', 'url' => ['plugin' => $plugin, 'controller' => 'Union', 'action' => 'dashboard']]);
Nav::add('sidebar', 'system', ['title' => __d('union', 'System'), 'weight' => 1, 'icon' => 'cog', 'children' => ['global-config' => ['title' => __d('union', 'Global config'), 'url' => ['plugin' => 'Union/Extensions', 'controller' => 'Plugins', 'action' => 'config', Plugin::alias($plugin)]]]]);
Beispiel #3
0
 /**
  * Test remove items.
  *
  * @return void
  */
 public function testRemove()
 {
     $options = ['title' => 'Bar', 'path' => '/my/path'];
     Nav::add('remove', 'simple', $options);
     $expected = ['simple' => Hash::merge(Nav::getDefaults(), $options)];
     $this->assertSame($expected, Nav::items('remove'));
     Nav::remove('remove');
     $this->assertSame([], Nav::items('remove'));
 }
Beispiel #4
0
<?php

/**
 * UnionCMS Community
 *
 * This file is part of the of the simple cms based on CakePHP 3.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @package   Community
 * @license   MIT
 * @copyright MIT License http://www.opensource.org/licenses/mit-license.php
 * @link      https://github.com/UnionCMS/Community
 * @author    Sergey Kalistratov <*****@*****.**>
 */
use Union\Core\Nav;
use Union\Core\Plugin;
$plugin = 'Union/Community';
Nav::add('sidebar', 'community', ['title' => __d('community', 'Community'), 'weight' => 50, 'icon' => 'group', 'children' => ['roles' => ['title' => __d('community', 'Groups'), 'weight' => 0, 'url' => ['plugin' => $plugin, 'controller' => 'Roles', 'action' => 'index']], 'users' => ['title' => __d('community', 'Users'), 'weight' => 10, 'url' => ['plugin' => $plugin, 'controller' => 'Users', 'action' => 'index']], 'permissions' => ['title' => __d('community', 'Permissions'), 'weight' => 15, 'url' => ['plugin' => $plugin, 'controller' => 'Acl', 'action' => 'permissions']], 'config' => ['title' => __d('union', 'Configure'), 'weight' => 20, 'url' => ['plugin' => 'Union/Extensions', 'controller' => 'Plugins', 'action' => 'config', Plugin::alias($plugin)]]]]);
 /**
  * User menu for backend.
  *
  * @return void
  */
 protected function _backendMenu()
 {
     Nav::add('user_nav', 'user', ['weight' => 10, 'icon' => 'user', 'liClass' => 'user user-menu', 'title' => $this->_controller->Auth->user('username'), 'children' => ['profile' => ['weight' => 10, 'title' => __d('community', 'Profile'), 'url' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'edit', $this->_controller->Auth->user('id')]], 'logout' => ['weight' => 100, 'title' => __d('community', 'Logout'), 'url' => ['plugin' => 'Union/Community', 'controller' => 'Users', 'action' => 'logout']]]]);
 }