Activated strict SQL mode, minor SQL injection fix, fixed _vl() debug helper.
[fa-stable.git] / includes / ui / ui_input.inc
index 5aa4f5694a0d1d29ba3ff9500641fdef5db6ba14..59a3676ef5664ed7ccc7bd004411ac37c2c824aa 100644 (file)
@@ -159,6 +159,7 @@ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=fal
                                        if ($icon===false) $icon=ICON_ESCAPE; break;
 
                                case 'nonajax':
+                               case 'download':
                                        $atype = false;
                        }
                }
@@ -287,7 +288,7 @@ function set_icon($icon, $title=false)
        global $path_to_root;
        if (basename($icon) === $icon) // standard icons does not contain path separator
                $icon = "$path_to_root/themes/".user_theme()."/images/$icon";
-       return "<img src='$icon' width='12' height='12' border='0'".($title ? " title='$title'" : "")." >\n";   
+       return "<img src='$icon' style='vertical-align:middle;width:12px;height:12px;border:0;'".($title ? " title='$title'" : "")." >\n";      
 }
 
 function button($name, $value, $title=false, $icon=false,  $aspect='')
@@ -304,7 +305,7 @@ function button($name, $value, $title=false, $icon=false,  $aspect='')
                if ($value == _("Delete")) // Helper during implementation
                        $icon = ICON_DELETE;
                return "<button type='submit' class='editbutton' name='"
-                       .htmlentities(strtr($name, array('.'=>'=2E', '='=>'=3D',// ' '=>'=20','['=>'=5B'
+                       .html_specials_encode(strtr($name, array('.'=>'=2E', '='=>'=3D',// ' '=>'=20','['=>'=5B'
                        )))
                        ."' value='1'" . ($title ? " title='$title'":" title='$value'")
                        . ($aspect ? " aspect='$aspect'" : '')
@@ -347,9 +348,13 @@ function select_button_cell($name, $value, $title=false)
 
 function check_value($name)
 {
-       if (!isset($_POST[$name]) || $_POST[$name]=='')
-               return 0;
-       return 1;
+       if (is_array($name)) {
+               $ret = array();
+               foreach($name as $key)
+                       $ret[$key] = check_value($key);
+               return $ret;
+       } else
+               return (empty($_POST[$name]) ? 0 : 1);
 }
 
 function checkbox($label, $name, $value=null, $submit_on_change=false, $title=false)
@@ -728,19 +733,19 @@ function ref_cells($label, $name, $title=null, $init=null, $params=null, $submit
                if (empty($_POST[$name.'_list'])) // restore refline id
                        $_POST[$name.'_list'] = $Refs->reflines->find_refline_id(empty($_POST[$name]) ? $init : $_POST[$name], $type);
 
-               if (empty($_POST[$name]) || ($_SERVER['REQUEST_METHOD'] == 'GET')) // initialization
+               if (empty($_POST[$name])) // initialization
                {
                        if (isset($init))
                        {
                                $_POST[$name] = $init;
                        } else {
-                               $_POST[$name] = $Refs->get_next($type, $_POST[$name.'_list'], $context); // set default
+                               $_POST[$name] = $Refs->get_next($type, $_POST[$name.'_list'], $context);
                        }
                        $Ajax->addUpdate(true, $name, $_POST[$name]);
                }
 
                if (check_ui_refresh($name)) { // call context changed
-                       $_POST[$name] = $Refs->normalize($init, $type, $context, $_POST[$name.'_list']);
+                       $_POST[$name] = $Refs->normalize($_POST[$name], $type, $context, $_POST[$name.'_list']);
                        $Ajax->addUpdate(true, $name, $_POST[$name]);
                }
 
@@ -759,7 +764,7 @@ function ref_cells($label, $name, $title=null, $init=null, $params=null, $submit
 
                label_cell($list."<input name='".$name."' "
                        .(check_edit_access($name) ? '' : 'disabled ')
-                       ."value='".@$_POST[$name]."' size=10 maxlength=35>");
+                       ."value='".@$_POST[$name]."' size=16 maxlength=35>");
        }
        else // just wildcard ref field (e.g. for global inquires)
        {
@@ -1012,3 +1017,12 @@ function bank_balance_row($bank_acc, $parms='')
                ."</a>", $parms);
 }
 
+function ahref($label, $href, $target="", $onclick="") {
+  echo "<a href='$href' target='$target' onclick='$onclick'>$label</a>";
+}
+
+function ahref_cell($label, $href, $target="", $onclick="") {
+  echo "<td align='center'>&nbsp;&nbsp;";
+  ahref($label, $href, $target, $onclick);
+  echo "&nbsp;&nbsp;</td>";
+}