Merge branch 'master' of https://github.com/mcNdave/picea-ui
This commit is contained in:
commit
7a2139e4a5
|
@ -19,12 +19,12 @@ class UiPopup extends UiElement implements Extension {
|
||||||
|
|
||||||
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) : string
|
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) : string
|
||||||
{
|
{
|
||||||
return "<?php echo ( new \\" . static::class . "() )->buildAttributes($arguments) ?>";
|
return "<?php echo 'ui-popup=\"' . ( new \\" . static::class . "() )->buildAttributes($arguments) . '\"' ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildAttributes(string $name, array $variables = []) : string
|
public function buildAttributes(string $name, array $variables = []) : string
|
||||||
{
|
{
|
||||||
return json_encode([ "name" => $name, "vars" => $variables ], JSON_HEX_APOS | JSON_HEX_QUOT);
|
return htmlentities(json_encode([ "name" => $name, "vars" => $variables ], JSON_HEX_APOS | JSON_HEX_QUOT), ENT_QUOTES, 'UTF-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,6 @@ class Form implements Extension {
|
||||||
|
|
||||||
public function formClass(FormInterface $form, ? FormContext $formContext = null) : FormHandler
|
public function formClass(FormInterface $form, ? FormContext $formContext = null) : FormHandler
|
||||||
{
|
{
|
||||||
return new FormHandler($this->request, $form, $formContext ?? $this->formContext ?? null);
|
return new FormHandler($this->request, $form, $formContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||||
class FormHandler {
|
class FormHandler {
|
||||||
public bool $sent = false;
|
public bool $sent = false;
|
||||||
|
|
||||||
|
public ? bool $executionStatus = null;
|
||||||
|
|
||||||
public FormContext $context;
|
public FormContext $context;
|
||||||
|
|
||||||
protected ServerRequestInterface $request;
|
protected ServerRequestInterface $request;
|
||||||
|
@ -18,7 +20,7 @@ class FormHandler {
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->sent = $this->requestSent();
|
$this->sent = $this->requestSent();
|
||||||
$this->form = $form;
|
$this->form = $form;
|
||||||
|
|
||||||
if ( $context ) {
|
if ( $context ) {
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +47,7 @@ class FormHandler {
|
||||||
|
|
||||||
if ( $this->sent ) {
|
if ( $this->sent ) {
|
||||||
if ( $this->form->validate($this->context) ) {
|
if ( $this->form->validate($this->context) ) {
|
||||||
$this->form->execute($this->context);
|
$this->executionStatus = $this->form->execute($this->context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Picea\Ui\Method\Message;
|
namespace Picea\Ui\Method\Message;
|
||||||
|
|
||||||
use Picea\Ui\Metohd\FormMessage;
|
use Picea\Ui\Method\FormMessage;
|
||||||
|
|
||||||
class ErrorMessage implements FormMessage {
|
class ErrorMessage implements FormMessage {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Picea\Ui\Method;
|
||||||
|
|
||||||
|
use Picea\Extension\Extension,
|
||||||
|
Picea\Extension\ExtensionTrait;
|
||||||
|
|
||||||
|
use Picea\Compiler\Context;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
|
class Pagination implements Extension {
|
||||||
|
use ExtensionTrait;
|
||||||
|
|
||||||
|
public array $tokens;
|
||||||
|
|
||||||
|
public string $token;
|
||||||
|
|
||||||
|
public ServerRequestInterface $request;
|
||||||
|
|
||||||
|
public function __construct(ServerRequestInterface $request, Context $context) {
|
||||||
|
$this->request = $request;
|
||||||
|
$this->register($context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) : string { }
|
||||||
|
|
||||||
|
public function register(Context $context) : void
|
||||||
|
{
|
||||||
|
$context->pushFunction("pagination", [ $this, 'paginationClass' ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function paginationClass(string $name, ?string $url = null, ?array $params = null) : PaginationHandler
|
||||||
|
{
|
||||||
|
return new PaginationHandler($this->request, $name, $url, $params);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Picea\Ui\Method;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
|
class PaginationHandler {
|
||||||
|
|
||||||
|
protected ServerRequestInterface $request;
|
||||||
|
|
||||||
|
protected FormInterface $form;
|
||||||
|
|
||||||
|
public int $limit;
|
||||||
|
|
||||||
|
public int $offset;
|
||||||
|
|
||||||
|
public int $page = 1;
|
||||||
|
|
||||||
|
public int $count;
|
||||||
|
|
||||||
|
public string $url;
|
||||||
|
|
||||||
|
public array $params;
|
||||||
|
|
||||||
|
public function __construct(ServerRequestInterface $request, string $name, ? string $url, ? array $params)
|
||||||
|
{
|
||||||
|
$this->request = $request;
|
||||||
|
|
||||||
|
$query = $request->getQueryParams();
|
||||||
|
|
||||||
|
$this->page = $query['page'] ?? 1;
|
||||||
|
$this->limit = 15;
|
||||||
|
$this->offset = 1;
|
||||||
|
$this->count = $this->page * $this->limit;
|
||||||
|
|
||||||
|
if ( $url ) {
|
||||||
|
$this->url = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->params = $params ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString() {
|
||||||
|
return "hello world";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue