Ejemplo n.º 1
0
    /**
     * 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;
    }
Ejemplo n.º 2
0
 /**
  * Opens a new ButtonGroup section.
  *
  * @param string $toggle     Whether the button group should be togglable
  * @param array  $attributes An array of attributes
  *
  * @return string An opening <div> tag
  */
 public static function open($toggle = null, $attributes = array())
 {
     $validToggles = array(ButtonGroup::TOGGLE_CHECKBOX, ButtonGroup::TOGGLE_RADIO);
     if (isset($toggle) && in_array($toggle, $validToggles)) {
         $attributes['data-toggle'] = 'buttons-' . $toggle;
     }
     $attributes = Helpers::add_class($attributes, 'btn-group');
     return '<div' . HTML::attributes($attributes) . '>';
 }
Ejemplo n.º 3
0
 /**
  * Create a new Alert.
  *
  * @param  string     $type
  * @param  string     $message
  * @param  bool       $enable_close
  * @param  array      $attributes
  * @return string     Alert HTML
  */
 protected static function show($type, $message, $enable_close = true, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'alert ' . $type);
     $html = '<div' . HTML::attributes($attributes) . '>';
     if ($enable_close) {
         $html .= '<a class="close" data-dismiss="alert" href="#">&times;</a>';
     }
     $html .= $message . '</div>';
     return $html;
 }
Ejemplo n.º 4
0
 /**
  * Create a HTML anchor tag styled like a button element.
  *
  * @param  string  $value
  * @param  string  $value
  * @param  array   $attributes
  * @param  bool    $hasDropdown
  * @return string
  */
 public static function link($value, $url, $attributes = array(), $hasDropdown = false)
 {
     $attributes['href'] = \URL::to($url);
     $attributes = Helpers::add_class($attributes, 'btn');
     $extra = '';
     if ($hasDropdown) {
         $attributes = Helpers::add_class($attributes, 'dropdown-toggle');
         $extra = ' <span class="caret"></span>';
         $attributes['data-toggle'] = 'dropdown';
     }
     return '<a' . HTML::attributes($attributes) . '>' . HTML::entities($value) . $extra . '</a>';
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * Create a Bootstrap carousel. Returns the HTML for the carousel.
  *
  * @param  array   $items
  * @param  array   $attributes
  * @return Carousel
  */
 public static function create($items, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'carousel slide');
     if (!isset($attributes['id'])) {
         $attributes['id'] = "carousel_" . Helpers::rand_string(5);
     }
     $html = '<div' . HTML::attributes($attributes) . '>';
     $html .= '<div class="carousel-inner">';
     $first = true;
     foreach ($items as $item) {
         $html .= static::createItem($item, $first);
         $first = false;
     }
     $html .= '</div>';
     $html .= '<a class="carousel-control left" href="#' . $attributes['id'] . '" data-slide="prev">' . Carousel::$prev . '</a>';
     $html .= '<a class="carousel-control right" href="#' . $attributes['id'] . '" data-slide="next">' . Carousel::$next . '</a>';
     $html .= '</div>';
     return $html;
 }
Ejemplo n.º 7
0
 /**
  * Creates the a new Breadcrumb.
  *
  * @param array $links      An array of breadcrumbs links
  * @param array $attributes Attributes to apply the breadcrumbs wrapper
  *
  * @return string A breadcrumbs-styled unordered list
  */
 public static function create($links, $attributes = array())
 {
     // If no links given, cancel
     if (empty($links)) {
         return false;
     }
     // Render each link
     $l = array();
     foreach ($links as $label => $url) {
         $l[] = (is_string($label) or is_array($url)) ? static::renderItem(HTML::link($url, $label)) : static::renderItem($url, true);
     }
     // Add global .breadcrumb class
     $attributes = Helpers::add_class($attributes, 'breadcrumb');
     // Wrap in an <ul> tag
     $html = '<ul' . HTML::attributes($attributes) . '>';
     $html .= implode('', $l);
     $html .= '</ul>';
     return $html;
 }
