Exemplo n.º 1
0
 public function testCanAttachMenus()
 {
     $list = static::$itemList;
     $list->add('#', 'foo');
     $list->attach(Menu::items()->add('#', 'bar'));
     $this->assertHTML($this->matchListWithItem(), $list);
     $this->assertHTML($this->matchLink('#', 'bar'), $list);
 }
Exemplo n.º 2
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('vespakoen/menu', null, __DIR__ . '/../');
     $container = Menu::getContainer();
     $container['url'] = $this->app['url'];
     $container['config'] = $this->app['config'];
     Menu::setContainer($container);
 }
Exemplo n.º 3
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/config.php';
     $this->mergeConfigFrom($configPath, 'menu');
     $container = Menu::getContainer();
     $container['url'] = $this->app['url'];
     $container['config'] = $this->app['config'];
     Menu::setContainer($container);
 }
Exemplo n.º 4
0
 /**
  * Get a particular option in the array
  *
  * @param string $option An option
  *
  * @return mixed Its value
  */
 public function getOption($option = null)
 {
     $globalOptions = Menu::getOption();
     $combinedOptions = array_replace_recursive($globalOptions, $this->options);
     if (!$option) {
         return $combinedOptions;
     }
     return ArraysMethods::get($combinedOptions, $option);
 }
Exemplo n.º 5
0
 public function setUp()
 {
     parent::setUp();
     // Reset all menus
     Menu::reset();
     $this->refreshApplication();
     // Precreate somme Dummy data
     static::$link = new Link('#', 'foo');
     static::$raw = new Raw('foo');
     static::$itemList = new ItemList();
     static::$item = new Item(static::$itemList, static::$link);
 }
Exemplo n.º 6
0
 public function breadcrumbs()
 {
     $menu = \Menu\Menu::handler('breadcrumbs');
     foreach ($this->getMenuItems() as $route => $menuItems) {
         $items = \Menu\Menu::items('breadcrumbs');
         foreach ($menuItems as $itemRoute => $itemName) {
             $items->add($itemRoute, $itemName);
         }
         $menu->add($route, $route, $items);
     }
     return $menu->breadcrumbs(function ($itemLists) {
         return $itemLists[1];
     })->setElement('ol')->addClass('breadcrumb');
 }
Exemplo n.º 7
0
 /**
  * Set a particular option in the array
  *
  * @param string $option The option
  * @param mixed  $value  Its new value
  *
  * @return MenuObject
  */
 public function setOption($option, $value)
 {
     // forward item config values to the items
     if (Str::startsWith($option, 'item.')) {
         foreach ($this->children as $child) {
             $child->setOption($option, $value);
         }
     } elseif (Str::startsWith($option, 'item_list.')) {
         $this->options = ArraysMethods::set($this->options, $option, $value);
     } else {
         Menu::setOption($option, $value);
     }
     return $this;
 }
Exemplo n.º 8
0
 public function breadcrumbs($choosePath = null)
 {
     if (is_null($choosePath)) {
         $choosePath = function ($itemLists) {
             return $itemLists[0];
         };
     }
     $menuObjects = array();
     foreach (Menu::allHandlers()->getMenuObjects() as $itemList) {
         $breadcrumbs = $itemList->breadcrumbs();
         if ($breadcrumbs->hasChildren()) {
             $menuObjects[] = $breadcrumbs;
         }
     }
     if (count($menuObjects) > 1) {
         return $choosePath($menuObjects);
     }
     return isset($menuObjects[0]) ? $menuObjects[0] : new MenuHandler();
 }
Exemplo n.º 9
0
 /**
  * @param array $menu
  * @param       $parent
  */
 protected function buildMenu(array $menu, $parent)
 {
     foreach ($menu as $menu_name => $menu_details) {
         $uri = array_get($menu_details, 'uri', null);
         $label = array_get($menu_details, 'label', null);
         $label = $label ? Lang::get($label) : null;
         $icon = array_get($menu_details, 'icon', null);
         $children = array_get($menu_details, 'children', false);
         $skipItem = false;
         foreach ($this->callbacks as $callback) {
             $result = $callback($menu_details);
             if (!$result) {
                 $skipItem = true;
                 break;
             }
         }
         if ($skipItem) {
             continue;
         }
         // Create children container
         $items = Menu::items($menu_name);
         $content = '';
         $icon_content = '';
         if ($icon) {
             $icon_content .= '<span class="' . $icon . '"></span> ';
         }
         $content .= $icon_content . $label;
         if ($uri) {
             $item = $parent->add($uri, $content, $items);
             if ($uri !== '#') {
                 $item->activePattern('^\\/' . preg_quote($uri, '/') . '(.+)$');
             }
         } else {
             $parent->raw($content, $items);
         }
         if ($children) {
             $this->buildMenu($children, $items);
         }
     }
 }
