Exemple #1
0
 /**
  * Initializes a Nav instance.
  *
  * @param array $options options the display options for the nav.
  * @param mixed $block Block to generate a customized inside nav content.
  */
 public function __construct($options = [], $block = null)
 {
     $num_args = $this->get_function_num_args(func_get_args());
     if (2 > $num_args && is_callable(func_get_arg($num_args - 1))) {
         $block = func_get_arg($num_args - 1);
         $options = [];
     }
     Base::set_nav_link(true);
     $nav = new ContentTag('ul', $this->nav_options($options), $block);
     Base::set_nav_link(false);
     $this->set_html_object($nav->get_html_object());
 }
Exemple #2
0
 /**
  * Build the Vertical object.
  *
  * @param array $options options to build the Vertical object.
  * @param closure $block Closure to build the Vertical object.
  * @return ContentTag instance of ContenTag that represents the Vertical object.
  */
 private function build_vertical($options = [], $block = null)
 {
     Base::set_navbar_vertical(true);
     $this->append_class($options, 'navbar-header');
     $yield = is_callable($block) ? call_user_func($block) : $block;
     $vertical = new ContentTag('div', $options, function () use($yield) {
         $content = is_array($yield) ? array_merge([$this->toggle_button()], $yield) : [$this->toggle_button(), $yield];
         return $content;
     });
     Base::set_navbar_vertical(false);
     return $vertical->get_html_object();
 }
Exemple #3
0
 /**
  * Initializes the Icon instance.
  *
  * @param String $name the name of the icon object to build
  * @param Array $options the options for the icon object.
  */
 public function __construct($name = null, $options = [])
 {
     !isset($options['library']) ? $options['library'] = 'glyphicons' : null;
     $prefix = $this->library_prefix_for($options['library']);
     unset($options['library']);
     $this->append_class($options, $prefix);
     if (!is_null($name)) {
         $name = str_replace('_', '-', $name);
         $this->append_class($options, "{$prefix}-{$name}");
     }
     $icon = new ContentTag('span', '', $options);
     $this->set_html_object($icon->get_html_object());
 }
Exemple #4
0
 /**
  * Initializes the ProgressBar instance.
  *
  * @param array $options options to build the ProgressBar.
  * @param array $container_options options to be passed to the ProgressBar's container.
  */
 public function __construct($options = [], $container_options = [])
 {
     $this->append_class($container_options, 'progress');
     $progress_bar = new ContentTag('div', $container_options, function () use($options) {
         if (is_array(reset($options))) {
             $progress_strings = [];
             foreach ($options as $progress_bar_options) {
                 $progress_strings[] = $this->build_progress_bar($progress_bar_options);
             }
             return $progress_strings;
         } else {
             return $this->build_progress_bar($options);
         }
     });
     $this->set_html_object($progress_bar->get_html_object());
 }
Exemple #5
0
 public function testMultipleContentAtSameLevel()
 {
     /**
      * It should generates:
      *
      * <div id="main">
      *     <p class="comment">First content</p>
      *     <a role="navigation" href="/home">Go Home!</a>
      * </div>
      */
     $content_tag = new ContentTag('div', ['class' => 'main'], function () {
         return [new ContentTag('p', 'First content', ['class' => 'comment']), new ContentTag('a', ['role' => 'navigation', 'href' => '/home'])];
     });
     $html = $content_tag->get_html();
     $this->assertEquals(2, $html->get_content()->length());
     $first_child = $html->get_child(0);
     $second_child = $html->get_child(1);
     $this->assertTrue($first_child->is_a('p', ['class' => 'comment']));
     $this->assertTrue($second_child->is_a('a'));
 }
Exemple #6
0
 /**
  * Initializes the PanelRow instance.
  *
  * @param mixed $options [optional] the display options for the panel.
  * @param Callable $block [optional] Block to generate inside panel row content.
  */
 public function __construct($options, $block = null)
 {
     Base::set_panel_column_class(is_array($options) && isset($options['column_class']) ? $options['column_class'] : null);
     $panel_row = new ContentTag('div', call_user_func($block), $this->set_panel_row_options($options));
     $this->set_html_object($panel_row->get_html_object());
 }
Exemple #7
0
 /**
  * Initializes Badge component.
  * 
  * @param type $text Badge's text.
  * @param array $options Badge's options
  * @return ContentTag instance of ContentTag object representing an Html Badge.
  */
 public function __construct($text, array $options = [])
 {
     $this->append_class($options, 'badge');
     $badge = new ContentTag('span', $text, $options);
     $this->set_html_object($badge->get_html_object());
 }