/** * Create a new Navbar instance. * * @param string $brand * @param string $brand_url * @param array $menu * @param string $type * @param bool $collapsible * @param array $attributes * @param bool $autoroute * @return Navbar */ public static function create($brand, $brand_url, $menus, $type = Navbar::STATIC_BAR, $collapsible = false, $attributes = array(), $autoroute = true) { $attributes = Helpers::add_class($attributes, 'navbar ' . $type); //Open navbar containers $html = '<div' . HTML::attributes($attributes) . '>'; $html .= '<div class="navbar-inner"><div class="container">'; if ($collapsible) { $html .= '<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span> </a>'; } $html .= '<a class="brand" href="' . $brand_url . '">' . $brand . '</a>'; if ($collapsible) { $html .= '<div class="nav-collapse">'; } foreach ($menus as $menu) { // If is string add to html if (is_string($menu)) { $html .= $menu; } else { $attr = isset($menu['attributes']) ? $menu['attributes'] : array(); $html .= Navigation::unstyled($menu['items'], false, $attr, $autoroute); } } if ($collapsible) { $html .= '</div>'; } //close navbar containers $html .= '</div></div></div>'; return $html; }
public function testMenuAttributes() { $navbar = Navbar::create()->with_menus(Navigation::links(array(array('foo', '#'), array('bar', '#'))), array('class' => 'foo', 'data-foo' => 'bar')); $matcher = $this->getBasicMatcher(); $matcher['child']['child']['child'] = array('tag' => 'ul', 'attributes' => array('class' => 'nav foo', 'data-foo' => 'bar'), 'children' => array('count' => 2, 'only' => array('tag' => 'li'))); $this->assertTag($matcher, $navbar); }
/** * sidebar function * Create sidebar * @return string * @author joharijumali **/ public static function sidebar() { // $Menu = Header::navigationdata(); $flow = URI::segment(3) == 'step' ? true : false; $navValue = array(array(Navigation::HEADER, Str::upper(Lang::line('admin.monitor')->get())), array(Lang::line('admin.dashboard')->get(), url('admin/home/dashboard'), false, false, null, 'tasks'), array(Navigation::HEADER, Str::upper(Lang::line('admin.sysmgmt')->get())), array(Lang::line('admin.configmanagement')->get(), url('admin/system/sysConfig'), false, false, null, 'chevron-right'), array(Lang::line('admin.datamanagement')->get(), url('admin/data/board'), false, false, null, 'chevron-right'), array(Lang::line('admin.pagemanagement')->get(), url('admin/modul/page'), false, false, null, 'chevron-right'), array(Lang::line('admin.flowmanagement')->get(), url('admin/modul/flow'), $flow, false, null, 'chevron-right'), array(Lang::line('admin.navsetup')->get(), url('admin/system/navigate'), false, false, null, 'chevron-right'), array(Lang::line('admin.log')->get(), url('admin/system/logger'), false, false, null, 'chevron-right'), array(Navigation::HEADER, Str::upper(Lang::line('admin.sysuser')->get())), array(Lang::line('admin.navuserlist')->get(), url('admin/user/list'), false, false, null, 'chevron-right'), array(Lang::line('admin.navuserrole')->get(), url('admin/user/role'), false, false, null, 'chevron-right'), array(Navigation::HEADER, Lang::line('global.logout')->get()), array(Lang::line('global.logout')->get(), url('admin/login/logout'), false, false, null, 'off')); return Navigation::lists(Navigation::links($navValue)); }
/** * Creates a DropdownButton. * * @param string $type * @param string $value * @param array $list * @param array $attributes * @param bool $right * @param bool $dropup * @param bool $autoroute * @return string */ protected static function show($type, $value, $list, $attributes = array(), $right = false, $dropup = false, $autoroute = true) { $attributes = Helpers::add_class($attributes, 'btn-group'); $list_attr = array(); if ($right) { $list_attr['class'] = 'pull-right'; } if ($dropup) { $attributes['class'] .= ' dropup'; } $html = '<div' . HTML::attributes($attributes) . '>'; $html .= Form::button($value, array('class' => $type), true); $html .= Navigation::dropdown($list, $list_attr, $autoroute); $html .= '</div>'; return $html; }
/** * Generate a Bootstrap tabbable object. * * @param array $list * @param string $placement * @param string $menu_type @see Navigation * @param bool $stacked * @param array $attributes * @param array $menu_attributes * @param array $content_attributes * @param bool $autoroute * @return string */ public static function create($list, $placement = Tabbable::PLACEMENT_ABOVE, $menu_type = Navigation::TYPE_TABS, $stacked = false, $attributes = array(), $menu_attributes = array(), $content_attributes = array(), $autoroute = true) { $content = array(); $list = static::normalize($list, $content); $tabs = Navigation::menu($list, $menu_type, $stacked, $menu_attributes, $autoroute); //Tab content container if (!isset($content_attributes['class'])) { $content_attributes['class'] = ''; } $content_attributes['class'] .= ' tab-content'; $content = '<div ' . HTML::attributes($content_attributes) . '>' . implode('', $content) . '</div>'; $html = '<div class="tabbable ' . $placement . '"' . HTML::attributes($attributes) . '>'; $html .= $placement === self::PLACEMENT_BELOW ? $content . $tabs : $tabs . $content; $html .= '</div>'; return $html; }
/** * Renders the dropdown * * @param array $link The link to render * @return string */ protected function renderDropdown(array $link) { if (self::NAVIGATION_NAVMENU !== $this->type) { return parent::renderDropdown(); } if ($this->dropdownShouldBeActive($link)) { $string = '<li class=\'dropdown active\'>'; } else { $string = '<li class=\'dropdown\'>'; } $string .= "<a class='dropdown-toggle' data-toggle='dropdown' href='#'>{$link[0]} <span class='caret'></span></a>"; $string .= '<ul class=\'dropdown-menu navmenu-nav\' role=\'menu\'>'; foreach ($link[1] as $item) { $string .= $this->renderItem($item); } $string .= '</ul>'; $string .= '</li>'; return $string; }
/** * Writes the current Navbar * * @return string A Bootstrap navbar */ public function __toString() { $attributes = Helpers::add_class($this->attributes, 'navbar ' . $this->type); // Open navbar containers $html = '<div' . HTML::attributes($attributes) . '>'; $html .= '<div class="navbar-inner"><div class="container">'; // Collapsible button if asked for if ($this->collapsible) { $html .= ' <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a>'; } // Add brand if one was given if ($this->brand) { $html .= HTML::link($this->brand['url'], $this->brand['name'], array('class' => 'brand')); } if ($this->collapsible) { $html .= '<div class="nav-collapse">'; } // Prints out menus if ($this->menus) { foreach ($this->menus as $menu) { if (is_string($menu)) { $html .= $menu; } else { $attr = array_get($menu, 'attributes', array()); $html .= Navigation::unstyled($menu['items'], false, $attr, $this->autoroute); } } } if ($this->collapsible) { $html .= '</div>'; } // Close navbar containers $html .= '</div></div></div>'; return $html; }
/** * Adds the given classes to attributes * * @param array $classes * @return $this * @static */ public static function addClass($classes) { //Method inherited from \Bootstrapper\RenderedObject return \Bootstrapper\Navigation::addClass($classes); }
/** * Outputs the current Dropdown in instance * * @return string A Dropdown menu */ public function __toString() { // Base class $this->attributes = Helpers::add_class($this->attributes, 'btn-group'); // Pull right $listAttributes = $this->pullRight ? array('class' => 'pull-right') : array(); // Dropup if ($this->dropup) { $this->attributes['class'] .= ' dropup'; } $html = '<div' . HTML::attributes($this->attributes) . '>'; //If split is false make this button dropdown $html .= Form::button($this->label, array('class' => $this->type), !$this->split); //Add split button if needed if ($this->split) { $html .= Form::button('', array('class' => $this->type), true); } $html .= Navigation::dropdown($this->links, $listAttributes, $this->autoroute); $html .= '</div>'; return $html; }
public function testActiveTab() { $arr = $this->createLinks(); //Set second tab as active $arr[1][2] = true; $tabs = Tabbable::tabs(Navigation::links($arr)); //Set matcher with $matcher = $this->createMatcher('above', 'tabs', 'Section 2', "Howdy, I'm in Section 2."); $this->assertHTML($matcher, $tabs); }
protected function setUp() { $this->links = Navigation::links(array(array('foo', '#'), array('bar', '#'))); }
function it_can_have_navigation_added(Navigation $navigation) { $navigation->navbar()->shouldBeCalledTimes(1); $navigation->__toString()->shouldBeCalledTimes(1)->willReturn('foo'); $this->withContent($navigation)->render()->shouldBe("<div class='navbar navbar-default' role='navigation'><div class='container'><div class='navbar-header'><button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'><span class='sr-only'>Toggle navigation</span><span class='icon-bar'></span><span class='icon-bar'></span><span class='icon-bar'></span></button></div><nav class='navbar-collapse collapse'>foo</nav></div></div>"); }
/** * @dataProvider classes */ public function testStylesAll($class) { $links = Navigation::links(array(array('foo', '#'), array('bar', '#'))); $menu = Navigation::$class($links, true, array('class' => 'bar', 'data-foo' => 'bar')); $match = $this->createNavMatcher($class, 'bar', true); $match['attributes']['data-foo'] = 'bar'; $this->assertHTML($match, $menu); }
/** * Writes the current Tabbable * * @return string A Bootstrap Tabbable */ public function __toString() { $content = array(); $list = static::normalize($this->menu, $content); $tabs = Navigation::menu($list, $this->style, $this->stacked, $this->menu_attributes, $this->autoroute); // Tab content container if (!isset($this->content_attributes['class'])) { $this->content_attributes['class'] = 'tab-content'; } else { $this->content_attributes['class'] .= ' tab-content'; } $content = '<div ' . HTML::attributes($this->content_attributes) . '>' . implode('', $content) . '</div>'; $html = '<div class="tabbable ' . $this->placement . '"' . HTML::attributes($this->attributes) . '>'; $html .= $this->placement === self::PLACEMENT_BELOW ? $content . $tabs : $tabs . $content; $html .= '</div>'; return $html; }
public function testCollapsibleMenu() { $navbar = Navbar::create()->with_menus( Navigation::links( array( array('foo', '#'), array('bar', '#') ) ) )->collapsible(); $matcher = $this->getBasicMatcher(true); $matcher['descendant']['child'] = array( 'tag' => 'ul', 'attributes' => array('class' => 'nav'), 'children' => array( 'count' => 2, 'only' => array('tag' => 'li') ) ); $this->assertHtml($matcher, $navbar); }