X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=82279aeaa4dcbb5f12306c42519ab22e127fffee;hb=3bf71dd6f93ecac6b93fe98d23b247869cbeb720;hp=74437698b62b80c087a04067326027e07156d203;hpb=2cb1b4507d223a8f1b803f5909ab7271bc2b37a8;p=fa-stable.git diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index 74437698..82279aea 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -1,9 +1,14 @@ . +***********************************************************************/ // // Sets local POST value and adds Value to ajax posting if needed // @@ -53,7 +58,9 @@ function simple_page_mode($numeric_id = true) foreach (array('Edit', 'Delete') as $m) { foreach ($_POST as $p => $pvar) { if (strpos($p, $m) === 0) { - $selected_id = substr($p, strlen($m)); +// $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; @@ -67,10 +74,10 @@ function simple_page_mode($numeric_id = true) // // 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; + if (!isset($_POST[$postname]) || $_POST[$postname] == "") + return $dflt; return user_numeric($_POST[$postname]); } @@ -91,59 +98,97 @@ function hidden($name, $value=null, $echo=true) else return $ret; } - -//--------------------------------------------------------------------------------- -// Submit button. -// $async parameter can have 3 values: -// false - normal submit via form action -// true - when js is on submition via ajax call -// null - fallback button not visible in js enabled mode -// -function submit($name, $value, $echo=true, $title=false, $async=false) -{ +/* + Universal submit form button. + $atype - type of submit: + Normal submit: + false - normal button; optional icon + null - button visible only in fallback mode; optional icon + Ajax submit: + true - standard button; optional icon + 'process' - displays progress bar during call; optional icon + 'default' - default form submit on Ctrl-Enter press; dflt ICON_OK icon + 'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL +*/ +function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=false) +{ + global $path_to_root; + + $aspect=''; + if (!is_bool($atype)) // necessary: switch uses '==' + switch($atype) { + case 'process': + $aspect = " aspect='process'"; break; + case 'default': + $aspect = " aspect='default'"; + if ($icon===false) $icon=ICON_SUBMIT; break; + case 'cancel': + $aspect = " aspect='cancel'"; + if ($icon===false) $icon=ICON_ESCAPE; break; + case null: + $aspect = fallback_mode() ? + " aspect='fallback'" : " style='display:none;'"; break; + } default_focus($name); - $submit_str = "\n"; + .">" + .($icon ? "" : '') + ."$value" + ."\n"; if ($echo) echo $submit_str; else return $submit_str; } -function submit_center($name, $value, $echo=true, $title=false, $async=false) +function submit_center($name, $value, $echo=true, $title=false, $async=false, $icon=false) { echo "
"; - submit($name, $value, $echo, $title, $async); + submit($name, $value, $echo, $title, $async, $icon); echo "
"; } -function submit_center_first($name, $value, $title=false, $async=false) +function submit_center_first($name, $value, $title=false, $async=false, $icon=false) { echo "
"; - submit($name, $value, true, $title, $async); + submit($name, $value, true, $title, $async, $icon); echo " "; } -function submit_center_last($name, $value, $title=false, $async=false) +function submit_center_last($name, $value, $title=false, $async=false, $icon=false) { echo " "; - submit($name, $value, true, $title, $async); + submit($name, $value, true, $title, $async, $icon); echo "
"; } - +/* + For following controls: + 'both' - use both Ctrl-Enter and Escape hotkeys + 'cancel' - apply to 'RESET' button +*/ function submit_add_or_update($add=true, $title=false, $async=false) { + $cancel = $async; + + if ($async === 'both') { + $async = 'default'; $cancel = 'cancel'; + } + else if ($async === 'default') + $cancel = true; + else if ($async === 'cancel') + $async = true; + if ($add) submit('ADD_ITEM', _("Add new"), true, $title, $async); else { submit('UPDATE_ITEM', _("Update"), true, $title, $async); - submit('RESET', _("Cancel"), true, $title, $async); + submit('RESET', _("Cancel"), true, $title, $cancel); } } @@ -154,14 +199,6 @@ function submit_add_or_update_center($add=true, $title=false, $async=false) echo ""; } -/* -function submit_add_or_update_row($add=true) -{ - echo ""; - submit_add_or_update($add); - echo "\n"; -} -*/ function submit_add_or_update_row($add=true, $right=true, $extra="", $title=false, $async=false) { echo ""; @@ -187,23 +224,56 @@ function submit_row($name, $value, $right=true, $extra="", $title=false, $async= submit_cells($name, $value, $extra, $title, $async); echo "\n"; } -//--------------------------------------------------------------------------------- -function button($name, $value, $onclick, $title=false) +function submit_return($name, $value, $title=false, $async=false) { - default_focus($name); - echo "\n"; + if (count($_SESSION['Context'])) { + submit($name, $value, true, $title, $async); + } +} +//----------------------------------------------------------------------------------- + +function set_icon($icon, $title=false) +{ + global $path_to_root; + return "\n"; } -function button_cell($name, $value, $onclick, $title=false) +function button($name, $value, $title=false, $icon=false) +{ + // php silently changes dots,spaces,'[' and characters 128-159 + // to underscore in POST names, to maintain compatibility with register_globals + if (user_graphic_links() && $icon) + { + if ($value == _("Delete")) // Helper during implementation + $icon = ICON_DELETE; + return "