Wrong email-adress field taken when emailing documents [0000035].
[fa-stable.git] / includes / ui / ui_input.inc
index ad27a4491b16716dd193c4fa7ccca85a3e731260..f1fb3691c1d6d45914a4b602ac49e6e0f0001e99 100644 (file)
@@ -32,15 +32,47 @@ function find_submit($prefix, $numeric=true)
     }
     return $numeric ? -1 : null;
 }
+//------------------------------------------------------------------------------
+//
+// Helper function for simple db table editor pages
+//
+function simple_page_mode($numeric_id = true)
+{
+       global $Ajax, $Mode, $selected_id;
+
+       $default = $numeric_id ? -1 : '';
+       $selected_id = get_post('selected_id', $default);
+       foreach (array('ADD_ITEM', 'UPDATE_ITEM', 'RESET') as $m) {
+               if (isset($_POST[$m])) {
+                       $Ajax->activate('_page_body');
+                       if ($m == 'RESET') 
+                               $selected_id = $default;
+                       $Mode = $m; return;
+               }
+       }
+       foreach (array('Edit', 'Delete') as $m) {
+               foreach ($_POST as $p => $pvar) {
+                       if (strpos($p, $m) === 0) {
+//                             $selected_id = strtr(substr($p, strlen($m)), array('%2E'=>'.'));
+                               unset($_POST['_focus']); // focus on first form entry
+                               $selected_id = quoted_printable_decode(substr($p, strlen($m)));
+                               $Ajax->activate('_page_body');
+                               $Mode = $m;
+                               return;
+                       }
+               }
+       }
+       $Mode = '';
+}
 
 //------------------------------------------------------------------------------
 //
 //     Read numeric value from user formatted input
 //
-function input_num($postname=null)
+function input_num($postname=null, $dflt=null)
 {
        if (!isset($_POST[$postname]))
-               return null;
+               return $dflt;
 
     return user_numeric($_POST[$postname]);
 }
@@ -65,9 +97,10 @@ function hidden($name, $value=null, $echo=true)
 //---------------------------------------------------------------------------------
 //     Submit button.
 //     $async parameter can have 3 values:
+//             null - fallback button not visible in js enabled mode
 //             false - normal submit via form action
 //             true  - when js is on submition via ajax call
-//             null - fallback button not visible in js enabled mode
+//             'process' - ditto with processing indicator in msgbox
 //
 function submit($name, $value, $echo=true, $title=false, $async=false)
 {
@@ -76,7 +109,8 @@ function submit($name, $value, $echo=true, $title=false, $async=false)
        $submit_str = "<input type=\"submit\" class=\""
            .($async ? 'ajaxsubmit' : 'inputsubmit')
                ."\""
-               .($async === null ? (in_ajax() ? " style='display:none;'" : ' fallback="1"' ): '')
+               .($async === null ? (in_ajax() ? " style='display:none;'" : ' aspect="fallback"' ): 
+                       ($async === 'process' ? 'aspect="process"' : '') )
            ." name=\"$name\"  id=\"$name\" value=\"$value\""
            .($title ? " title='$title'" : '')
            .">\n";
@@ -110,9 +144,11 @@ function submit_center_last($name, $value, $title=false, $async=false)
 function submit_add_or_update($add=true, $title=false, $async=false)
 {
        if ($add)
-               submit('ADD_ITEM', _("Save"), true, $title, $async);
-       else
+               submit('ADD_ITEM', _("Add new"), true, $title, $async);
+       else {
                submit('UPDATE_ITEM', _("Update"), true, $title, $async);
+               submit('RESET', _("Cancel"), true, $title, $async);
+       }
 }
 
 function submit_add_or_update_center($add=true, $title=false, $async=false)