mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-06-07 15:29:55 +00:00
Fixed multiple things
This commit is contained in:
parent
0b3694d14d
commit
308cd29e79
@ -22,8 +22,7 @@ class ExampleController extends Controller
|
||||
{
|
||||
if (Authentificator::getInstance()->isLoggedIn()) {
|
||||
return "test is false!";
|
||||
} else {
|
||||
}
|
||||
return "test is true";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ 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
|
||||
@ -82,4 +82,3 @@ abstract class AbstractCache implements CacheInterface
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,17 +32,15 @@ class FileCache extends AbstractCache
|
||||
$file = $this->folder . DIRECTORY_SEPARATOR . $key;
|
||||
if (is_file($file)) {
|
||||
$content = file_get_contents($file);
|
||||
if ($content !== false) {
|
||||
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"];
|
||||
} else {
|
||||
}
|
||||
$this->delete($key);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Cache file couldn't be read", 1);
|
||||
}
|
||||
}
|
||||
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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -34,7 +34,8 @@ abstract class AbstractInput implements Input
|
||||
'id',
|
||||
'value',
|
||||
'placeholder',
|
||||
'style'
|
||||
'style',
|
||||
'disabled'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class ArrayInput extends AbstractInput
|
||||
array(
|
||||
"array_type",
|
||||
"item",
|
||||
"script"
|
||||
"click"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user