diff --git a/nur_src/v/plugins/showmorePlugin.php b/nur_src/v/plugins/showmorePlugin.php index d50265a..b5dbb88 100644 --- a/nur_src/v/plugins/showmorePlugin.php +++ b/nur_src/v/plugins/showmorePlugin.php @@ -15,22 +15,40 @@ class showmorePlugin extends BasePlugin { /** @var string classe du panneau caché par défaut */ const INVITE_CONTENT = "En savoir plus..."; const PANEL_CLASS = "showmore-panel"; - + + function __construct(?array $params=null) { + $this->containerClass = $params["container_class"] ?? static::CONTAINER_CLASS; + $this->inviteClass = $params["invite_class"] ?? self::INVITE_CLASS; + $this->inviteContent = $params["invite_content"] ?? self::INVITE_CONTENT; + $this->panelClass = $params["panel_class"] ?? self::PANEL_CLASS; + $this->onShow = $params["on_show"] ?? null; + } + + protected string $containerClass; + + protected string $inviteClass, $inviteContent; + + protected string $panelClass; + + protected ?string $onShow; + function startc(): array { - return v::sdiv(["class" => self::CONTAINER_CLASS]); + return v::sdiv(["class" => $this->containerClass]); } function invite($vs=null): array { - if ($vs === null) $vs = self::INVITE_CONTENT; + $vs ??= $this->inviteContent; return v::a([ - "class" => self::INVITE_CLASS, + "class" => $this->inviteClass, "href" => "#", $vs, ]); } function startp(): array { - return v::sdiv(["class" => [self::PANEL_CLASS, "hidden"]]); + return v::sdiv([ + "class" => [$this->panelClass, "hidden"], + ]); } function endp(): array { @@ -76,7 +94,10 @@ jQuery.noConflict()(function($) { $(".").click(function() { let $this = $(this); $this.addClass("hidden"); - $this.closest(".").find(".").removeClass("hidden"); + let $container = $this.closest("."); + let $panel = $container.find("."); + $panel.removeClass("hidden"); + onShow?> return false; }); }); diff --git a/src/app/RunFile.php b/src/app/RunFile.php index 1818213..047d021 100644 --- a/src/app/RunFile.php +++ b/src/app/RunFile.php @@ -107,8 +107,8 @@ class RunFile { } } - function haveWorked(int $serial, ?int &$currentSerial=null): bool { - $data = $this->read(); + function haveWorked(int $serial, ?int &$currentSerial=null, ?array $data=null): bool { + $data ??= $this->read(); $currentSerial = $data["serial"]; return $serial !== $currentSerial; } @@ -122,7 +122,7 @@ class RunFile { } function warnIfLocked(?array $data=null): bool { - if ($data === null) $data = $this->read(); + $data ??= $this->read(); if ($data["locked"]) { msg::warning("$data[name]: possède le verrou depuis $data[date_lock]"); return true; @@ -172,22 +172,22 @@ class RunFile { } /** tester si l'application a déjà été démarrée au moins une fois */ - function wasStarted(): bool { - $data = $this->read(); + function wasStarted(?array $data=null): bool { + $data ??= $this->read(); return $data["date_start"] !== null; } /** tester si l'application est démarrée et non arrêtée */ - function isStarted(?array &$data=null): bool { - $data = $this->read(); + function isStarted(?array $data=null): bool { + $data ??= $this->read(); return $data["date_start"] !== null && $data["date_stop"] === null; } /** * vérifier si l'application marquée comme démarrée tourne réellement */ - function isRunning(?array &$data=null): bool { - $data = $this->read(); + function isRunning(?array $data=null): bool { + $data ??= $this->read(); if ($data["date_start"] === null) return false; if ($data["date_stop"] !== null) return false; if (!posix_kill($data["pid"], 0)) { @@ -216,14 +216,14 @@ class RunFile { } /** tester si l'application est déjà été stoppée au moins une fois */ - function wasStopped(): bool { - $data = $this->read(); + function wasStopped(?array $data=null): bool { + $data ??= $this->read(); return $data["date_stop"] !== null; } /** tester si l'application a été démarrée puis arrêtée */ - function isStopped(?array &$data=null): bool { - $data = $this->read(); + function isStopped(?array $data=null): bool { + $data ??= $this->read(); return $data["date_start"] !== null && $data["date_stop"] !== null; } @@ -250,8 +250,8 @@ class RunFile { return false; } $done = true; - if (!$updateDone) return null; - return ["is_done" => $done]; + if ($updateDone) return ["is_done" => $done]; + else return null; }); return $done; }