Exemplo n.º 10
0
 public static function genMainMenu()
 {
     Self::setMenu();
     $aryMenu = Static::$arrMainMenu;
     $menu = Menu::handler('mainmenu');
     foreach ($aryMenu as $lv1) {
         if (isset($lv1['childrens']) && !empty($lv1['childrens']) && is_array($lv1['childrens'])) {
             // With level 2
             $menuItems = Menu::items();
             foreach ($lv1['childrens'] as $lv2) {
                 $menuItems->add($lv2['url'], $lv2['rawContent']);
             }
             $menu->add($lv1['url'], $lv1['rawContent'], $menuItems, null, ['class' => 'treeview']);
         } else {
             $menu->add($lv1['url'], $lv1['rawContent']);
         }
     }
     /*$menu->add('dashboard', '<i class="fa fa-dashboard"></i> <span>Dashboard</span>')
       ->add('contacts', '<i class="fa fa-dashboard"></i> <span>Contact</span> <small class="badge pull-right bg-yellow">12</small>')
       ->add('#', '<i class="fa fa-calendar"></i> <span>Parent</span> <i class="fa fa-angle-left pull-right"></i>', Menu::items()
               // ->prefixParents()
               ->add('#', '<i class="fa fa-angle-double-right"></i>Menu 1')
               ->add('#', '<i class="fa fa-angle-double-right"></i>Menu 2')
               ->add('#', '<i class="fa fa-angle-double-right"></i>Menu 3')
           , null, [ 'class' => "treeview" ]
       )
       // ->raw(null, null, ['class' => 'divider'])
       ->add('inbox', '<i class="fa fa-envelope"></i> <span>Inbox</span>');*/
     //styling
     $menu->addClass('sidebar-menu')->getAllItemLists()->map(function ($item) {
         if ($item->isActive()) {
             $item->addClass('active');
         }
         if ($item->hasChildren()) {
             $item->addClass('treeview-menu');
         }
     });
     return $menu;
 }
Exemplo n.º 11
0
 /**
  * Get the Request instance
  *
  * @return Request
  */
 public function getRequest()
 {
     return Menu::getContainer('request');
 }
Exemplo n.º 12
0
 public function testCanHandle()
 {
     $handles = array('foo', 'bar');
     $menu = Menu::handler($handles);
     $this->assertEquals(array_values(Menu::getItemList()), $menu->getMenuObjects());
 }
Exemplo n.º 13
0
 public function testChainingMethods()
 {
     $menu = Menu::handler('foo')->add('#', 'foo')->onItem()->data_foo('bar')->addClass('active')->getContent()->href('lol')->stop()->add('#', 'bar');
     $this->assertEquals('<ul>' . '<li data-foo="bar" class="active">' . '<a href="http://localhost/lol">foo</a>' . '</li>' . '<li>' . '<a href="#">bar</a>' . '</li>' . '</ul>', $menu->render());
 }
Exemplo n.º 14
0
Arquivo: Link.php Projeto: memeq1/menu
 /**
  * Render the Link
  *
  * @return string
  */
 public function render()
 {
     $this->href = $this->getEvaluatedUrl();
     // Don't compote URL if special URL
     if (!$this->isSpecialUrl()) {
         $this->href = Menu::getContainer()->bound('url') ? Menu::getContainer('url')->to($this->href) : $this->href;
     }
     return parent::render();
 }
 private function composeSubMenus()
 {
     // Compose the contact sub-menu
     View::composer('contact.shared', function ($view) {
         $menu = Menu::handler('contactMenu');
         $menu->add(route('contact.enquiries'), 'General Enquiries')->add(route('contact.book'), 'Book Us')->add(route('contact.feedback'), 'Provide Feedback');
         $menu->addClass('nav nav-tabs');
         $view->with('menu', $menu->render());
     });
     // Compose the profile sub-menu
     View::composer('members.profile', function ($view) {
         $username = $view->getData()['user']->username;
         $menu = Menu::handler('profileMenu');
         $menu->add(route('members.profile', $username), 'Details')->add(route('members.profile', ['username' => $username, 'tab' => 'events']), 'Events')->add(route('members.profile', ['username' => $username, 'tab' => 'training']), 'Training');
         $menu->addClass('nav nav-tabs');
         $view->with('menu', $menu->render());
     });
     // Compose the 'my profile' sub-menu
     View::composer('members.my_profile', function ($view) {
         $menu = Menu::handler('profileMenu');
         $menu->add(route('members.myprofile'), 'My Details')->add(route('members.myprofile', 'events'), 'Events')->add(route('members.myprofile', 'training'), 'Training');
         $menu->addClass('nav nav-tabs');
         $view->with('menu', $menu->render());
     });
     // Compose the signup sub-menu
     View::composer('events.signup', function ($view) {
         $menu = Menu::handler('signupMenu');
         $menu->add(route('events.signup', 'em'), 'Requiring an EM')->activePattern('\\/events\\/signup$')->add(route('events.signup', 'crew'), 'Requiring Crew');
         $menu->addClass('nav nav-tabs');
         $view->with('menu', $menu->render());
     });
 }
Exemplo n.º 16
0
<?php

if (!empty($params[0])) {
    $code = $params[0];
}
if (empty($code)) {
    $code = 'main';
}
$menu = \Menu\Menu::get($code, 'code');
if ($menu) {
    foreach ($menu->items(['where' => ['parent_id', 0], 'order' => ['weight', 'asc']]) as $item) {
        if (urldecode($_SERVER['REQUEST_URI']) == $item->href) {
            $active = ' class = "active" ';
        } else {
            $active = '';
        }
        echo "<li {$active}><a href = '{$item->href}'>{$item->name}</a>";
        if ($item->childs(['order' => ['weight', 'asc']])) {
            echo "<ul>";
            foreach ($item->childs as $item) {
                if (urldecode($_SERVER['REQUEST_URI']) == $item->href) {
                    $active = ' class = "active" ';
                } else {
                    $active = '';
                }
                echo "<li {$active}><a href = '{$item->href}'>{$item->name}</a>";
            }
            echo "</ul>";
        }
        echo "</li>";
    }