noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 07/19: http_input replace empty by a value


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 07/19: http_input replace empty by a value
Date: Thu, 12 Dec 2019 15:49:05 -0500 (EST)

sparkyx pushed a commit to tag rel7200
in repository noalyss.

commit 758544af0882eae657288e8c4d1f311f118f2aa9
Author: Dany De Bontridder <address@hidden>
Date:   Wed Dec 4 19:43:16 2019 +0100

    http_input replace empty by a value
---
 include/ajax/ajax_search_operation.php |  1 +
 include/lib/http_input.class.php       | 40 +++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/include/ajax/ajax_search_operation.php 
b/include/ajax/ajax_search_operation.php
index 9c3a5ef..0c47011 100644
--- a/include/ajax/ajax_search_operation.php
+++ b/include/ajax/ajax_search_operation.php
@@ -42,6 +42,7 @@ $base=basename($_SERVER['SCRIPT_NAME']);
 $inside=false;
 $tiers=$http->get("tiers", "string", "");
 // With the amount id, we find the amount in a html elt
+$http->set_empty(0);
 if (isset($_GET['amount_id']))
 {
     put_global(array(
diff --git a/include/lib/http_input.class.php b/include/lib/http_input.class.php
index 68d9648..fab33d2 100644
--- a/include/lib/http_input.class.php
+++ b/include/lib/http_input.class.php
@@ -34,13 +34,36 @@ class HttpInput
 {
 
     private $array;
+    private $empty; //!< if empty that replace by $empty
 
     function _construct()
     {
         $this->array=null;
+        $this->empty="";
+    }
+    public function get_array()
+    {
+        return $this->array;
     }
 
-    /**
+    public function get_empty()
+    {
+        return $this->empty;
+    }
+
+    public function set_array($array)
+    {
+        $this->array=$array;
+        return $this;
+    }
+    // $empty replace the empty value 
+    public function set_empty($empty)
+    {
+        $this->empty=$empty;
+        return $this;
+    }
+
+        /**
      * Check the type of the value
      * @param $p_name name of the variable
      * @param $p_type type of the variable (number,string,date,array)
@@ -53,10 +76,17 @@ class HttpInput
         {
             // no check on string
             if ($p_type=="string")
+            {
                 return;
+            }
             // Check if number
             else if ($p_type=="number")
             {
+                if (empty($this->array[$p_name]))
+                {
+                    $this->array[$p_name]=$this->empty;
+                }
+
                 if ( isNumber($this->array[$p_name])==0 )
                 {
                     throw new Exception(_("Type invalide")."[ $p_name ] = 
{$this->array[$p_name]}"
@@ -67,6 +97,10 @@ class HttpInput
             // Check if date dd.mm.yyyy
             else if ($p_type=="date")
             {
+                if (empty($this->array[$p_name]))
+                {
+                    $this->array[$p_name]=$this->empty;
+                }
                 if (isDate($this->array[$p_name]) <> $this->array[$p_name])
                 {
                     throw new Exception(_("Type invalide")."[ $p_name ] = 
{$this->array[$p_name]}"
@@ -76,6 +110,10 @@ class HttpInput
             }
             else if ($p_type=="array")
             {
+                if (empty($this->array[$p_name]))
+                {
+                    $this->array[$p_name]=$this->empty;
+                }
                 if (!is_array($this->array[$p_name]) ) {
                     throw new Exception(_("Type invalide")."[ $p_name ] = 
{$this->array[$p_name]}"
                 , EXC_PARAM_TYPE);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]