Exemple #1
0
 /**
  * Creates a new Typeahead instance.
  *
  * @param array $source     Array of items for list
  * @param int   $items      Number of items to display
  * @param array $attributes An array of attributes to use
  *
  * @return Typeahead
  */
 public static function create($source, $items = 8, $attributes = array())
 {
     $attributes['type'] = 'text';
     $attributes['data-items'] = $items;
     $attributes['data-provide'] = 'typeahead';
     $attributes['data-source'] = json_encode($source);
     return '<input' . Helpers::getContainer('html')->attributes($attributes) . '>';
 }
Exemple #2
0
    private static function make($type, $contents = array(), $attributes = array())
    {
        $attributes = Helpers::add_class($attributes, 'buttons', 'data-toggle');
        $attributes = Helpers::add_class($attributes, 'btn-group');
        $string = "<div " . Helpers::getContainer('html')->attributes($attributes) . ">";
        $string .= static::makeContents($contents, $type);
        $string .= "</div>";

        return $string;
    }
Exemple #3
0
 /**
  * Adds a bar to the current progress bar
  *
  * @param integer $amounts    A progress amount
  * @param string  $type       Type of progress bar
  * @param array   $attributes array of attributes for progress bar
  *
  * @return string
  */
 protected static function show($amounts = 0, $type = Progress::NORMAL, $attributes = array())
 {
     if (is_array($amounts)) {
         $type = Progress::NORMAL;
     }
     $attributes = Helpers::add_class($attributes, 'progress ' . $type);
     // Create the progress bar(s)
     $progress = '<div' . Helpers::getContainer('html')->attributes($attributes) . '>';
     if (!is_array($amounts)) {
         $amounts = array((int) $amounts => null);
     }
     foreach ($amounts as $amount => $style) {
         $progress .= static::bar($amount, $style);
     }
     $progress .= '</div>';
     return $progress;
 }
Exemple #4
0
    public function __toString()
    {
        $name = $this->name;
        $attributes = Helpers::add_class($this->attributes, 'panel-group');
        $attributes = Helpers::add_class($attributes, $name, 'id');

        $string = "<div" . Helpers::getContainer('html')->attributes($attributes) . ">";
        $count = 1;
        foreach ($this->contents as $content) {
            $heading = $content[0];
            $body = $content[1];
            $panelAttributes = isset($content[2]) ? $content[2] : array();
            $panelAttributes = Helpers::add_class($panelAttributes, 'panel panel-default');

            $bodyAttributes = array(
                'class' => 'panel-collapse collapse',
                'id' => "$name-$count"
            );
            $bodyAttributes = $count == $this->opened ? Helpers::add_class($bodyAttributes, 'in') : $bodyAttributes;

            $string .= "<div" . Helpers::getContainer('html')->attributes($panelAttributes) . ">";
            $string .= "<div class='panel-heading'>";
            $string .= "<h4 class='panel-title'>";
            $string .= "<a class='accordion-toggle' data-toggle='collapse' data-parent='#$name' href='#$name-$count'>";
            $string .= $heading;
            $string .= "</a>";
            $string .= "</h4>";
            $string .= "</div>";


            $string .= "<div" . Helpers::getContainer('html')->attributes($bodyAttributes) . ">";
            $string .= "<div class='panel-body'>";
            $string .= $body;
            $string .= "</div>";
            $string .= "</div>";
            $string .= "</div>";
            $count += 1;
        }
        $string .= "</div>";

        return $string;
    }
Exemple #5
0
    public function __toString()
    {

        $string = "<div" . Helpers::getContainer('html')->attributes($this->attributes) . ">";
        if ($this->header) {
            $string .= "<div class='panel-heading'>";
            $string .= "<h3 class='panel-title'>" . $this->header . "</h3>";
            $string .= "</div>";
        }
        if ($this->body) {
            $string .= "<div class='panel-body'>";
            $string .= $this->body;
            $string .= "</div>";
        }
        if ($this->footer) {
            $string .= "<div class='panel-footer'>";
            $string .= $this->footer;
            $string .= "</div>";
        }
        $string .= "</div>";

        return $string;

    }
Exemple #6
0
 /**
  * Outputs the current Dropdown in instance
  *
  * @return string A Dropdown menu
  */
 public function render()
 {
     // 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' . Helpers::getContainer('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;
 }
Exemple #7
0
 /**
  * Writes the current Tabbable
  *
  * @return string A Bootstrap Tabbable
  */
 public function render()
 {
     $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 ' . Helpers::getContainer('html')->attributes($this->content_attributes) . '>' . implode('', $content) . '</div>';
     $html = '<div class="tabbable ' . $this->placement . '"' . Helpers::getContainer('html')->attributes($this->attributes) . '>';
     $html .= $this->placement === self::PLACEMENT_BELOW ? $content . $tabs : $tabs . $content;
     $html .= '</div>';
     return $html;
 }
