Fixed multiple things

This commit is contained in:
Florian Bouillon 2019-05-07 14:36:33 +02:00
parent 0b3694d14d
commit 308cd29e79
No known key found for this signature in database
GPG Key ID: B143FF27EF555D16
11 changed files with 30 additions and 35 deletions

View File

@ -22,8 +22,7 @@ class ExampleController extends Controller
{
if (Authentificator::getInstance()->isLoggedIn()) {
return "test is false!";
} else {
return "test is true";
}
return "test is true";
}
}

View File

@ -73,13 +73,12 @@ abstract class AbstractCache implements CacheInterface
{
if (is_int($ttl)) {
return $ttl;
} else {
return
((($ttl->y * 365 + $ttl->m * 30 + $ttl->d //translate to days
) * 24 + $ttl->h //translate to hours
) * 60 + $ttl->i //translate to minutes
) * 60 + $ttl->s //translate to seconds
;
}
return
((($ttl->y * 365 + $ttl->m * 30 + $ttl->d //translate to days
) * 24 + $ttl->h //translate to hours
) * 60 + $ttl->i //translate to minutes
) * 60 + $ttl->s //translate to seconds
;
}
}

View File

@ -32,16 +32,14 @@ class FileCache extends AbstractCache
$file = $this->folder . DIRECTORY_SEPARATOR . $key;
if (is_file($file)) {
$content = file_get_contents($file);
if ($content !== false) {
$res = unserialize($content);
if ($res["ttl"] > time() && $res['value'] !== null) {
return $res["value"];
} else {
$this->delete($key);
}
} else {
if ($content === false) {
throw new Exception("Cache file couldn't be read", 1);
}
$res = unserialize($content);
if ($res["ttl"] > time() && $res['value'] !== null) {
return $res["value"];
}
$this->delete($key);
}
return $default;
}
@ -51,7 +49,7 @@ class FileCache extends AbstractCache
if (!$this->checkKey($key)) {
throw new InvalidArgumentException("key is not valid");
}
$tl = $ttl != null ? $this->getTTL($ttl) : $this->ttl;
$tl = isset($ttl) ? $this->getTTL($ttl) : $this->ttl;
$arr = array(
"value" => $value,
'ttl' => time() + $tl

View File

@ -28,9 +28,8 @@ class SessionCache extends AbstractCache
$item = $_SESSION[$key];
if ($item["ttl"] > time() && $item["value"] !== null) {
return $item["value"];
} else {
$this->delete($key);
}
$this->delete($key);
}
return $default;
}
@ -58,7 +57,6 @@ class SessionCache extends AbstractCache
public function clear()
{
dump(phpversion());
if (phpversion() !== false && version_compare(phpversion(), '7.2.0', '>=')) {
return session_reset();
}

View File

@ -59,7 +59,7 @@ class Form
private function addField($name, $settings)
{
/** @var \DeltaCMS\Form\Input */
$field = $this->getField($settings->type);
$field = $this->getField($settings["type"]);
$entity = $this->session->get("form_" . $this->formname, null);
$func = "get" . ucfirst($name);
@ -69,8 +69,6 @@ class Form
foreach ($settings as $settingName => $value) {
$field->setOption($settingName, $value);
}
// dump($_POST[$name]);
dump($name, $field->getValue());
$this->$name = $field->render();
}
@ -84,7 +82,7 @@ class Form
if (isset($forms[$formname])) {
$this->formname = $formname;
$form = $forms[$formname];
$this->fields = $form->fields;
$this->fields = $form["fields"];
// dd($this->fields);
if ($this->isSubmitting()) {
if ($entity !== null) {

View File

@ -34,7 +34,8 @@ abstract class AbstractInput implements Input
'id',
'value',
'placeholder',
'style'
'style',
'disabled'
);
}

View File

@ -21,7 +21,7 @@ class ArrayInput extends AbstractInput
array(
"array_type",
"item",
"script"
"click"
)
);
}

View File

@ -17,7 +17,7 @@ class DatalistInput extends AbstractInput
public function setOption(string $name, $value)
{
if ($name === "name") {
$this->attributes["list"] = $name . "_list";
$this->attributes["list"] = $value . "_list";
}
parent::setOption($name, $value);
}

View File

@ -8,11 +8,11 @@ class DateInput extends AbstractInput
{
public function setOption(string $name, $value)
{
if ($name === "value") {
if ($name === "value" && $value !== null) {
$this->attributes["value"] = (new DateTime($value))->format('Y-m-d');
} else {
parent::setOption($name, $value);
return;
}
parent::setOption($name, $value);
}
public function getValue($name = null)

View File

@ -11,5 +11,5 @@
{% endblock %}
{% block after %}
<button type="button" data-for="{{ attributes.name }}">Ajouter</button>
<button type="button" data-for="{{ attributes.name }}" onclick="{{ options.click }}">Ajouter</button>
{% endblock %}

View File

@ -3,13 +3,15 @@
{% block after %}
<datalist id="{{ attributes.list }}">
{% for entity in options.entities %}
<option data-id="{{ entity.id }}">
{% if entity.name is not null %}
<option>{{entity.name}}</option>
{{entity.name}}
{% elseif entity.firstname is not null %}
<option>{{entity.firstname}}</option>
{{entity.firstname}} {{ entity.lastname }}
{% else %}
<option>{{entity.id}}</option>
{{entity.id}}
{% endif %}
</option>
{% endfor %}
</datalist>
{% endblock %}