コード例 #1
0
ファイル: ButtonGroup.php プロジェクト: dyon/flatstrapper
 /**
  * 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' . Helpers::getContainer('html')->attributes($attributes) . '>';
 }
コード例 #2
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // Manually register Basset as we need it now
     if (!class_exists('Basset\\BassetServiceProvider')) {
         $basset = __DIR__ . '/../../../../jasonlewis/basset/src/Basset/BassetServiceProvider.php';
         if (file_exists($basset)) {
             include $basset;
         }
     }
     Helpers::setContainer($this->app);
 }
コード例 #3
0
ファイル: Breadcrumb.php プロジェクト: dyon/flatstrapper
 /**
  * Renders a breadcrumb item
  *
  * @param string  $content The item content
  * @param boolean $active  Whether the item is active or not
  *
  * @return string
  */
 protected static function renderItem($content, $active = false)
 {
     $item = Element::li($content);
     $separator = Helpers::getContainer('config')->get('bootstrapper::breadcrumbs_separator');
     $separator = Element::span($separator)->addClass('divider');
     // If the link is not active it's the last one, don't append separator
     if (!$active) {
         $item->nest($separator);
     } else {
         $item->addClass('active');
     }
     return $item;
 }
コード例 #4
0
ファイル: ThumbnailTest.php プロジェクト: dyon/flatstrapper
 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);
 }
コード例 #5
0
ファイル: Alert.php プロジェクト: dyon/flatstrapper
 /**
  * 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();
 }
コード例 #6
0
ファイル: Icon.php プロジェクト: dyon/flatstrapper
 /**
  * Allows magic methods such as Icon::home([attributes]) or Icon::close_white()
  *
  * Sample Usage:
  * <code>
  * <?php
  * 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::icons_prefix') . implode('-', $classes);
     if ($white) {
         $classes .= ' ' . Helpers::getContainer('config')->get('bootstrapper::icons_prefix') . 'white';
     }
     $attributes = isset($parameters[0]) ? $parameters[0] : $parameters;
     $icon = new static($attributes);
     $icon->addClass($classes);
     return $icon;
 }
コード例 #7
0
ファイル: Paginator.php プロジェクト: dyon/flatstrapper
 /**
  * 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);
 }
コード例 #8
0
ファイル: Table.php プロジェクト: dyon/flatstrapper
 /**
  * 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>';
 }
コード例 #9
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('dyon/flatstrapper');
     $this->app['config']->package('dyon/flatstrapper', __DIR__ . '/../config');
     Helpers::setContainer($this->app);
 }
コード例 #10
0
ファイル: Form.php プロジェクト: dyon/flatstrapper
 /**
  * Create a text box with the search-query class.
  *
  * @param string $name       name of the textbox
  * @param string $value      value of textbox
  * @param array  $attributes attributes for control
  *
  * @return string
  * @see Laravel\Form::text()
  */
 public static function search_box($name, $value = null, $attributes = array())
 {
     $attributes = Helpers::add_class($attributes, 'search-query');
     return static::text($name, $value, $attributes);
 }