3 //---------------------------------------------------------------------------------
5 function start_form($multi=false, $sid=false, $action="", $name="")
8 $name = "name='$name'";
10 $action = $_SERVER['PHP_SELF'];
13 if (strpos($action, "?"))
19 echo "<form enctype='multipart/form-data' method='post' action='$action' $name>\n";
21 echo "<form method='post' action='$action' $name>\n";
25 //---------------------------------------------------------------------------------
27 function end_form($breaks=0)
31 echo "<input type=\"hidden\" name=\"_focus\" value=\"".get_post('_focus')."\">\n";
35 function start_table($extra="", $padding='2', $spacing='0')
37 echo "<center><table";
40 echo " cellpadding=$padding cellspacing=$spacing>\n";
43 function end_table($breaks=0)
45 echo "</table></center>\n";
50 function meta_forward($forward_to, $params="")
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?$params'>" . _("click here") . "</a> " . _("to continue") . ".<br><br></center>\n";
56 if ($params !='') $params = '?'.$params;
57 $Ajax->redirect($forward_to.$params);
61 //-----------------------------------------------------------------------------------
62 // Find and replace hotkey marker.
63 // if $clean == true marker is removed and clean label is returned
64 // (for use in wiki help system), otherwise result is array of label
65 // with underlined hotkey letter and access property string.
67 function access_string($label, $clean=false)
72 if (preg_match('/(.*)&([a-zA-Z0-9])(.*)/', $label, $slices))
74 $label = $clean ? $slices[1].$slices[2].$slices[3] :
75 $slices[1].'<u>'.$slices[2].'</u>'.$slices[3];
76 $access = " accesskey='".strtoupper($slices[2])."'";
79 $label = str_replace( '&&', '&', $label);
81 return $clean ? $label : array($label, $access);
84 function hyperlink_back($center=true)
88 //echo "<a href='javascript:goBack();'>"._("Back")."</a>\n";
89 echo "<p><a href='javascript:goBack();'>"._("Back")."</a></p>\n";
95 function hyperlink_no_params($target, $label, $center=true)
97 $pars = access_string($label);
100 echo "<a href='$target?=" . SID . "'$pars[1]>$pars[0]</a>\n";
105 function hyperlink_no_params_td($target, $label)
108 hyperlink_no_params($target, $label);
112 //-----------------------------------------------------------------------------------
114 function hyperlink_params($target, $label, $params, $center=true)
116 $pars = access_string($label);
119 echo "<a href='$target?$params'$pars[1]>$pars[0]</a>\n";
124 function hyperlink_params_td($target, $label, $params)
127 hyperlink_params($target, $label, $params, false);
131 //-----------------------------------------------------------------------------------
133 function hyperlink_params_separate($target, $label, $params, $center=false)
135 $pars = access_string($label);
138 echo "<a target='_blank' href='$target?$params" . SID . "'$pars[1]>$pars[0]</a>\n";
143 function hyperlink_params_separate_td($target, $label, $params)
146 hyperlink_params_separate($target, $label, $params);
150 //--------------------------------------------------------------------------------------------------
152 function alt_table_row_color(&$k)
156 echo "<tr class='oddrow'>\n";
161 echo "<tr class='evenrow'>\n";
166 function table_section_title($msg)
168 echo "<tr><td colspan=2 class='tableheader'>$msg</td><tr>\n";
171 function table_header($labels)
174 foreach ($labels as $label)
175 labelheader_cell($label);
179 function edit_link_cell($param, $title=false)
181 label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'"
182 .($title ? " title='$title'":'').">" . _("Edit") . "</a>", "nowrap");
185 function delete_link_cell($param, $title=false)
187 label_cell("<a href='" . $_SERVER['PHP_SELF']. "?" . "$param'"
188 .($title ? " title='$title'":'') .">" . _("Delete") . "</a>", "nowrap");
191 function edit_button($name, $value, $title=false)
193 // php silently changes dots,spaces,'[' and characters 128-159
194 // to underscore in POST names, to maintain compatibility with register_globals
195 echo "<input type=\"submit\" class=\"editbutton\" name=\""
196 .htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
197 ."\" value=\"$value\""
198 .($title ? " title='$title'":'')." />\n";
201 function edit_button_cell($name, $value, $title=false)
204 edit_button($name, $value, $title);
208 //-----------------------------------------------------------------------------------
210 function start_row($param="")
213 echo "<tr $param>\n";
225 for ($i = 0; $i < $num; $i++)
229 $ajax_divs = array();
231 function div_start($id='', $trigger=null, $non_ajax=false)
235 if ($non_ajax) { // div for non-ajax elements
236 array_push($ajax_divs, array($id, null));
237 echo "<div style='display:none' class='js_only' ".($id !='' ? "id='$id'" : '').">";
238 } else { // ajax ready div
239 array_push($ajax_divs, array($id, $trigger===null ? $id : $trigger));
240 echo "<div ". ($id !='' ? "id='$id'" : '').">";
247 global $ajax_divs, $Ajax;
249 if (count($ajax_divs))
251 $div = array_pop($ajax_divs);
252 if ($div[1] !== null)
253 $Ajax->addUpdate($div[1], $div[0], ob_get_flush());
259 External page call with saving current context.
260 $call - url of external page
261 $ctx - optional. name of SESSION context object or array of names of POST
262 variables saved on call
264 function context_call($call, $ctx='')
268 foreach($ctx as $postname)
270 $context[$postname] = get_post($postname);
273 $context = isset($_SESSION[$ctx]) ? $_SESSION[$ctx] : null;
275 array_unshift($_SESSION['Context'], array('name' => $ctx,
277 'caller' => $_SERVER['PHP_SELF'],
282 Restores context after external page call and
283 returns array of data passed by external page.
285 function context_restore()
287 if ( count($_SESSION['Context'])) {
288 if ($_SERVER['PHP_SELF'] == $_SESSION['Context'][0]['caller']) {
289 $ctx = array_shift($_SESSION['Context']);
291 if (is_array($ctx['ctx'])) {
292 foreach($ctx['ctx'] as $name => $val)
294 $_POST[$name] = $val;
297 if ($ctx['name']!='')
298 $_SESSION[$ctx['name']] = $ctx['ctx'];
307 Return to caller page if the page was called from external context.
309 function context_return($ret)
311 if ( count($_SESSION['Context'])) {
312 $ctx = &$_SESSION['Context'][0];
314 meta_forward( $ctx['caller'] );
318 Clearing context stack after page cancel.
320 function context_reset()
322 $_SESSION['Context'] = array();
326 Context stack initialization
328 if (!isset($_SESSION['Context'])) {