<?php
|
/**
|
* User: Cristiano Magro
|
* Date: 08/07/2019
|
*/
|
|
class FilesFilter
|
{
|
|
private $filtro = array();
|
|
public function toJson()
|
{
|
return json_encode($this->filtro);
|
}
|
|
public function addExt($extension = '')
|
{
|
if ($extension != ''){
|
switch(strtolower($extension)) {
|
case 'gif':
|
$this->filtro[] = json_decode('{"title":"Image files", "extensions":"gif"}', true);
|
break;
|
case 'doc':
|
$this->filtro[] = json_decode('{"title":"Documenti", "extensions":"doc"}', true);
|
break;
|
}
|
}
|
return $this;
|
}
|
|
/**
|
* Decodifico il titolo in base all'estensione.
|
* Il confronto viene eseguito in lowercase
|
* @param string $ext
|
* @return string
|
*/
|
public function decodeTitolo($ext)
|
{
|
switch (strtolower($ext)) {
|
case 'gif':
|
$titolo = "Image files";
|
break;
|
case 'doc':
|
case 'txt':
|
$titolo = "Documenti";
|
break;
|
}
|
|
return $titolo;
|
}
|
|
}
|