Exemple #8
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 . Helpers::getContainer('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;
 }
Exemple #9
0
 /**
  * Generates a link without doing a getting the full url from Laravel
  *
  * @param string $url        Url for the link
  * @param string $title      Title for thel ink
  * @param array  $attributes Attributes to apply to the link
  * @param bool   $encode     Encode title
  * @param string $icon       Icon for the link
  *
  * @return string
  */
 protected static function linkItem($url, $title, $attributes = array(), $encode = true, $icon = null)
 {
     if ($encode) {
         $title = Helpers::getContainer('html')->entities($title);
     }
     if (isset($icon)) {
         $title = Icon::$icon() . ' ' . $title;
     }
     return '<a href="' . $url . '"' . Helpers::getContainer('html')->attributes($attributes) . '>' . $title . '</a>';
 }
Exemple #10
0
 /**
  * Creates a Bootstrap image
  *
  * @param string $type       The image type
  * @param string $url        An url
  * @param string $alt        An alt text
  * @param array  $attributes An array of attributes
  *
  * @return string An img tag
  */
 protected static function create($type, $url, $alt, $attributes)
 {
     $attributes = Helpers::add_class($attributes, 'img-' . $type);
     return Helpers::getContainer('html')->image($url, $alt, $attributes);
 }
Exemple #11
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;
 }
Exemple #12
0
 /**
  * Prints the current button in memory
  *
  * @return string A button
  */
 public function render()
 {
     // 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 . Helpers::getContainer('html')->attributes($attributes) . '>' . (string) $value . $caret . '</' . $tag . '>';
 }
Exemple #13
0
 public function render()
 {
     return Helpers::getContainer('html')->image($this->url, $this->alt, $this->attributes);
 }
Exemple #14
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;
    }
Exemple #15
0
 /**
  * Creates a 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 dl($list, $attributes = array())
 {
     $dl = null;
     // Check if the list contains anything
     if (count($list) == 0) {
         return false;
     }
     // Write each entry
     foreach ($list as $term => $description) {
         $dl .= '<dt>' . Helpers::getContainer('html')->entities($term) . '</dt>';
         $dl .= '<dd>' . Helpers::getContainer('html')->entities($description) . '</dd>';
     }
     return '<dl' . Helpers::getContainer('html')->attributes($attributes) . '>' . $dl . '</dl>';
 }
Exemple #16
0
    /**
     * Create a carousel item. Returns a HTML element for one slide.
     *
     * @param  array $item A carousel item to render
     * @param  bool $key A fallback key as the item's position in the array
     * @return string
     */
    protected function createItem($item, $key)
    {
        // Gather necessary variables
        $key = $this->getFromItem($item, 'key', $key);
        $altText = $this->getFromItem($item, 'alt');
        $attributes = $this->getFromItem($item, 'attributes', array());
        $caption = $this->getFromItem($item, 'caption');
        $label = $this->getFromItem($item, 'label');
        $image = $this->getFromItem($item, 'image');

        // If we were given an array of image paths instead of arrays
        if (!$image and is_string($item)) {
            $image = $item;
        }

        // Build HTML
        $active = $this->active == $key ? ' active' : null;
        $html = '<div class="item' . $active . '">';

        // Render the image
        $html .= Helpers::getContainer('html')->image($image, $altText, $attributes);

        // If we have a caption, render it
        if ($caption or $label) {
            $html .= '<div class="carousel-caption">';
            if ($label) $html .= '<h4>' . $label . '</h4>';
            if ($caption) $html .= '<p>' . $caption . '</p>';
            $html .= '</div>';
        }

        $html .= '</div>';

        return $html;
    }
Exemple #17
0
 /**
  * Opens a new ButtonToolbar section.
  *
  * @param array $attributes Attributes for the button toolbar
  *
  * @return string A button toolbar
  */
 public static function open($attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'btn-toolbar');
     return '<div' . Helpers::getContainer('html')->attributes($attributes) . '>';
 }
Exemple #18
0
    public function render()
    {
        $this->attributes = Helpers::add_class($this->attributes, 'modal');
        $this->attributes = Helpers::add_class($this->attributes, "true", 'aria-hidden');
        // Open the modal
        $string = "<div" . Helpers::getContainer('html')->attributes(
                $this->attributes
            ) . "><div class='modal-dialog'><div class='modal-content'>";
        // Add the header
        $string .= '<div class="modal-header">';
        $string .= '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>';
        if ($this->header) {
            $string .= "<h3>" . $this->header . "</h3>";
        }
        $string .= "</div>";
        if ($this->body) {
            $string .= "<div class='modal-body'>";
            $string .= $this->body;
            $string .= "</div>";
        }
        if ($this->footer) {
            $string .= "<div class='modal-footer'>";
            $string .= $this->footer;
            $string .= "</div>";
        }

        return $string . "</div></div></div>";
    }