From 54655e3e7145384132a6be67a13a7f62dbcf8fd1 Mon Sep 17 00:00:00 2001
From: Cristiano Magro <cristiano.magro@vola.it>
Date: Tue, 27 Aug 2019 11:35:47 +0200
Subject: [PATCH] Merge branch 'FilesFilter'
---
src/Vola/UploadFile/FilterExt.class.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/src/Vola/UploadFile/FilterExt.class.php b/src/Vola/UploadFile/FilterExt.class.php
new file mode 100644
index 0000000..6a379e2
--- /dev/null
+++ b/src/Vola/UploadFile/FilterExt.class.php
@@ -0,0 +1,60 @@
+<?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;
+ }
+
+ public function getFilterObj()
+ {
+ return json_decode($this->getFilter());
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0