public function __construct()
 {
     $this->testAttributes = new AttributesHelper(['class' => 'horseradish']);
     $this->testAttributes->setId('CHESTNUT');
     $this->testAttributes->addClass('cheese');
     $this->testAttributes->addClass('peanuts');
     $this->testAttributes->addData('beef-steak', 'XYZ ');
 }
 /**
  * @param                                                   $content
  * @param \AndreasGlaser\Helpers\Html\AttributesHelper|array|null $attributes
  *
  * @return $this
  * @author Andreas Glaser
  */
 public function addItem($content, $attributes = null)
 {
     $index = count($this->items);
     $this->items[$index]['content'] = $content;
     $this->items[$index]['attributes'] = AttributesHelper::f($attributes);
     return $this;
 }
 /**
  * @author Andreas Glaser
  */
 public function test()
 {
     $unorderedList = OrderedListHelper::f(['id' => 'my-list']);
     $unorderedList->addItem('Hello', ['rel' => 'test']);
     $unorderedList->addItem('XYZ', AttributesHelper::f(['data-test' => 'Aww']));
     $this->assertEquals('<ol id="my-list"><li class="item-first item-index-0" rel="test">Hello</li><li class="item-last item-index-1" data-test="Aww">XYZ</li></ol>', $unorderedList->render());
 }
示例#4
0
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     return '<td' . $this->attributes->render() . '>' . $this->content . '</td>';
 }
 /**
  * @author Andreas Glaser
  */
 public function test()
 {
     $unorderedList = DescriptionListHelper::f(['id' => 'my-list']);
     $unorderedList->addItem('Term 1', 'Hello', ['rel' => 'test'], ['data-test' => '123']);
     $unorderedList->addItem('Term 1', 'XYZ', AttributesHelper::f(['data-test' => 'Aww'], ['id' => '321']));
     $this->assertEquals('<dl id="my-list"><dt class="item-first item-index-0" rel="test">Hello</dt><dd class="item-first item-index-0" data-test="123">Hello</dd><dt class="item-last item-index-1" data-test="Aww">XYZ</dt><dd class="item-last item-index-1">XYZ</dd></dl>', $unorderedList->render());
 }
示例#6
0
 /**
  * @param \AndreasGlaser\Helpers\Interfaces\RendererInterface|null $renderer
  *
  * @return string
  * @author Andreas Glaser
  */
 public function render(RendererInterface $renderer = null)
 {
     if ($renderer) {
         return $renderer->render($this);
     }
     $html = '<tr' . $this->attributes->render() . '>';
     foreach ($this->getCells() as $cell) {
         $html .= $cell->render();
     }
     $html .= '</tr>';
     return $html;
 }
 /**
  * @author Andreas Glaser
  */
 public function testAttributes()
 {
     $attributesHelper = new AttributesHelper();
     $attributesHelper->setId('myid')->addClass('myclass')->addData('mydata1', 'cheese')->addData('mydata2', 'bacon')->addStyle('height', '100%')->addStyle('width', '200px')->set('href', 'http://andreas.glaser.me');
     $this->assertEquals(' id="myid" class="myclass" href="http://andreas.glaser.me" data-mydata1="cheese" data-mydata2="bacon" style="height:100%;width:200px;"', $attributesHelper->render());
     $attributesHelper->removeClass('myclass');
     $attributesHelper->removeData('mydata2');
     $attributesHelper->removeId();
     $this->assertEquals(' href="http://andreas.glaser.me" data-mydata1="cheese" style="height:100%;width:200px;"', $attributesHelper->render());
     $this->assertEquals(' id="my-id" class="testclass" data-important="info" data-cheese="delicious" style="color:red;font-size:1em;"', AttributesHelper::f(['id' => 'my-id', 'CLASS' => 'testclass', 'data-important' => 'info', 'data-cheese' => 'delicious', 'style' => 'color:red;font-size:1em'])->render());
 }
 /**
  * @param array                       $headRows
  * @param array                       $bodyRows
  * @param AttributesHelper|array|null $attributesHelper
  */
 public function __construct(array $headRows = null, array $bodyRows = null, $attributesHelper = null)
 {
     if ($headRows) {
         foreach ($headRows as $headRow) {
             $this->addHeadRow($headRow);
         }
     }
     if ($bodyRows) {
         foreach ($bodyRows as $bodyRow) {
             $this->addBodyRow($bodyRow);
         }
     }
     $this->attributes = AttributesHelper::f($attributesHelper);
 }
 /**
  * @param                                              $name
  * @param \AndreasGlaser\Helpers\Html\AttributesHelper|array|null $attributesHelper
  *
  * @return string
  * @author Andreas Glaser
  */
 public static function glyphIcon($name, $attributesHelper = null)
 {
     $attributesHelper = AttributesHelper::f($attributesHelper);
     return HtmlHelper::span('', $attributesHelper->addClass('glyphicon')->addClass('glyphicon-' . $name));
 }
 /**
  * @author Andreas Glaser
  */
 public function testRadio()
 {
     $this->assertEquals('<input name="biscuit" type="radio" value="" />', FormHelper::radio('biscuit', false));
     $this->assertEquals('<input name="peanut" type="radio" value="Hmmmm" checked="checked" />', FormHelper::radio('peanut', 'Hmmmm', true));
     $this->assertEquals('<input id="my-id" name="strawberry" type="radio" value="1" />', FormHelper::radio('strawberry', 1, false, AttributesHelper::f(['id' => 'my-id'])));
     $this->assertEquals('<input id="delicious" name="vegetable[cucumber]" type="radio" value="123" checked="checked" />', FormHelper::radio('vegetable[cucumber]', 123, true, AttributesHelper::f(['id' => 'delicious'])));
 }
示例#11
0
 /**
  * @param                                                         $src
  * @param \AndreasGlaser\Helpers\Html\AttributesHelper|array|null $attributesHelper
  *
  * @return string
  * @author Andreas Glaser
  */
 public static function image($src, $attributesHelper = null)
 {
     $attributesHelper = AttributesHelper::f($attributesHelper);
     $attributesHelper->set('src', $src);
     return '<img' . $attributesHelper . ' />';
 }
示例#12
0
 /**
  * @param string                                                  $name
  * @param null                                                    $value
  * @param bool                                                    $checked
  * @param \AndreasGlaser\Helpers\Html\AttributesHelper|array|null $attributesHelper
  *
  * @return string
  * @author Andreas Glaser
  */
 public static function radio($name, $value = null, $checked = false, $attributesHelper = null)
 {
     $attributesHelper = AttributesHelper::f($attributesHelper);
     $attributesHelper->set('name', $name);
     $attributesHelper->set('type', 'radio');
     $attributesHelper->set('value', $value);
     if ($checked) {
         $attributesHelper->set('checked', 'checked');
     }
     return '<input' . $attributesHelper . ' />';
 }