A lot of annoying layout bugs taken. Mostly from views and inquiries.
[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     global $Ajax;
53         echo "<meta http-equiv='Refresh' content='0; url=$forward_to?$params'>\n";
54         echo "<center><br>" . _("You should automatically be forwarded.");
55         echo " " . _("If this does not happen") . " " . "<a href='$forward_to'>" . _("click here") . "</a> " . _("to continue") . ".<br><br></center>\n";
56         $Ajax->redirect($forward_to.'?'.$params);
57         exit;
58 }
59
60 //-----------------------------------------------------------------------------------
61
62 function hyperlink_back($center=true)
63 {
64         if ($center)
65                 echo "<center>";
66         //echo "<a href='javascript:goBack();'>"._("Back")."</a>\n";
67         echo "<p><a href='javascript:goBack();'>"._("Back")."</a></p>\n";
68         if ($center)
69                 echo "</center>";
70         echo "<br>";
71 }
72
73 function hyperlink_no_params($target, $label, $center=true)
74 {
75         if ($center)
76                 echo "<br><center>";
77         echo "<a href='$target?=" . SID . "'>$label</a>\n";
78         if ($center)
79                 echo "</center>";
80 }
81
82 function hyperlink_no_params_td($target, $label)
83 {
84         echo "<td>";
85         hyperlink_no_params($target, $label);
86         echo "</td>\n";
87 }
88
89 //-----------------------------------------------------------------------------------
90
91 function hyperlink_params($target, $label, $params, $center=true)
92 {
93         if ($center)
94                 echo "<br><center>";
95         echo "<a href='$target?$params'>$label</a>\n";
96         if ($center)
97                 echo "</center>";
98 }
99
100 function hyperlink_params_td($target, $label, $params)
101 {
102         echo "<td>";
103         hyperlink_params($target, $label, $params);
104         echo "</td>\n";
105 }
106
107 //-----------------------------------------------------------------------------------
108
109 function hyperlink_params_separate($target, $label, $params, $center=false)
110 {
111         if ($center)
112                 echo "<br><center>";
113         echo "<a target='_blank' href='$target?$params" . SID . "'>$label</a>\n";
114         if ($center)
115                 echo "</center>";
116 }
117
118 function hyperlink_params_separate_td($target, $label, $params)
119 {
120         echo "<td>";
121         hyperlink_params_separate($target, $label, $params);
122         echo "</td>\n";
123 }
124
125 //--------------------------------------------------------------------------------------------------
126
127 function alt_table_row_color(&$k)
128 {
129         if ($k == 1)
130         {
131                 echo "<tr class='oddrow'>\n";
132                 $k = 0;
133         }
134         else
135         {
136                 echo "<tr class='evenrow'>\n";
137                 $k++;
138         }
139 }
140
141 function table_section_title($msg)
142 {
143         echo "<tr><td colspan=2 class='tableheader'>$msg</td><tr>\n";
144 }
145
146 function table_header($labels)
147 {
148         start_row();
149         foreach ($labels as $label)
150                 labelheader_cell($label);
151         end_row();
152 }
153
154 function edit_link_cell($param)
155 {
156         label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'>" . _("Edit") . "</a>", "nowrap");
157 }
158
159 function delete_link_cell($param)
160 {
161         label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'>" . _("Delete") . "</a>", "nowrap");
162 }
163
164 function edit_button_cell($name, $value)
165 {
166     label_cell("<input type=\"submit\" class=\"editbutton\" name=\"$name\" value=\"$value\" />\n");
167 }
168
169 //-----------------------------------------------------------------------------------
170
171 function start_row($param="")
172 {
173         if ($param != "")
174                 echo "<tr $param>\n";
175         else
176                 echo "<tr>\n";
177 }
178
179 function end_row()
180 {
181         echo "</tr>\n";
182 }
183
184 function br($num=1)
185 {
186         for ($i = 0; $i < $num; $i++)
187                 echo "<br>";
188 }
189
190 $ajax_divs = array();
191
192 function div_start($id='')
193 {
194     global $ajax_divs;
195
196     array_push($ajax_divs, $id);
197     echo "<div ". ($id !='' ? "id='$id'" : '').">";
198     ob_start();
199 }
200
201 function div_end()
202 {
203     global $ajax_divs, $Ajax;
204
205     if (count($ajax_divs))
206     {
207                 $id = array_pop($ajax_divs);
208                 $Ajax->addUpdate($id, $id, ob_get_flush());
209                 echo "</div>";
210     }
211 }
212 ?>