Added explicit ob_end_flush on shutdown for php 5
[fa-stable.git] / includes / ui / ui_controls.inc
index 8e815e73473415518e422cf686fca027e91a47f5..ad0c8a2468e65e787d7c96bfdbe64a615abdcb54 100644 (file)
@@ -19,6 +19,7 @@ function start_form($multi=false, $sid=false, $action="", $name="")
                echo "<form enctype='multipart/form-data' method='post' action='$action' $name>\n";     
        else
                echo "<form method='post' action='$action' $name>\n";   
+
 }
 
 //---------------------------------------------------------------------------------
@@ -27,6 +28,7 @@ function end_form($breaks=0)
 {
        if ($breaks)
                br($breaks);
+       echo "<input type=\"hidden\" name=\"_focus\" value=\"".$_POST['_focus']."\">\n";
        echo "</form>\n";
 }
 
@@ -47,9 +49,11 @@ function end_table($breaks=0)
 
 function meta_forward($forward_to, $params="")
 {
+    global $Ajax;
        echo "<meta http-equiv='Refresh' content='0; url=$forward_to?$params'>\n";
        echo "<center><br>" . _("You should automatically be forwarded.");
        echo " " . _("If this does not happen") . " " . "<a href='$forward_to'>" . _("click here") . "</a> " . _("to continue") . ".<br><br>\n";
+       $Ajax->redirect($forward_to.'?'.$params);
        exit;
 }
 
@@ -57,8 +61,6 @@ function meta_forward($forward_to, $params="")
 
 function hyperlink_back($center=true)
 {
-       echo  get_js_go_back();
-
        if ($center)
                echo "<center>";
        echo "<a href='javascript:goBack();'>"._("Back")."</a>\n";
@@ -103,9 +105,13 @@ function hyperlink_params_td($target, $label, $params)
 
 //-----------------------------------------------------------------------------------
 
-function hyperlink_params_separate($target, $label, $params)
+function hyperlink_params_separate($target, $label, $params, $center=false)
 {
+       if ($center)
+               echo "<br><center>";
        echo "<a target='_blank' href='$target?$params" . SID . "'>$label</a>\n";
+       if ($center)
+               echo "</center>";
 }
 
 function hyperlink_params_separate_td($target, $label, $params)
@@ -154,6 +160,11 @@ function delete_link_cell($param)
        label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'>" . _("Delete") . "</a>", "nowrap");
 }
 
+function edit_button_cell($name, $value)
+{
+    label_cell("<input type=\"submit\" class=\"editbutton\" name=\"$name\" value=\"$value\" />\n");
+}
+
 //-----------------------------------------------------------------------------------
 
 function start_row($param="") 
@@ -173,5 +184,27 @@ function br($num=1)
 {
        for ($i = 0; $i < $num; $i++)
                echo "<br>";
-}              
+}
+
+$ajax_divs = array();
+
+function div_start($id='')
+{
+    global $ajax_divs;
+
+    array_push($ajax_divs, $id);
+    echo "<div ". ($id !='' ? "id='$id'" : '').">";
+    ob_start();
+}
+
+function div_end()
+{
+    global $ajax_divs, $Ajax;
+
+    if (count($ajax_divs)) {
+       $id = array_pop($ajax_divs);
+       $Ajax->addUpdate($id, $id, ob_get_flush());
+       echo "</div>"; 
+    }
+}
 ?>
\ No newline at end of file