modifs.mineures sans commentaires
This commit is contained in:
		
							parent
							
								
									8df7d262cb
								
							
						
					
					
						commit
						efda96cae5
					
				
							
								
								
									
										53
									
								
								nur_src/v/plugins/autorefreshPlugin.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								nur_src/v/plugins/autorefreshPlugin.php
									
									
									
									
									
										Normal file
									
								
							@ -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
 | 
			
		||||
namespace nur\sery\ext\spreadsheet;
 | 
			
		||||
 | 
			
		||||
use nur\sery\cl;
 | 
			
		||||
use nur\sery\file\csv\AbstractReader;
 | 
			
		||||
use OpenSpout\Reader\Common\Creator\ReaderEntityFactory;
 | 
			
		||||
 | 
			
		||||
@ -24,6 +25,8 @@ class SpoutReader extends AbstractReader {
 | 
			
		||||
      # actuelle
 | 
			
		||||
      $this->wsname = null;
 | 
			
		||||
    }
 | 
			
		||||
    $this->includeWsnames = cl::withn($params["include_wsnames"] ?? null);
 | 
			
		||||
    $this->excludeWsnames = cl::withn($params["exclude_wsnames"] ?? null);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected ?string $ssType;
 | 
			
		||||
@ -35,11 +38,23 @@ class SpoutReader extends AbstractReader {
 | 
			
		||||
    $this->allSheets = $allSheets;
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @param string|int|null $wsname
 | 
			
		||||
   * @param string|int|null $wsname l'unique feuille à sélectionner
 | 
			
		||||
   *
 | 
			
		||||
   * NB: appeler cette méthode réinitialise $allSheets à false
 | 
			
		||||
   */
 | 
			
		||||
@ -64,11 +79,18 @@ class SpoutReader extends AbstractReader {
 | 
			
		||||
    $ss->open($this->input);
 | 
			
		||||
    try {
 | 
			
		||||
      $allSheets = $this->allSheets;
 | 
			
		||||
      $includeWsnames = $this->includeWsnames;
 | 
			
		||||
      $excludeWsnames = $this->excludeWsnames;
 | 
			
		||||
      $wsname = $this->wsname;
 | 
			
		||||
      $first = true;
 | 
			
		||||
      foreach ($ss->getSheetIterator() as $ws) {
 | 
			
		||||
        if ($allSheets) $found = true;
 | 
			
		||||
        else $found = $wsname === null || $wsname === $ws->getName();
 | 
			
		||||
        if ($allSheets) {
 | 
			
		||||
          $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 ($first) {
 | 
			
		||||
            $first = false;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user