| | |
| | | |
| | | public function toJson() |
| | | { |
| | | return json_encode($this->filtro); |
| | | |
| | | $temp = array (); |
| | | |
| | | /** @var FilterExt $filtro */ |
| | | foreach ($this->filtro as $filtro){ |
| | | $temp[] = $filtro->getFilterObj(); |
| | | } |
| | | |
| | | return json_encode($temp); |
| | | } |
| | | |
| | | 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; |
| | | if ($extension != '') { |
| | | $titolo = $this->decodeTitolo($extension); |
| | | if ($titolo != null) { |
| | | if($this->filtro[$titolo] instanceof FilterExt){ |
| | | $this->filtro[$titolo]->addExt($extension); |
| | | } else { |
| | | $filtro = new FilterExt($titolo, $extension); |
| | | $this->filtro[$titolo] = $filtro; |
| | | } |
| | | } |
| | | } |
| | | return $this; |