<?php
|
/**
|
* Costruzione di un filtro
|
* User: Cristiano Magro
|
* Date: 09/07/2019
|
*/
|
|
class FilterExt
|
{
|
private $titolo;
|
private $extensions;
|
|
public function __construct($titolo = null, $ext = null)
|
{
|
$this->titolo = $titolo;
|
$this->extensions[$ext] = $ext;
|
}
|
|
/**
|
* Costruisco la struttura json del filtro.
|
* La lista viene collassata in una stringa
|
* @return string struttura json del filtro
|
*/
|
public function getFilter()
|
{
|
$new = new stdClass();
|
$new->title = $this->titolo;
|
|
//riordino le chiavi
|
sort($this->extensions);
|
|
$new->extensions = implode(',', $this->extensions);
|
|
return json_encode($new);
|
}
|
|
/**
|
* Aggiungo alla lista una estensione.
|
* @param string $newExt
|
* @return FilterExt
|
*/
|
public function addExt($newExt)
|
{
|
$this->extensions[$newExt] = $newExt;
|
return $this;
|
}
|
|
/**
|
* @return string Titolo del filtro
|
*/
|
public function getTitolo()
|
{
|
return $this->titolo;
|
}
|
}
|