Example #1
0
 /**
  * Writes the current Navbar
  *
  * @return string A Bootstrap navbar
  */
 public function render()
 {
     $attributes = Helpers::add_class($this->attributes, 'navbar ' . $this->type);
     // Open navbar containers
     $html = '<div' . Helpers::getContainer('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 .= Helpers::getContainer('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;
 }
Example #2
0
    /**
     * Writes the current Navbar
     *
     * @return string A Bootstrap navbar
     */
    public function render()
    {
        $type = (!empty($this->type)) ? ' ' . $this->type : '';
        $attributes = Helpers::add_class($this->attributes, 'navbar' . $type);

        // Open navbar containers
        $html = '<nav' . Helpers::getContainer('html')->attributes($attributes) . ' role="navigation">';
        $html .= '<div class="container">';

        // --- Header ---
        $html .= '<div class="navbar-header">';

        // Collapsible button if asked for
        if ($this->collapsible) {
            $html .= '
            <button type="button" class="btn btn-navbar 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>';
        }

        // Add brand if one was given
        if ($this->brand) {
            $brand = $this->brand;
            if ($brand['escape']) {
                $html .= Helpers::getContainer('html')->link(
                    $this->brand['url'],
                    $this->brand['name'],
                    array('class' => 'navbar-brand')
                );
            } else {
                $url = $brand['url'];
                $text = $brand['name'];
                $html .= "<a href='$url' class='navbar-brand'>$text</a>";
            }
        }

        $html .= '</div>';
        /// --- Header ---

        // --- Content ---
        $html .= '<div class="navbar-collapse collapse">';

        // Prints out menus
        if ($this->menus) {
            foreach ($this->menus as $menu) {
                if (is_string($menu)) {
                    $html .= $menu;
                } // If is string add to html
                else {
                    $attr = array_get($menu, 'attributes', array());
                    $html .= Navigation::unstyled($menu['items'], false, $attr, $this->autoroute);
                }
            }
        }

        $html .= '</div>';
        // --- Content ---

        // Close navbar containers
        $html .= '</div></nav>';

        return $html;
    }