Fixed layout of hyperlink_params_td()
[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, false);
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, $title=false)
155 {
156     label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'"
157         .($title ? " title='$title'":'').">" . _("Edit") . "</a>", "nowrap");
158 }
159
160 function delete_link_cell($param, $title=false)
161 {
162     label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'"
163         .($title ? " title='$title'":'') .">" . _("Delete") . "</a>", "nowrap");
164 }
165
166 function edit_button_cell($name, $value, $title=false)
167 {
168     label_cell("<input type=\"submit\" class=\"editbutton\" name=\"$name\" value=\"$value\""
169         .($title ? " title='$title'":'')." />\n");
170 }
171
172 //-----------------------------------------------------------------------------------
173
174 function start_row($param="")
175 {
176         if ($param != "")
177                 echo "<tr $param>\n";
178         else
179                 echo "<tr>\n";
180 }
181
182 function end_row()
183 {
184         echo "</tr>\n";
185 }
186
187 function br($num=1)
188 {
189         for ($i = 0; $i < $num; $i++)
190                 echo "<br>";
191 }
192
193 $ajax_divs = array();
194
195 function div_start($id='', $trigger=null)
196 {
197     global $ajax_divs;
198
199     array_push($ajax_divs, array($id, $trigger===null ? $id : $trigger));
200     echo "<div ". ($id !='' ? "id='$id'" : '').">";
201     ob_start();
202 }
203
204 function div_end()
205 {
206     global $ajax_divs, $Ajax;
207
208     if (count($ajax_divs))
209     {
210                 $div = array_pop($ajax_divs);
211                 $Ajax->addUpdate($div[1], $div[0], ob_get_flush());
212                 echo "</div>";
213     }
214 }
215 ?>