Ejemplo n.º 8
0
 /**
  * Creates the a new Breadcrumb.
  * @param array 	$links
  * @param array 	$attributes
  * @return string
  */
 public static function create($links, $attributes = array())
 {
     if (empty($links)) {
         return;
     }
     $l = array();
     foreach ($links as $label => $url) {
         if (is_string($label) || is_array($url)) {
             $l[] = static::renderItem('<a href="' . $url . '">' . $label . '</a>');
         } else {
             $l[] = static::renderItem($url, true);
         }
     }
     $attributes = Helpers::add_class($attributes, 'breadcrumb');
     $html = '<ul' . HTML::attributes($attributes) . '>';
     $html .= implode('', $l);
     $html .= '</ul>';
     return $html;
 }
Ejemplo n.º 9
0
 /**
  * Opens a new ButtonToolbar section.
  * @param array 	$attributes
  * @return string
  */
 public static function open($attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'btn-toolbar');
     return '<div' . HTML::attributes($attributes) . '>';
 }
Ejemplo n.º 10
0
 /**
  * Allows creation of inverted navbar
  *
  * @param string $method     The method to call
  * @param array  $parameters An array of parameters
  *
  * @return Navbar
  */
 public static function __callStatic($method, $parameters)
 {
     if ($method == 'inverse') {
         $attributes = array_get($parameters, 0);
         $type = array_get($parameters, 1);
         $attributes = Helpers::add_class($attributes, 'navbar-inverse');
         return static::create($attributes, $type);
     } else {
         return static::create();
     }
 }
Ejemplo n.º 11
0
 /**
  * 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;
 }
Ejemplo n.º 12
0
 /**
  * Checks call to see if we can create a progress bar from a magic call (for you wizards).
  * normal_striped_active, info_striped, etc...
  *
  * @param string $method     Method name
  * @param array  $parameters Method parameters
  *
  * @return mixed
  */
 public static function __callStatic($method, $parameters)
 {
     $method_array = explode('_', strtolower($method));
     $types = array('normal', 'success', 'info', 'warning', 'danger', 'automatic');
     $type_found = array_intersect($method_array, $types);
     if (count($type_found) > 0) {
         $function = $type_found[key($type_found)];
         // Set default $attributes and check for a set value
         $attributes = array();
         if (isset($parameters[1])) {
             if (is_array($parameters[1])) {
                 $attributes = $parameters[1];
             } else {
                 throw new \InvalidArgumentException("Tabbable attributes parameter should be an array of attributes");
             }
         }
         if (in_array('striped', $method_array)) {
             $attributes = Helpers::add_class($attributes, 'progress-striped');
         }
         if (in_array('active', $method_array)) {
             $attributes = Helpers::add_class($attributes, 'active');
         }
         return static::$function($parameters[0], $attributes);
     }
 }
Ejemplo n.º 13
0
 /**
  * Create a new Label
  *
  * @param string $type       Label type
  * @param string $message    Label text
  * @param array  $attributes Attributes to apply the label itself
  *
  * @return string Label HTML
  */
 protected static function show($type = Label::NORMAL, $message, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'label ' . $type);
     return '<span' . HTML::attributes($attributes) . '>' . $message . '</span>';
 }
Ejemplo n.º 14
0
 /**
  * Creates a Bootstrap Dropdown menu.
  *
  * @param array $list       Menu items
  * @param array $attributes attributes to apply the nav
  * @param bool  $autoroute  Autoroute links
  *
  * @return string
  */
 public static function dropdown($list, $attributes = array(), $autoroute = true)
 {
     $attributes = Helpers::add_class($attributes, 'dropdown-menu');
     return static::menu($list, null, false, $attributes, $autoroute, true);
 }
Ejemplo n.º 15
0
 /**
  * Prints the current button in memory
  *
  * @return string A button
  */
 public function __toString()
 {
     // Gather variables
     extract($this->currentButton);
     // Add btn to classes and fallback type
     if (!isset($attributes['type'])) {
         $attributes['type'] = 'button';
     }
     $attributes = Helpers::add_class($attributes, 'btn');
     // Modify output if we have a dropdown
     $caret = null;
     if ($hasDropdown) {
         $attributes = Helpers::add_class($attributes, 'dropdown-toggle');
         $caret = ' <span class="caret"></span>';
         $attributes['data-toggle'] = 'dropdown';
     }
     // Write output according to tag
     $tag = 'button';
     if ($type === 'link') {
         $tag = 'a';
         unset($attributes['type']);
     }
     return '<' . $tag . HTML::attributes($attributes) . '>' . (string) $value . $caret . '</' . $tag . '>';
 }
