X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fui%2Fui_input.inc;h=aa57475ccd8d474ec2d602140e285a6b259c283e;hb=9a1b3abd5371ad7f6315db1d56f8356587444314;hp=b27f5fde11ae787a486fc4fa73ecce2556dca591;hpb=9478a0cdeaf9201d2f3947e11e58d90354050025;p=fa-stable.git
diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc
index b27f5fde..aa57475c 100644
--- a/includes/ui/ui_input.inc
+++ b/includes/ui/ui_input.inc
@@ -37,6 +37,15 @@ function find_submit($prefix, $numeric=true)
}
return $numeric ? -1 : null;
}
+/*
+ Helper function.
+ Returns true if input $name with $submit_on_change option set is subject to update.
+*/
+function input_changed($name)
+{
+ return isset($_POST['_'.$name.'_changed']);
+}
+
//------------------------------------------------------------------------------
//
// Helper function for simple db table editor pages
@@ -84,10 +93,16 @@ function input_num($postname=null, $dflt=0)
}
//---------------------------------------------------------------------------------
+//
+// Thanks to hidden fields buffering hidden() helper can be used in arbitrary places and
+// proper html structure is still preserved. Buffered hidden fields are output on the nearest
+// table or form closing tag (see output_hidden()).
+//
+$hidden_fields = array();
function hidden($name, $value=null, $echo=true)
{
- global $Ajax;
+ global $Ajax, $hidden_fields;
if ($value === null)
$value = get_post($name);
@@ -95,7 +110,7 @@ function hidden($name, $value=null, $echo=true)
$ret = "";
$Ajax->addUpdate($name, $name, $value);
if ($echo)
- echo $ret."\n";
+ $hidden_fields[] = $ret;
else
return $ret;
}
@@ -107,35 +122,47 @@ function hidden($name, $value=null, $echo=true)
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
'selector' - ditto with closing current popup editor window
'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL
+ 'process' - displays progress bar during call; optional icon
+ 'nonajax' - ditto, non-ajax submit
+
+ $atype can contain also multiply type selectors separated by space,
+ however make sense only combination of 'process' and one of defualt/selector/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 'selector':
- $aspect = " aspect='selector' rel = '$value'";
- $value = _("Select");
- if ($icon===false) $icon=ICON_SUBMIT; 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;
- }
+ if ($atype === null) {
+ $aspect = fallback_mode() ? " aspect='fallback'" : " style='display:none;'";
+
+ } elseif (!is_bool($atype)) { // necessary: switch uses '=='
+ $aspect = " aspect='$atype' ";
+ $types = explode(' ', $atype);
+
+ foreach ($types as $type) {
+ switch($type) {
+ case 'selector':
+ $aspect = " aspect='selector' rel = '$value'";
+ $value = _("Select");
+ if ($icon===false) $icon=ICON_SUBMIT; break;
+
+ case 'default':
+ if ($icon===false) $icon=ICON_SUBMIT; break;
+
+ case 'cancel':
+ if ($icon===false) $icon=ICON_ESCAPE; break;
+
+ case 'nonajax':
+ $atype = false;
+ }
+ }
+ }
$submit_str = "\n";
if ($echo)
@@ -175,6 +202,7 @@ function submit_center_last($name, $value, $title=false, $async=false, $icon=fal
/*
For following controls:
'both' - use both Ctrl-Enter and Escape hotkeys
+ 'upgrade' - use Ctrl-Enter with progress ajax indicator and Escape hotkeys. Nonajax request for OK option is performed.
'cancel' - apply to 'RESET' button
*/
function submit_add_or_update($add=true, $title=false, $async=false, $clone=false)
@@ -183,7 +211,10 @@ function submit_add_or_update($add=true, $title=false, $async=false, $clone=fals
if ($async === 'both') {
$async = 'default'; $cancel = 'cancel';
- }
+ }
+ elseif ($async === 'upgrade') {
+ $async = 'default nonajax process'; $cancel = 'cancel';
+ }
else if ($async === 'default')
$cancel = true;
else if ($async === 'cancel')
@@ -239,17 +270,24 @@ function submit_return($name, $value, $title=false)
}
}
-function submit_js_confirm($name, $msg) {
- add_js_source(
- "_validate.$name=function(){ return confirm('"
- . strtr($msg, array("\n"=>'\\n')) . "');};");
-};
+function submit_js_confirm($name, $msg, $set = true) {
+ global $Ajax;
+ $js = "_validate.$name=".($set ? "function(){ return confirm('"
+ . strtr($msg, array("\n"=>'\\n')) . "');};"
+ : 'null;');
+ if (in_ajax()) {
+ $Ajax->addScript(true, $js);
+ } else
+ add_js_source($js);
+}
//-----------------------------------------------------------------------------------
function set_icon($icon, $title=false)
{
global $path_to_root;
- return "\n";
+ if (basename($icon) === $icon) // standard icons does not contain path separator
+ $icon = "$path_to_root/themes/".user_theme()."/images/$icon";
+ return "\n";
}
function button($name, $value, $title=false, $icon=false, $aspect='')
@@ -265,21 +303,23 @@ function button($name, $value, $title=false, $icon=false, $aspect='')
{
if ($value == _("Delete")) // Helper during implementation
$icon = ICON_DELETE;
- return "