Automatic first field focus on page start, preserved focus sequence
[fa-stable.git] / includes / ui / ui_controls.inc
1 <?php
2
3 //---------------------------------------------------------------------------------
4
5 function start_form($multi=false, $sid=false, $action="", $name="")
6 {
7         if ($name != "")
8                 $name = "name='$name'";
9         if ($action == "")
10                 $action = $_SERVER['PHP_SELF'];
11         if ($sid)
12         {
13                 if (strpos($action, "?"))
14                         $action .= "&" . SID;
15                 else    
16                         $action .= "?" . SID;
17         }               
18         if ($multi)
19                 echo "<form enctype='multipart/form-data' method='post' action='$action' $name>\n";     
20         else
21                 echo "<form method='post' action='$action' $name>\n";   
22
23 }
24
25 //---------------------------------------------------------------------------------
26
27 function end_form($breaks=0)
28 {
29         if ($breaks)
30                 br($breaks);
31         echo "<input type=\"hidden\" name=\"_focus\" value=\"".$_POST['_focus']."\">\n";
32         echo "</form>\n";
33 }
34
35 function start_table($extra="", $padding='2', $spacing='0')
36 {
37         echo "<center><table";
38         if ($extra != "")
39                 echo " $extra";
40         echo " cellpadding=$padding cellspacing=$spacing>\n";
41 }       
42
43 function end_table($breaks=0)
44 {
45         echo "</table></center>\n";
46         if ($breaks)
47                 br($breaks);
48 }
49
50 function meta_forward($forward_to, $params="")
51 {
52         echo "<meta http-equiv='Refresh' content='0; url=$forward_to?$params'>\n";
53         echo "<center><br>" . _("You should automatically be forwarded.");
54         echo " " . _("If this does not happen") . " " . "<a href='$forward_to'>" . _("click here") . "</a> " . _("to continue") . ".<br><br>\n";
55         exit;
56 }
57
58 //-----------------------------------------------------------------------------------
59
60 function hyperlink_back($center=true)
61 {
62         echo  get_js_go_back();
63
64         if ($center)
65                 echo "<center>";
66         echo "<a href='javascript:goBack();'>"._("Back")."</a>\n";
67         if ($center)
68                 echo "</center>";
69         echo "<br>";    
70 }
71
72 function hyperlink_no_params($target, $label, $center=true)
73 {
74         if ($center)
75                 echo "<br><center>";
76         echo "<a href='$target?=" . SID . "'>$label</a>\n";
77         if ($center)
78                 echo "</center>";
79 }
80
81 function hyperlink_no_params_td($target, $label)
82 {
83         echo "<td>";
84         hyperlink_no_params($target, $label);
85         echo "</td>\n";
86 }
87
88 //-----------------------------------------------------------------------------------
89
90 function hyperlink_params($target, $label, $params, $center=true)
91 {
92         if ($center)
93                 echo "<br><center>";
94         echo "<a href='$target?$params'>$label</a>\n";
95         if ($center)
96                 echo "</center>";
97 }
98
99 function hyperlink_params_td($target, $label, $params)
100 {
101         echo "<td>";
102         hyperlink_params($target, $label, $params);
103         echo "</td>\n";
104 }
105
106 //-----------------------------------------------------------------------------------
107
108 function hyperlink_params_separate($target, $label, $params, $center=false)
109 {
110         if ($center)
111                 echo "<br><center>";
112         echo "<a target='_blank' href='$target?$params" . SID . "'>$label</a>\n";
113         if ($center)
114                 echo "</center>";
115 }
116
117 function hyperlink_params_separate_td($target, $label, $params)
118 {
119         echo "<td>";
120         hyperlink_params_separate($target, $label, $params);
121         echo "</td>\n";
122 }
123
124 //--------------------------------------------------------------------------------------------------
125
126 function alt_table_row_color(&$k)
127 {
128         if ($k == 1)
129         {
130                 echo "<tr class='oddrow'>\n";
131                 $k = 0;
132         } 
133         else 
134         {
135                 echo "<tr class='evenrow'>\n";
136                 $k++;
137         }
138 }
139
140 function table_section_title($msg) 
141 {
142         echo "<tr><td colspan=2 class='tableheader'>$msg</td><tr>\n";
143 }
144
145 function table_header($labels) 
146 {
147         start_row();
148         foreach ($labels as $label)
149                 labelheader_cell($label);
150         end_row();      
151 }
152
153 function edit_link_cell($param) 
154 {
155         label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'>" . _("Edit") . "</a>", "nowrap");
156 }
157
158 function delete_link_cell($param)
159 {
160         label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'>" . _("Delete") . "</a>", "nowrap");
161 }
162
163 function edit_button_cell($name, $value)
164 {
165     label_cell("<input type=\"submit\" class=\"editbutton\" name=\"$name\" value=\"$value\" />\n");
166 }
167
168 //-----------------------------------------------------------------------------------
169
170 function start_row($param="") 
171 {
172         if ($param != "")
173                 echo "<tr $param>\n";
174         else    
175                 echo "<tr>\n";
176 }
177
178 function end_row() 
179 {
180         echo "</tr>\n";
181 }       
182
183 function br($num=1)
184 {
185         for ($i = 0; $i < $num; $i++)
186                 echo "<br>";
187 }               
188 ?>