61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
return new class extends Lewp\Module
|
||
|
|
{
|
||
|
|
|
||
|
|
const KEY_OPTIONS_SEARCHINPUT_PLACEHOLDER = "searchinput_placeholder";
|
||
|
|
const KEY_OPTIONS_BUTTON_CONTENT_NODE = "button_content_node";
|
||
|
|
|
||
|
|
private function createSearchInput(string $placeholder)
|
||
|
|
{
|
||
|
|
return $this->createAndSetupElement(
|
||
|
|
'input',
|
||
|
|
'',
|
||
|
|
[
|
||
|
|
"type" => "text",
|
||
|
|
"placeholder" => $placeholder
|
||
|
|
]
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
private function createButton($content_node = null)
|
||
|
|
{
|
||
|
|
$button = $this->createAndSetupElement(
|
||
|
|
'button',
|
||
|
|
'',
|
||
|
|
[
|
||
|
|
"type" => "button"
|
||
|
|
]
|
||
|
|
);
|
||
|
|
|
||
|
|
if (isset($content_node)) {
|
||
|
|
$button->appendChild($this->importNode($content_node, true));
|
||
|
|
} else {
|
||
|
|
$button->appendChild($this->createTextNode('Submit'));
|
||
|
|
}
|
||
|
|
|
||
|
|
return $button;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function run(array $options = []) : bool
|
||
|
|
{
|
||
|
|
$options += [
|
||
|
|
self::KEY_OPTIONS_SEARCHINPUT_PLACEHOLDER => "",
|
||
|
|
self::KEY_OPTIONS_BUTTON_CONTENT_NODE => null
|
||
|
|
];
|
||
|
|
|
||
|
|
$this->appendChild(
|
||
|
|
$this->createSearchInput(
|
||
|
|
$options[self::KEY_OPTIONS_SEARCHINPUT_PLACEHOLDER]
|
||
|
|
)
|
||
|
|
);
|
||
|
|
|
||
|
|
$this->appendChild(
|
||
|
|
$this->createButton(
|
||
|
|
$options[self::KEY_OPTIONS_BUTTON_CONTENT_NODE]
|
||
|
|
)
|
||
|
|
);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
};
|