<?php
|
|
/**
|
* Bean dati di upload
|
*
|
* Raccolgo i dati necessari per effettuare l'upload dei file e configurare la <br>
|
* pagina in modo dinamico, da passare a Smarty per inizializzare il codice <br>
|
* javascript di gestione del plupload
|
*
|
* @author Cristiano Magro
|
*/
|
class SetupUpload {
|
|
private $queueLimitUpload;
|
private $totLimitUpload;
|
private $sizeLimitFileUpload;
|
private $totLimitUploadTest;
|
private $fileFilterExt;
|
private $random;
|
private $pathUploadKey;
|
private $numMaxFiles = '1';
|
private $sizeMaxFilesByte;
|
private $sizeMaxFilesDesc;
|
private $debugPageActive = false;
|
|
/**
|
* Builder statico
|
*
|
* @return \SetupUpload
|
*/
|
public static function create() {
|
$instance = new self;
|
return $instance;
|
}
|
|
public function getQueueLimit() {
|
return $this->queueLimitUpload;
|
}
|
|
public function setQueueLimit($x) {
|
$this->queueLimitUpload = $x;
|
return $this;
|
}
|
|
public function getTotalLimit() {
|
return $this->totLimitUpload;
|
}
|
|
public function setTotalLimit($x) {
|
$this->totLimitUpload = $x;
|
return $this;
|
}
|
|
public function getSizeLimitFile() {
|
return $this->sizeLimitFileUpload;
|
}
|
|
public function setSizeLimitFile($x) {
|
$this->sizeLimitFileUpload = $x;
|
return $this;
|
}
|
|
public function getLimitText() {
|
return $this->totLimitUploadTest;
|
}
|
|
public function setLimitText($x) {
|
$this->totLimitUploadTest = $x;
|
return $this;
|
}
|
|
public function getFilesFilter() {
|
return $this->fileFilterExt;
|
}
|
|
public function setFilesFilter($x) {
|
$this->fileFilterExt = $x;
|
return $this;
|
}
|
|
public function getRandomValue() {
|
return $this->random;
|
}
|
|
public function setRandomValue($x) {
|
$this->random = $x;
|
return $this;
|
}
|
|
public function getPathUploadKey() {
|
return $this->pathUploadKey;
|
}
|
|
/**
|
* Chiave per decodificare la directory di salvataggio dei file
|
*
|
* La chiave viene utilizzata per ricavare dalla mappatura delle directory, il
|
* path in cui salvare il file. Da utilizzare per offuscare il filesystem del
|
* server. La directory non viene mai passata nei parametri.
|
*
|
* @param string $pathKey necessaria per accedere alla mappatura
|
*
|
* @return \SetupUpload
|
*/
|
public function setPathUploadKey($pathKey) {
|
$this->pathUploadKey = $pathKey;
|
return $this;
|
}
|
|
public function getNumMaxFiles() {
|
return $this->numMaxFiles;
|
}
|
|
public function setNumMaxFiles($x) {
|
$this->numMaxFiles = $x;
|
return $this;
|
}
|
|
public function getSizeMaxFilesByte() {
|
return $this->sizeMaxFilesByte;
|
}
|
|
public function setSizeMaxFilesByte($x) {
|
$this->sizeMaxFilesByte = $x;
|
return $this;
|
}
|
|
public function getSizeMaxFilesDesc() {
|
return $this->sizeMaxFilesDesc;
|
}
|
|
public function setSizeMaxFilesDesc($x) {
|
$this->sizeMaxFilesDesc = $x;
|
return $this;
|
}
|
|
public function getDebugActive() {
|
return $this->debugPageActive;
|
}
|
|
public function setDebugActive($x) {
|
$this->debugPageActive = $x;
|
return $this;
|
}
|
|
/**
|
* Creo JSON con i dati per inizializzare la pagina
|
*
|
* Per inizializzare l'oggetto JS che fa da schiavo a pluploader per la
|
* configurazione della pagina, creo un json string con i dati di configurazione
|
* che verranno passati a Smarty.
|
*
|
* @return string json
|
*/
|
public function createJsonSetup() {
|
$dati = array(
|
'QUEUE_LIMIT_UPLOAD' => $this->getQueueLimit(),
|
'TOT_LIMIT_UPLOAD' => $this->getSizeMaxFilesByte(),
|
'SIZE_LIMIT_UPLOAD' => $this->getSizeLimitFile(),
|
'TOT_LIMIT_UPLOAD_TXT' => $this->getSizeMaxFilesDesc(),
|
'NUM_MAX_FILES' => $this->getNumMaxFiles(),
|
);
|
|
return json_encode($dati);
|
}
|
|
}
|