Widget/Lists: add widget missing in ipl/incubator
This commit is contained in:
parent
087b09d363
commit
04f0dc51f1
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\Widget;
|
||||
|
||||
use ipl\Html\Attributes;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Html\HtmlElement;
|
||||
|
||||
class AbstractList extends BaseHtmlElement
|
||||
{
|
||||
protected $contentSeparator = "\n";
|
||||
|
||||
/**
|
||||
* AbstractList constructor.
|
||||
* @param array $items
|
||||
* @param null $attributes
|
||||
*/
|
||||
public function __construct(array $items = [], $attributes = null)
|
||||
{
|
||||
foreach ($items as $item) {
|
||||
$this->addItem($item);
|
||||
}
|
||||
|
||||
if ($attributes !== null) {
|
||||
$this->addAttributes($attributes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Html|array|string $content
|
||||
* @param Attributes|array $attributes
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addItem($content, $attributes = null)
|
||||
{
|
||||
return $this->add(HtmlElement::create('li', $attributes, $content));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\Widget;
|
||||
|
||||
use ipl\Html\Attributes;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Html\ValidHtml;
|
||||
|
||||
class ListItem extends BaseHtmlElement
|
||||
{
|
||||
protected $contentSeparator = "\n";
|
||||
|
||||
/**
|
||||
* @param ValidHtml|array|string $content
|
||||
* @param Attributes|array $attributes
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function addItem($content, $attributes = null)
|
||||
{
|
||||
return $this->add(
|
||||
Html::tag('li', $attributes, $content)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\Widget;
|
||||
|
||||
class OrderedList extends AbstractList
|
||||
{
|
||||
protected $tag = 'ol';
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Web\Widget;
|
||||
|
||||
class UnorderedList extends AbstractList
|
||||
{
|
||||
protected $tag = 'ul';
|
||||
}
|
Loading…
Reference in New Issue