noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 69/119: Improve Input_Switch , do not echo bu


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 69/119: Improve Input_Switch , do not echo but returns string
Date: Mon, 26 Oct 2020 18:27:24 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 30688bda9d5edda7a8da833ad97bef4573b6fce9
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Sat Oct 10 19:35:10 2020 +0200

    Improve Input_Switch , do not echo but returns string
---
 include/lib/input_switch.class.php | 15 ++++++++-------
 include/template/param_jrn.php     |  2 +-
 scenario/HtmlInput.test.php        |  8 ++++----
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/include/lib/input_switch.class.php 
b/include/lib/input_switch.class.php
index ba67d7f..3d8345c 100644
--- a/include/lib/input_switch.class.php
+++ b/include/lib/input_switch.class.php
@@ -45,6 +45,7 @@ class InputSwitch extends HtmlInput
 
     function input($p_name=NULL, $p_value=NULL)
     {
+        $r="";
         if ($p_name!=NULL)
             $this->value_container=$p_name;
         if ($p_value!==NULL)
@@ -56,25 +57,25 @@ class InputSwitch extends HtmlInput
              throw new Exception(_("Valeur invalide"),1);
         }
         if ($this->readOnly == TRUE) {
-            $this->display();
-            return;
+            return $this->display();
         }
-        echo HtmlInput::hidden($this->value_container, $this->value);
+        $r.= HtmlInput::hidden($this->value_container, $this->value);
         
         
$this->javascript=sprintf('toggle_onoff(\'%s\',\'%s\');%s;',$this->icon,$this->value_container,$this->javascript);
         
         if ($this->value=='1') {
-            echo Icon_Action::iconon($this->icon, $this->javascript);
+            $r.=Icon_Action::iconon($this->icon, $this->javascript);
         } else {
-            echo Icon_Action::iconoff($this->icon, $this->javascript);
+            $r.=Icon_Action::iconoff($this->icon, $this->javascript);
         }
+        return $r;
     }
     function display()
     {
         if ($this->value=='1') {
-            echo Icon_Action::iconon($this->icon, "");
+            return  Icon_Action::iconon($this->icon, "");
         } else {
-            echo Icon_Action::iconoff($this->icon, "");
+            return Icon_Action::iconoff($this->icon, "");
         }
     }
 
diff --git a/include/template/param_jrn.php b/include/template/param_jrn.php
index 6c73529..1d0ce32 100644
--- a/include/template/param_jrn.php
+++ b/include/template/param_jrn.php
@@ -98,7 +98,7 @@ if ( $type == 'ACH' || $type == 'VEN'||$new):
         <td>
            <?php
                 
$negative->javascript="toggle_row_warning_enable('negative_amount','row_warning')";
-                $negative->input();
+                echo $negative->input();
             ?>
         </td>
     </tr>
diff --git a/scenario/HtmlInput.test.php b/scenario/HtmlInput.test.php
index 027f4eb..363a8fd 100644
--- a/scenario/HtmlInput.test.php
+++ b/scenario/HtmlInput.test.php
@@ -61,25 +61,25 @@ $http=new HttpInput();
     <pre>
         
     $input_switch=new InputSwitch('input_switch_value',<?php echo 
$http->get("input_switch_value","string","0")?>);
-    $input_switch->input();
+    echo $input_switch->input();
     </pre>
     input_switch 
     <?php
     
     $input_switch=new 
InputSwitch('input_switch_value',$http->get("input_switch_value","string","0"));
-    $input_switch->input();
+    echo $input_switch->input();
     ?>
     <h2>ReadOnly</h2>
     <pre>
     $input_switch=new InputSwitch('input_switch_readonly',0);
     $input_switch->readOnly=TRUE;
-    $input_switch->input();
+    echo  $input_switch->input();
     </pre>
     input_switch
     <?php
     $input_switch=new InputSwitch('input_switch_readonly',0);
     $input_switch->readOnly=TRUE;
-    $input_switch->input();
+    echo $input_switch->input();
     ?>
     <h1>Submit</h1>
     <pre>



reply via email to

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