modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-06-26 11:18:44 +04:00
parent 92ad052682
commit 70e9c4d268
3 changed files with 47 additions and 7 deletions

View File

@ -71,6 +71,9 @@ abstract class Application {
*/ */
const USE_RUNLOCK = false; const USE_RUNLOCK = false;
/** @var bool faut-il installer le gestionnaire de signaux? */
const USE_SIGNAL_HANDLER = false;
protected static function _app_init(): void { protected static function _app_init(): void {
config::set_fact(config::FACT_CLI_APP); config::set_fact(config::FACT_CLI_APP);
@ -137,10 +140,26 @@ abstract class Application {
static function run(?Application $app=null): void { static function run(?Application $app=null): void {
$unlock = false; $unlock = false;
$stop = false; $stop = false;
register_shutdown_function(function () use (&$unlock, &$stop) { $shutdownHandler = function () use (&$unlock, &$stop) {
if ($unlock) app::get()->getRunfile()->release(); if ($unlock) {
if ($stop) app::get()->getRunfile()->wfStop(); app::get()->getRunfile()->release();
}); $unlock = false;
}
if ($stop) {
app::get()->getRunfile()->wfStop();
$stop = false;
}
};
register_shutdown_function($shutdownHandler);
if (static::USE_SIGNAL_HANDLER) {
$signalHandler = function(int $signo, $siginfo) {
self::exit(255);
};
pcntl_signal(SIGHUP, $signalHandler);
pcntl_signal(SIGINT, $signalHandler);
pcntl_signal(SIGQUIT, $signalHandler);
pcntl_signal(SIGTERM, $signalHandler);
}
try { try {
static::_app_init(); static::_app_init();
if (static::USE_RUNFILE) { if (static::USE_RUNFILE) {

View File

@ -3,6 +3,7 @@ namespace nur\v\bs3\vc;
use nur\b\params\Tparametrable; use nur\b\params\Tparametrable;
use nur\b\ValueException; use nur\b\ValueException;
use nur\func;
use nur\v\vo; use nur\v\vo;
/** /**
@ -14,7 +15,9 @@ class CListGroup extends _CItemList {
const CONTAINER = null; const CONTAINER = null;
const PARAMETRABLE_PARAMS_SCHEMA = [ const PARAMETRABLE_PARAMS_SCHEMA = [
"list_group_class" => ["?array", null, "classe CSS de la liste"],
"container" => ["string", "ul", "container de la liste: ul ou div"], "container" => ["string", "ul", "container de la liste: ul ou div"],
"item_func" => ["?callable", null, "fonction avec la signature (\$vs, \$item) retournant l'élément à afficher"],
]; ];
function __construct(?iterable $items=null, ?array $params=null) { function __construct(?iterable $items=null, ?array $params=null) {
@ -24,6 +27,8 @@ class CListGroup extends _CItemList {
parent::__construct($items, $params); parent::__construct($items, $params);
} }
protected $ppListGroupClass;
private $ctag, $itag; private $ctag, $itag;
function pp_setContainer(string $container): self { function pp_setContainer(string $container): self {
@ -42,6 +47,14 @@ class CListGroup extends _CItemList {
return $this; return $this;
} }
/** @var array */
protected $itemCtx;
function pp_setItemFunc($itemFunc): void {
if ($itemFunc === null) $this->itemCtx = null;
else $this->itemCtx = func::_prepare($itemFunc);
}
/** retourner le contenu associé au conteneur */ /** retourner le contenu associé au conteneur */
function container(): ?array { function container(): ?array {
return null; return null;
@ -49,7 +62,7 @@ class CListGroup extends _CItemList {
protected function _printStartContainer($container): void { protected function _printStartContainer($container): void {
vo::start($this->ctag, [ vo::start($this->ctag, [
"class" => "list-group", "class" => ["list-group", $this->ppListGroupClass],
$this->container(), $this->container(),
]); ]);
} }
@ -64,7 +77,11 @@ class CListGroup extends _CItemList {
/** retourner le contenu associé à l'élément spécifié. */ /** retourner le contenu associé à l'élément spécifié. */
function item($item): ?iterable { function item($item): ?iterable {
return [$item]; $vs = [$item];
if ($this->itemCtx !== null) {
$vs = func::_call($this->itemCtx, [$vs, $item]);
}
return $vs;
} }
protected function _printStartItem(): void { protected function _printStartItem(): void {

View File

@ -30,7 +30,11 @@ class autorefreshPlugin extends BasePlugin {
<script type="text/javascript"> <script type="text/javascript">
jQuery.noConflict()(function($) { jQuery.noConflict()(function($) {
var autorefreshTimeout = null; var autorefreshTimeout = null;
function autorefreshEnabled() {
return $("#autorefresh").is(":checked");
}
function autorefreshUpdate(enabled) { function autorefreshUpdate(enabled) {
if (typeof(enabled) === 'undefined') enabled = autorefreshEnabled();
if (enabled && autorefreshTimeout == null) { if (enabled && autorefreshTimeout == null) {
autorefreshTimeout = setTimeout(function() { location.reload(); }, <?=$this->delay?>); autorefreshTimeout = setTimeout(function() { location.reload(); }, <?=$this->delay?>);
} else if (!enabled && autorefreshTimeout != null) { } else if (!enabled && autorefreshTimeout != null) {
@ -42,7 +46,7 @@ jQuery.noConflict()(function($) {
$("#autorefresh").click(function() { $("#autorefresh").click(function() {
autorefreshUpdate($(this).is(":checked")); autorefreshUpdate($(this).is(":checked"));
}); });
autorefreshUpdate($("#autorefresh").is(":checked")); autorefreshUpdate();
} }
}); });
</script> </script>