modifs.mineures sans commentaires
This commit is contained in:
parent
8df7d262cb
commit
efda96cae5
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
namespace nur\v\plugins;
|
||||||
|
|
||||||
|
use nur\v\BasePlugin;
|
||||||
|
|
||||||
|
class autorefreshPlugin extends BasePlugin {
|
||||||
|
const HAVE_JQUERY = true;
|
||||||
|
|
||||||
|
const CHECKED = true;
|
||||||
|
|
||||||
|
const TEXT = "Rafraîchir cette page automatiquement";
|
||||||
|
|
||||||
|
function __construct(?array $params=null) {
|
||||||
|
$this->checked = $params["checked"] ?? static::CHECKED;
|
||||||
|
$this->text = $params["text"] ?? static::TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool $checked;
|
||||||
|
protected string $text;
|
||||||
|
|
||||||
|
function printJquery(): void {
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery.noConflict()(function($) {
|
||||||
|
var autorefreshTimeout = null;
|
||||||
|
function autorefreshUpdate(enabled) {
|
||||||
|
if (enabled && autorefreshTimeout == null) {
|
||||||
|
autorefreshTimeout = setTimeout(function() { location.reload(); }, 15000);
|
||||||
|
} else if (!enabled && autorefreshTimeout != null) {
|
||||||
|
clearTimeout(autorefreshTimeout);
|
||||||
|
autorefreshTimeout = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($("#autorefresh").length > 0) {
|
||||||
|
$("#autorefresh").click(function() {
|
||||||
|
autorefreshUpdate($(this).is(":checked"));
|
||||||
|
});
|
||||||
|
autorefreshUpdate($("#autorefresh").is(":checked"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
function print(): void {
|
||||||
|
?>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="autorefresh"<?=$this->checked? " checked": false?>/>
|
||||||
|
<?=htmlspecialchars($this->text)?>
|
||||||
|
</label>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\ext\spreadsheet;
|
namespace nur\sery\ext\spreadsheet;
|
||||||
|
|
||||||
|
use nur\sery\cl;
|
||||||
use nur\sery\file\csv\AbstractReader;
|
use nur\sery\file\csv\AbstractReader;
|
||||||
use OpenSpout\Reader\Common\Creator\ReaderEntityFactory;
|
use OpenSpout\Reader\Common\Creator\ReaderEntityFactory;
|
||||||
|
|
||||||
|
@ -24,6 +25,8 @@ class SpoutReader extends AbstractReader {
|
||||||
# actuelle
|
# actuelle
|
||||||
$this->wsname = null;
|
$this->wsname = null;
|
||||||
}
|
}
|
||||||
|
$this->includeWsnames = cl::withn($params["include_wsnames"] ?? null);
|
||||||
|
$this->excludeWsnames = cl::withn($params["exclude_wsnames"] ?? null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ?string $ssType;
|
protected ?string $ssType;
|
||||||
|
@ -36,10 +39,22 @@ class SpoutReader extends AbstractReader {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|null si non null, liste de feuilles à inclure. n'est pris en
|
||||||
|
* compte que si $allSheets===true
|
||||||
|
*/
|
||||||
|
protected ?array $includeWsnames;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array|null si non null, liste de feuilles à exclure. n'est pris en
|
||||||
|
* compte que si $allSheets===true
|
||||||
|
*/
|
||||||
|
protected ?array $excludeWsnames;
|
||||||
|
|
||||||
protected $wsname;
|
protected $wsname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|int|null $wsname
|
* @param string|int|null $wsname l'unique feuille à sélectionner
|
||||||
*
|
*
|
||||||
* NB: appeler cette méthode réinitialise $allSheets à false
|
* NB: appeler cette méthode réinitialise $allSheets à false
|
||||||
*/
|
*/
|
||||||
|
@ -64,11 +79,18 @@ class SpoutReader extends AbstractReader {
|
||||||
$ss->open($this->input);
|
$ss->open($this->input);
|
||||||
try {
|
try {
|
||||||
$allSheets = $this->allSheets;
|
$allSheets = $this->allSheets;
|
||||||
|
$includeWsnames = $this->includeWsnames;
|
||||||
|
$excludeWsnames = $this->excludeWsnames;
|
||||||
$wsname = $this->wsname;
|
$wsname = $this->wsname;
|
||||||
$first = true;
|
$first = true;
|
||||||
foreach ($ss->getSheetIterator() as $ws) {
|
foreach ($ss->getSheetIterator() as $ws) {
|
||||||
if ($allSheets) $found = true;
|
if ($allSheets) {
|
||||||
else $found = $wsname === null || $wsname === $ws->getName();
|
$wsname = $ws->getName();
|
||||||
|
$found = ($includeWsnames === null || in_array($wsname, $includeWsnames))
|
||||||
|
&& ($excludeWsnames === null || !in_array($wsname, $excludeWsnames));
|
||||||
|
} else {
|
||||||
|
$found = $wsname === null || $wsname === $ws->getName();
|
||||||
|
}
|
||||||
if ($found) {
|
if ($found) {
|
||||||
if ($first) {
|
if ($first) {
|
||||||
$first = false;
|
$first = false;
|
||||||
|
|
Loading…
Reference in New Issue