diff --git a/chandler/MVC/SimplePresenter.php b/chandler/MVC/SimplePresenter.php index 3a4c0cc..065b9ce 100644 --- a/chandler/MVC/SimplePresenter.php +++ b/chandler/MVC/SimplePresenter.php @@ -166,9 +166,10 @@ abstract class SimplePresenter implements IPresenter return $_GET[$index] ?? NULL; } - protected function postParam(string $index): ?string + protected function postParam(string $index, bool $csrfCheck = true): ?string { - $this->assertNoCSRF(); + if($csrfCheck) + $this->assertNoCSRF(); return $_POST[$index] ?? NULL; } @@ -186,6 +187,21 @@ abstract class SimplePresenter implements IPresenter return $GLOBALS["jsonInputCache"][$index] ?? NULL; } + protected function findParam(string $index, array $searchIn = ["json", "post", "query"]): ?string + { + $res = NULL; + foreach($searchIn as $search) { + if($search === "json") + $res = $this->jsonParam($index) ?? $res; + else if($search === "post") + $res = $this->postParam($index, false) ?? $res; + else if($search === "query") + $res = $this->queryParam($index) ?? $res; + } + + return $res; + } + protected function checkbox(string $name): bool { return ($this->postParam($name) ?? "off") === "on";