Esempio n. 1
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
        $listItems = array();
        foreach ($links as $label => $url) {
            $listItems[] = (is_string($label) or is_array($url))
                ? static::renderItem(Helpers::getContainer('html')->link($url, $label))
                : static::renderItem($url, true);
        }

        return Lists::ul($listItems, $attributes)->addClass('breadcrumb');
    }
Esempio n. 2
0
    /**
     * Allows magic methods such as Icon::home([attributes]) or Icon::close_white()
     *
     * Sample Usage:
     * <code>
     * Icon::plus();
     * // <i class="icon-plus"></i>
     * Icon::folder_open(array('class'=>'widget','data-foo'=>'bar'));
     * // <i class="widget icon-folder-open" data-foo="bar"></i>
     * Icon::circle_arrow_right_white();
     * // <i class="icon-circle-arrow-right icon-white"></i>
     * </code>
     *
     * @param string $method     Name of missing method
     * @param array  $parameters array of parameters passed to missing method
     *
     * @return string
     */
    public static function __callStatic($method, $parameters)
    {
        // Explode method name
        $classes = explode('_', strtolower($method));
        $white = in_array('white', $classes);
        if ($white) unset($classes[array_search('white', $classes)]);

      
        // Concatenate icons
        $classes = Helpers::getContainer('config')->get('bootstrapper::icon_prefix') . implode('-', $classes);
        if ($white) $classes .= ' ' .Helpers::getContainer('config')->get('bootstrapper::icon_prefix').'white';
        $classes = Helpers::getContainer('config')->get('bootstrapper::icon_class') . ' ' . $classes;

        $attributes = isset($parameters[0]) ? $parameters[0] : $parameters;

        $icon = new static($attributes);
        $icon->addClass($classes);

        return $icon;
    }
Esempio n. 3
0
    /**
     * Writes the current Alert
     *
     * @return string A Bootstrap Alert
     */
    public function render()
    {
        $this->addClass('alert');

        // Block alert
        if ($this->isBlock) {
            $this->addClass('alert-block');
        }

        // Add close icon if necessary
        if ($this->isCloseable) {
            $close = Helpers::getContainer('html')->link(
                '#',
                '&times;',
                array('class' => 'close', 'data-dismiss' => 'alert')
            );
            $this->nest($close);
        }

        $this->nest(new Text($this->message));

        return '<' . $this->element . Helpers::getContainer('html')->attributes(
            $this->attributes
        ) . '>' . $this->getContent() . $this->close();
    }
Esempio n. 4
0
    /**
     * Build a range of numeric pagination links.
     *
     * For the current page, an HTML span element will be generated instead of a link.
     *
     * @param int $start starting position
     * @param int $end ending position
     *
     * @return string
     */
    protected function range($start, $end)
    {
        $pages = array();

        // To generate the range of page links, we will iterate through each page
        // and, if the current page matches the page, we will generate a span,
        // otherwise we will generate a link for the page. The span elements
        // will be assigned the "current" CSS class for convenient styling.
        for ($page = $start; $page <= $end; $page++) {
            if ($this->page == $page) {
                $pages[] = '<li class="active"><a href="#">' . Helpers::getContainer('html')->entities(
                        $page
                    ) . '</a></li>';
            } else {
                $pages[] = '<li>' . $this->link($page, $page, null) . '</li>';
            }
        }

        return implode(' ', $pages);
    }
Esempio n. 5
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
     */
    protected 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' . Helpers::getContainer('html')->attributes($attributes) . '>
            <' . $tag . ' colspan="' . $this->numberColumns . '">' . $content . '</' . $tag . '>
        </tr>';
    }
Esempio n. 6
0
    /**
     * Returns the latest version of Bootstrap's (and JQuery's) JS
     *
     * @return string The link for the latest version of Bootstrap
     */
    public static function get_JS()
    {
        $bootstrapVersion = Helpers::getContainer('config')->get('bootstrapper::bootstrap_version');
        $jQueryVersion = Helpers::getContainer('config')->get('bootstrapper::jquery_version');

        return "<script src='http://code.jquery.com/jquery-$jQueryVersion.min.js'></script><script src='//netdna.bootstrapcdn.com/bootstrap/$bootstrapVersion/js/bootstrap.min.js'></script>";
    }
Esempio n. 7
0
    /**
     * Create a HTML for an uneditable control
     *
     * @param string $value value of uneditable control
     * @param array $attributes attributes for control
     *
     * @return string
     */
    public static function uneditable($value, $attributes = array())
    {
        $attributes = Helpers::add_class($attributes, 'uneditable-input');

        return '<span' . Helpers::getContainer('html')->attributes($attributes) . '>' . Helpers::getContainer(
            'html'
        )->entities($value) . '</span>';
    }
Esempio n. 8
0
    public function testWithClosure()
    {
        $thumbnails = Thumbnail::create(
            $this->richImages,
            function ($image) {
                $image = (object)$image;

                $return = '<li class="thumbnail"><figure>' . Helpers::getContainer('html')->image(
                        $image->image,
                        $image->image
                    ) . '</figure>';
                if (isset($image->label)) {
                    $return .= '<h2>' . $image->label . '</h2>';
                }
                $return .= '</li>';

                return $return;
            }
        )->render();
        $matcher = $this->matcher(
            '<li class="thumbnail"><figure>' . $this->image('foo') . '</figure></li>' .
            '<li class="thumbnail"><figure>' . $this->image('bar') . '</figure><h2>bar</h2></li>' .
            '<li class="thumbnail"><figure>' . $this->image('den') . '</figure><h2>den</h2></li>'
        );

        $this->assertEquals($matcher, $thumbnails);
    }