Ejemplo n.º 16
0
 /**
  * Creates a table opening tag
  *
  * @param  array  $attributes An array of attributes
  * @return string             A table opening tag
  */
 public static function table($attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'table');
     return '<table' . HTML::attributes($attributes) . '>';
 }
Ejemplo n.º 17
0
 /**
  * Prints out the MediaObject in memory
  *
  * @return string The HTML markup for the media object
  */
 public function __toString()
 {
     // Whether objects should be printed as list elements or divs
     $children = static::$listed ? 'li' : 'div';
     // Open the media object
     $attributes = Helpers::add_class($this->attributes, 'media');
     $html = '<' . $children . HTML::attributes($attributes) . '>';
     // Add the media itself
     $html .= '<a class="pull-' . $this->pull . '">';
     $html .= $this->media;
     $html .= '</a>';
     // Add the title and body
     $html .= '<div class="media-body">';
     if ($this->title) {
         $html .= $this->title;
     }
     $html .= $this->content;
     // Render nested media objects (always as divs)
     if ($this->nested) {
         $listed = static::$listed;
         static::$listed = false;
         foreach ($this->nested as $mediaObject) {
             $html .= $mediaObject;
         }
         static::$listed = $listed;
     }
     // Close body
     $html .= '</div>';
     // Close object
     $html .= '</' . $children . '>';
     return $html;
 }
Ejemplo n.º 18
0
 /**
  * Creates an image with polaroid borders
  *
  * @param string $url        An url
  * @param string $alt        An alt text
  * @param array  $attributes An array of attributes
  *
  * @return string An img tag
  */
 public static function polaroid($url, $alt = '', $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'img-' . __FUNCTION__);
     return HTML::image($url, $alt, $attributes);
 }
Ejemplo n.º 19
0
 /**
  * Creates a new Carousel instance
  *
  * @param array $items      The items to use as pictures
  * @param array $attributes Its attributes
  */
 public function __construct($items, $attributes = array())
 {
     $this->items = $items;
     $this->attributes = Helpers::add_class($attributes, 'carousel slide');
     // Set default active item
     $this->active = key($items);
     // Calculate the Carousel ID
     $this->hash = '#' . array_get($attributes, 'id', 'carousel_' . Helpers::rand_string(5));
 }
Ejemplo n.º 20
0
 /**
  * Creates a table-wide row to display content
  *
  * @param string $content    The content to display
  * @param array  $attributes The rows's attributes
  * @param bool   $asHeaders  Draw row as header
  *
  * @return string A single-column row spanning all table
  */
 private function full_row($content, $attributes = array(), $asHeaders = false)
 {
     // Add a class for easy styling
     $attributes = Helpers::add_class($attributes, 'full-row');
     $tag = $asHeaders ? 'th' : 'td';
     return '<tr' . HTML::attributes($attributes) . '>
         <' . $tag . ' colspan="' . $this->numberColumns . '">' . $content . '</' . $tag . '>
     </tr>';
 }
Ejemplo n.º 21
0
 /**
  * Create a text box with the search-query class.
  *
  * @see Laravel\Form::text()
  * @param  string  $name
  * @param  string  $value
  * @param  array   $attributes
  * @return string
  */
 public static function search_box($name, $value = null, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'search-query');
     return static::text($name, $value, $attributes);
 }
Ejemplo n.º 22
0
 /**
  * Creates an horizontal definition list
  *
  * @param array $list       An array [term => description]
  * @param array $attributes An array of attributes
  *
  * @return string A formatted <dl> list
  */
 public static function horizontal_dl($list, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'dl-horizontal');
     return static::dl($list, $attributes);
 }
Ejemplo n.º 23
0
 /**
  * Writes the current Alert
  *
  * @return string A Bootstrap Alert
  */
 public function __toString()
 {
     $attr = Helpers::add_class($this->attributes, 'alert ' . $this->type);
     if ($this->isBlock) {
         $attr = Helpers::add_class($attr, 'alert-block');
     }
     $html = '<div' . HTML::attributes($attr) . '>';
     // Add close icon if necessary
     if ($this->isCloseable) {
         $html .= HTML::link('#', '&times;', array('class' => 'close', 'data-dismiss' => 'alert'));
     }
     $html .= $this->message . '</div>';
     return $html;
 }