3 // SourceForge: Breaking Down the Barriers to Open Source Development
4 // Copyright 1999-2000 (c) The SourceForge Crew
5 // http://sourceforge.net
9 // require("exit.php");
11 function html_feedback_top($feedback) {
15 <H3><FONT COLOR="RED">'.$feedback.'</FONT></H3>';
18 function html_feedback_bottom($feedback) {
22 <H3><FONT COLOR="RED">'.$feedback.'</FONT></H3>';
25 function html_a_group($grp) {
26 print '<A /project/?group_id='.$grp.'>' . group_getname($grp) . '</A>';
29 function html_blankimage($height,$width) {
30 return '<img src="/images/blank.gif" width="' . $width . '" height="' . $height . '" alt="">';
33 function html_dbimage($id) {
37 $sql="SELECT width,height ".
38 "FROM db_images WHERE id='$id'";
39 $result=db_query($sql);
40 $rows=db_numrows($result);
42 if (!$result || $rows < 1) {
45 return html_image('/dbimage.php?id='.$id,db_result($result,0,'width'),db_result($result,0,'height'),array());
49 function html_image($src,$width,$height,$args,$display=1) {
50 global $sys_images_url;
51 $return = ('<IMG src="' . $sys_images_url . $src .'"');
53 while(list($k,$v) = each($args)) {
54 $return .= ' '.$k.'="'.$v.'"';
57 // ## insert a border tag if there isn't one
58 if (!$args['border']) $return .= (" border=0");
60 // ## add image dimensions
61 $return .= " width=" . $width;
62 $return .= " height=" . $height;
72 Pop up box of supported languages
80 function html_get_language_popup ($Language,$title='language_id',$selected='xzxzxz') {
81 $res=$Language->getLanguages();
82 return html_build_select_box ($res,$title,$selected,false);
89 Pop up box of supported Timezones
91 Assumes you have included Timezones array file
100 function html_get_timezone_popup ($title='timezone',$selected='xzxzxzx') {
102 if ($selected == 'xzxzxzx') {
103 $r = file ('/etc/timezone');
104 $selected = str_replace ("\n", '', $r[0]);
106 return html_build_select_box_from_arrays ($TZs,$TZs,$title,$selected,false);
109 function html_build_list_table_top ($title_arr,$links_arr=false) {
111 Takes an array of titles and builds
112 The first row of a new table
114 Optionally takes a second array of links for the titles
119 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="1" CELLPADDING="2">
120 <TR BGCOLOR="'. $HTML->COLOR_HTMLBOX_TITLE .'">';
122 $count=count($title_arr);
124 for ($i=0; $i<$count; $i++) {
126 <TD ALIGN="MIDDLE"><a class=sortbutton href="'.$links_arr[$i].'"><FONT COLOR="'.
127 $HTML->FONTCOLOR_HTMLBOX_TITLE.'"><B>'.$title_arr[$i].'</B></FONT></A></TD>';
130 for ($i=0; $i<$count; $i++) {
132 <TD ALIGN="MIDDLE"><FONT COLOR="'.
133 $HTML->FONTCOLOR_HTMLBOX_TITLE.'"><B>'.$title_arr[$i].'</B></FONT></TD>';
136 return $return.'</TR>';
139 function html_get_alt_row_color ($i) {
144 return $HTML->COLOR_LTBACK1;
148 function html_build_select_box_from_array ($vals,$select_name,$checked_val='xzxz',$samevals = 0) {
150 Takes one array, with the first array being the "id" or value
151 and the array being the text you want displayed
153 The second parameter is the name you want assigned to this form element
155 The third parameter is optional. Pass the value of the item that should be checked
159 <SELECT NAME="'.$select_name.'">';
163 for ($i=0; $i<$rows; $i++) {
165 $return .= "\n\t\t<OPTION VALUE=\"" . $vals[$i] . "\"";
166 if ($vals[$i] == $checked_val) {
167 $return .= ' SELECTED';
170 $return .= "\n\t\t<OPTION VALUE=\"" . $i .'"';
171 if ($i == $checked_val) {
172 $return .= ' SELECTED';
175 $return .= '>'.$vals[$i].'</OPTION>';
183 function html_build_select_box_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='None') {
186 The infamous '100 row' has to do with the
187 SQL Table joins done throughout all this code.
188 There must be a related row in users, categories, et , and by default that
189 row is 100, so almost every pop-up box has 100 as the default
190 Most tables in the database should therefore have a row with an id of 100 in it
191 so that joins are successful
195 Takes two arrays, with the first array being the "id" or value
196 and the other array being the text you want displayed
198 The third parameter is the name you want assigned to this form element
200 The fourth parameter is optional. Pass the value of the item that should be checked
202 The fifth parameter is an optional boolean - whether or not to show the '100 row'
204 The sixth parameter is optional - what to call the '100 row' defaults to none
208 <SELECT NAME="'.$select_name.'">';
210 //we don't always want the default 100 row shown
213 <OPTION VALUE="100">'. $text_100 .'</OPTION>';
217 if (count($texts) != $rows) {
218 $return .= 'ERROR - uneven row counts';
221 for ($i=0; $i<$rows; $i++) {
222 // uggh - sorry - don't show the 100 row
223 // if it was shown above, otherwise do show it
224 if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
226 <OPTION VALUE="'.$vals[$i].'"';
227 if ($vals[$i] == $checked_val) {
228 $return .= ' SELECTED';
230 $return .= '>'.$texts[$i].'</OPTION>';
238 function html_build_select_box ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='None') {
240 Takes a result set, with the first column being the "id" or value
241 and the second column being the text you want displayed
243 The second parameter is the name you want assigned to this form element
245 The third parameter is optional. Pass the value of the item that should be checked
247 The fourth parameter is an optional boolean - whether or not to show the '100 row'
249 The fifth parameter is optional - what to call the '100 row' defaults to none
252 return html_build_select_box_from_arrays (util_result_column_to_array($result,0),util_result_column_to_array($result,1),$name,$checked_val,$show_100,$text_100);
255 function html_build_multiple_select_box ($result,$name,$checked_array,$size='8') {
257 Takes a result set, with the first column being the "id" or value
258 and the second column being the text you want displayed
260 The second parameter is the name you want assigned to this form element
262 The third parameter is an array of checked values;
264 The fourth parameter is optional. Pass the size of this box
267 $checked_count=count($checked_array);
268 // echo '-- '.$checked_count.' --';
270 <SELECT NAME="'.$name.'" MULTIPLE SIZE="'.$size.'">';
272 Put in the default NONE box
275 <OPTION VALUE="100"';
276 for ($j=0; $j<$checked_count; $j++) {
277 if ($checked_array[$j] == '100') {
278 $return .= ' SELECTED';
281 $return .= '>None</OPTION>';
283 $rows=db_numrows($result);
285 for ($i=0; $i<$rows; $i++) {
286 if (db_result($result,$i,0) != '100') {
288 <OPTION VALUE="'.db_result($result,$i,0).'"';
290 Determine if it's checked
292 $val=db_result($result,$i,0);
293 for ($j=0; $j<$checked_count; $j++) {
294 if ($val == $checked_array[$j]) {
295 $return .= ' SELECTED';
298 $return .= '>'.$val.'-'. substr(db_result($result,$i,1),0,35). '</OPTION>';
306 function html_buildpriority_select_box ($name='priority', $checked_val='5') {
308 Return a select box of standard priorities.
309 The name of this select box is optional and so is the default checked value
312 <SELECT NAME="<?php echo $name; ?>">
313 <OPTION VALUE="1"<?php if ($checked_val=="1") {echo " SELECTED";} ?>>1 - Lowest</OPTION>
314 <OPTION VALUE="2"<?php if ($checked_val=="2") {echo " SELECTED";} ?>>2</OPTION>
315 <OPTION VALUE="3"<?php if ($checked_val=="3") {echo " SELECTED";} ?>>3</OPTION>
316 <OPTION VALUE="4"<?php if ($checked_val=="4") {echo " SELECTED";} ?>>4</OPTION>
317 <OPTION VALUE="5"<?php if ($checked_val=="5") {echo " SELECTED";} ?>>5 - Medium</OPTION>
318 <OPTION VALUE="6"<?php if ($checked_val=="6") {echo " SELECTED";} ?>>6</OPTION>
319 <OPTION VALUE="7"<?php if ($checked_val=="7") {echo " SELECTED";} ?>>7</OPTION>
320 <OPTION VALUE="8"<?php if ($checked_val=="8") {echo " SELECTED";} ?>>8</OPTION>
321 <OPTION VALUE="9"<?php if ($checked_val=="9") {echo " SELECTED";} ?>>9 - Highest</OPTION>
327 function html_buildcheckboxarray($options,$name,$checked_array) {
328 $option_count=count($options);
329 $checked_count=count($checked_array);
331 for ($i=1; $i<=$option_count; $i++) {
333 <BR><INPUT type="checkbox" name="'.$name.'" value="'.$i.'"';
334 for ($j=0; $j<$checked_count; $j++) {
335 if ($i == $checked_array[$j]) {
339 echo '> '.$options[$i];
343 /*! @function site_user_header
344 @abstract everything required to handle security and
345 add navigation for user pages like /my/ and /account/
346 @param params array() must contain $user_id
347 @result text - echos HTML to the screen directly
349 function site_header($params) { GLOBAL $HTML;
352 Check to see if active user
353 Check to see if logged in
355 echo $HTML->header($params);
356 echo html_feedback_top($GLOBALS['feedback']);
359 function site_footer($params) {
361 $HTML->footer($params);
364 /*! @function site_project_header
365 @abstract everything required to handle security and state checks for a project web page
366 @param params array() must contain $toptab and $group
367 @result text - echos HTML to the screen directly
369 function site_project_header($params) {
373 Check to see if active
374 Check to see if project rather than foundry
375 Check to see if private (if private check if user_ismember)
378 $group_id=$params['group'];
380 //get the project object
381 $project=&project_get_object($group_id);
383 if (!$project || $project->isError()) {
384 exit_error("Group Problem",$project->getErrorMessage());
388 if (!$project->isPublic()) {
389 //if it's a private group, you must be a member of that group
390 session_require(array('group'=>$group_id));
393 //for dead projects must be member of admin project
394 if (!$project->isActive()) {
395 //only SF group can view non-active, non-holding groups
396 session_require(array('group'=>'1'));
399 echo $HTML->header($params);
400 echo html_feedback_top($GLOBALS['feedback']);
401 echo $HTML->project_tabs($params['toptab'],$params['group']);
404 /*! @function site_project_footer
405 @abstract currently a simple shim that should be on every project page,
406 rather than a direct call to site_footer() or theme_footer()
407 @param params array() empty
408 @result text - echos HTML to the screen directly
410 function site_project_footer($params) {
413 echo html_feedback_bottom($GLOBALS['feedback']);
414 echo $HTML->footer($params);
417 /*! @function site_user_header
418 @abstract everything required to handle security and
419 add navigation for user pages like /my/ and /account/
420 @param params array() must contain $user_id
421 @result text - echos HTML to the screen directly
423 function site_user_header($params) {
427 Check to see if active user
428 Check to see if logged in
430 echo $HTML->header($params);
431 echo html_feedback_top($GLOBALS['feedback']);
434 <A HREF="/my/">My Personal Page</A> | <A HREF="/my/diary.php">Diary & Notes</A> | <A HREF="/account/">Account Options</A>
439 /*! @function site_user_footer
440 @abstract currently a simple shim that should be on every user page,
441 rather than a direct call to site_footer() or theme_footer()
442 @param params array() empty
443 @result text - echos HTML to the screen directly
445 function site_user_footer($params) {
448 echo html_feedback_bottom($GLOBALS['feedback']);
449 echo $HTML->footer($params);