5 * SourceForge: Breaking Down the Barriers to Open Source Development
6 * Copyright 1999-2001 (c) VA Linux Systems
7 * http://sourceforge.net
13 * html_feedback_top() - Show the feedback output at the top of the page.
15 * @param string The feedback.
17 function html_feedback_top($feedback) {
21 <h3><span style="color:red">'.$feedback.'</span></h3>';
25 * make_user_link() - Make a username reference into a link to that users User page on SF.
27 * @param string The username of the user to link.
29 function make_user_link($username) {
30 if (!strcasecmp($username,'Nobody') || !strcasecmp($username,'None')) {
33 return '<a href="/users/'.$username.'">'.$username.'</a>' ;
38 * html_feedback_top() - Show the feedback output at the bottom of the page.
40 * @param string The feedback.
42 function html_feedback_bottom($feedback) {
46 <h3><span style="color:red">'.$feedback.'</span></h3>';
50 * html_blankimage() - Show the blank spacer image.
52 * @param int The height of the image
53 * @param int The width of the image
55 function html_blankimage($height,$width) {
56 return '<img src="/images/blank.png" width="' . $width . '" height="' . $height . '" alt="" />';
60 * html_dbimage() - Show an image that is stored in the database
62 * @param int The id of the image to show
64 function html_dbimage($id, $args=0) {
71 $sql="SELECT width,height,version ".
72 "FROM db_images WHERE id='$id'";
73 $result=db_query($sql);
74 $rows=db_numrows($result);
76 if (!$result || $rows < 1) {
79 return html_image('/dbimage.php?id='.$id.'&v='.db_result($result,0,'version'),db_result($result,0,'width'),db_result($result,0,'height'),$args);
84 * html_image() - Build an image tag of an image contained in $src
86 * @param string The source location of the image
87 * @param int The width of the image
88 * @param int The height of the image
89 * @param array Any IMG tag parameters associated with this image (i.e. 'border', 'alt', etc...)
90 * @param bool DEPRECATED
92 function html_image($src,$width,$height,$args,$display=1) {
93 global $sys_images_url,$sys_images_secure_url,$HTML;
94 $s = ((session_issecure()) ? $sys_images_secure_url : $sys_images_url );
95 $return = ('<img src="' . $s . $HTML->imgroot . $src .'"');
97 while(list($k,$v) = each($args)) {
98 $return .= ' '.$k.'="'.$v.'"';
101 // ## insert a border tag if there isn't one
102 if (!isset($args['border'])) {
103 $return .= ' border="0"';
106 if (!isset($args['alt'])) {
107 $return .= ' alt=""';
110 // ## add image dimensions
111 $return .= " width=\"" . $width . "\"";
112 $return .= " height=\"" . $height . "\"";
119 * html_get_language_popup() - Pop up box of supported languages
121 * @param object BaseLanguage object
122 * @param string The title of the popup box
123 * @param string Which element of the box is to be selected
125 function html_get_language_popup ($Language,$title='language_id',$selected='xzxzxz') {
126 $res=$Language->getLanguages();
127 return html_build_select_box ($res,$title,$selected,false);
131 * html_get_timezone_popup() - Pop up box of supported Timezones
132 * Assumes you have included Timezones array file
134 * @param string The title of the popup box
135 * @param string Which element of the box is to be selected
137 function html_get_timezone_popup ($title='timezone',$selected='xzxz') {
139 if ($selected == 'xzxzxzx') {
140 $r = file ('/etc/timezone');
141 $selected = str_replace ("\n", '', $r[0]);
143 return html_build_select_box_from_arrays ($TZs,$TZs,$title,$selected,false);
147 * html_build_select_box_from_array() - Takes one array, with the first array being the "id"
148 * or value and the array being the text you want displayed.
150 * @param string The name you want assigned to this form element
151 * @param string The value of the item that should be checked
153 function html_build_select_box_from_array ($vals,$select_name,$checked_val='xzxz',$samevals = 0) {
155 <select name="'.$select_name.'">';
159 for ($i=0; $i<$rows; $i++) {
161 $return .= "\n\t\t<option value=\"" . $vals[$i] . "\"";
162 if ($vals[$i] == $checked_val) {
163 $return .= ' selected="selected"';
166 $return .= "\n\t\t<option value=\"" . $i .'"';
167 if ($i == $checked_val) {
168 $return .= ' selected="selection"';
171 $return .= '>'.$vals[$i].'</option>';
180 * html_build_select_box_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other
181 * array being the text you want displayed.
183 * The infamous '100 row' has to do with the SQL Table joins done throughout all this code.
184 * There must be a related row in users, categories, et , and by default that
185 * row is 100, so almost every pop-up box has 100 as the default
186 * Most tables in the database should therefore have a row with an id of 100 in it so that joins are successful
188 * @param array The ID or value
189 * @param array Text to be displayed
190 * @param string Name to assign to this form element
191 * @param string The item that should be checked
192 * @param bool Whether or not to show the '100 row'
193 * @param string What to call the '100 row' defaults to none
195 function html_build_select_box_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='None') {
197 <select name="'.$select_name.'">';
199 //we don't always want the default 100 row shown
202 <option value="100">'. $text_100 .'</option>';
206 if (count($texts) != $rows) {
207 $return .= 'ERROR - uneven row counts';
210 for ($i=0; $i<$rows; $i++) {
211 // uggh - sorry - don't show the 100 row
212 // if it was shown above, otherwise do show it
213 if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) {
215 <option value="'.$vals[$i].'"';
216 if ($vals[$i] == $checked_val) {
218 $return .= ' selected="selected"';
220 $return .= '>'.$texts[$i].'</option>';
224 // If the passed in "checked value" was never "SELECTED"
225 // we want to preserve that value UNLESS that value was 'xzxz', the default value
227 if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) {
229 <option value="'.$checked_val.'" selected="selected">No Change</option>';
237 * html_build_select_box() - Takes a result set, with the first column being the "id" or value and
238 * the second column being the text you want displayed.
240 * @param int The result set
241 * @param string Text to be displayed
242 * @param string The item that should be checked
243 * @param bool Whether or not to show the '100 row'
244 * @param string What to call the '100 row'. Defaults to none.
246 function html_build_select_box ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='None') {
247 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);
250 * html_build_multiple_select_box() - Takes a result set, with the first column being the "id" or value
251 * and the second column being the text you want displayed.
253 * @param int The result set
254 * @param string Text to be displayed
255 * @param string The item that should be checked
256 * @param int The size of this box
257 * @param bool Whether or not to show the '100 row'
259 function html_build_multiple_select_box ($result,$name,$checked_array,$size='8',$show_100=true) {
260 $checked_count=count($checked_array);
262 <select name="'.$name.'" multiple="multiple" size="'.$size.'">';
265 Put in the default NONE box
268 <option value="100"';
269 for ($j=0; $j<$checked_count; $j++) {
270 if ($checked_array[$j] == '100') {
271 $return .= ' selected="selected"';
274 $return .= '>None</option>';
277 $rows=db_numrows($result);
279 for ($i=0; $i<$rows; $i++) {
280 if ((db_result($result,$i,0) != '100') || (db_result($result,$i,0) == '100' && !$show_100)) {
282 <option value="'.db_result($result,$i,0).'"';
284 Determine if it's checked
286 $val=db_result($result,$i,0);
287 for ($j=0; $j<$checked_count; $j++) {
288 if ($val == $checked_array[$j]) {
289 $return .= ' selected="selected"';
292 $return .= '>'.$val.'-'. substr(db_result($result,$i,1),0,35). '</option>';
301 * html_build_checkbox() - Render checkbox control
303 * @param name - name of control
304 * @param value - value of control
305 * @param checked - true if control should be checked
306 * @return html code for checkbox control
308 function html_build_checkbox($name, $value, $checked) {
309 return '<input type="checkbox" name="'.$name.'"'
310 .' value="'.$value.'"'
311 .($checked ? 'checked="checked"' : '').'>';
315 * html_get_priority_color() - Return the color value for the index that was passed in
316 * (defined in $sys_urlroot/themes/<selected theme>/theme.php)
320 function html_get_priority_color ($index) {
323 /* make sure that index is of appropriate type and range */
324 $index = (int)$index;
327 } else if ($index>9) {
330 //return "prior$index";
331 return $bgpri[$index];
335 * build_priority_select_box() - Wrapper for html_build_priority_select_box()
337 * @see html_build_priority_select_box()
339 function build_priority_select_box ($name='priority', $checked_val='5', $nochange=false) {
340 echo html_build_priority_select_box ($name, $checked_val, $nochange);
344 * html_build_priority_select_box() - Return a select box of standard priorities.
345 * The name of this select box is optional and so is the default checked value.
347 * @param string Name of the select box
348 * @param string The value to be checked
349 * @param bool Whether to make 'No Change' selected.
351 function html_build_priority_select_box ($name='priority', $checked_val='5', $nochange=false) {
353 <select name="<?php echo $name; ?>">
354 <?php if($nochange) { ?>
355 <option value="100"<?php if ($nochange) {echo " selected=\"selected\"";} ?>>No Change</option>
357 <option value="1"<?php if ($checked_val=="1") {echo " selected=\"selected\"";} ?>>1 - Lowest</option>
358 <option value="2"<?php if ($checked_val=="2") {echo " selected=\"selected\"";} ?>>2</option>
359 <option value="3"<?php if ($checked_val=="3") {echo " selected=\"selected\"";} ?>>3</option>
360 <option value="4"<?php if ($checked_val=="4") {echo " selected=\"selected\"";} ?>>4</option>
361 <option value="5"<?php if ($checked_val=="5") {echo " selected=\"selected\"";} ?>>5 - Medium</option>
362 <option value="6"<?php if ($checked_val=="6") {echo " selected=\"selected\"";} ?>>6</option>
363 <option value="7"<?php if ($checked_val=="7") {echo " selected=\"selected\"";} ?>>7</option>
364 <option value="8"<?php if ($checked_val=="8") {echo " selected=\"selected\"";} ?>>8</option>
365 <option value="9"<?php if ($checked_val=="9") {echo " selected=\"selected\"";} ?>>9 - Highest</option>
372 * html_buildcheckboxarray() - Build an HTML checkbox array.
374 * @param array Options array
375 * @param name Checkbox name
376 * @param array Array of boxes to be pre-checked
378 function html_buildcheckboxarray($options,$name,$checked_array) {
379 $option_count=count($options);
380 $checked_count=count($checked_array);
382 for ($i=1; $i<=$option_count; $i++) {
384 <br /><input type="checkbox" name="'.$name.'" value="'.$i.'"';
385 for ($j=0; $j<$checked_count; $j++) {
386 if ($i == $checked_array[$j]) {
387 echo ' checked="checked"';
390 echo ' /> '.$options[$i];
395 * site_user_header() - everything required to handle security and
396 * add navigation for user pages like /my/ and /account/
398 * @param array Must contain $user_id
400 function site_header($params) {
403 Check to see if active user
404 Check to see if logged in
406 echo $HTML->header($params);
407 echo html_feedback_top($GLOBALS['feedback']);
411 * site_footer() - Show the HTML site footer.
413 * @param array Footer params array
415 function site_footer($params) {
417 $HTML->footer($params);
421 * site_project_header() - everything required to handle
422 * security and state checks for a project web page
424 * @param params array() must contain $toptab and $group
426 function site_project_header($params) {
430 Check to see if active
431 Check to see if project rather than foundry
432 Check to see if private (if private check if user_ismember)
435 $group_id=$params['group'];
437 //get the project object
438 $project =& group_get_object($group_id);
440 if (!$project || !is_object($project)) {
441 exit_error("GROUP PROBLEM","PROBLEM CREATING GROUP OBJECT");
442 } else if ($project->isError()) {
443 exit_error("Group Problem",$project->getErrorMessage());
447 if (!$project->isPublic()) {
448 //if it's a private group, you must be a member of that group
449 session_require(array('group'=>$group_id));
452 //for dead projects must be member of admin project
453 if (!$project->isActive()) {
454 //only SF group can view non-active, non-holding groups
455 session_require(array('group'=>'1'));
458 echo $HTML->header($params);
459 echo html_feedback_top($GLOBALS['feedback']);
460 // echo $HTML->project_tabs($params['toptab'],$params['group'],$params['tabtext']);
464 * site_project_footer() - currently a simple shim
465 * that should be on every project page, rather than
466 * a direct call to site_footer() or theme_footer()
468 * @param params array() empty
470 function site_project_footer($params) {
473 echo html_feedback_bottom($GLOBALS['feedback']);
474 echo $HTML->footer($params);
478 * site_user_header() - everything required to handle security and
479 * add navigation for user pages like /my/ and /account/
481 * @param params array() must contain $user_id
483 function site_user_header($params) {
484 GLOBAL $HTML,$Language;
487 Check to see if active user
488 Check to see if logged in
490 echo $HTML->header($params);
491 echo html_feedback_top($GLOBALS['feedback']);
492 echo ($HTML->BeginSubMenu());
493 echo ($HTML->PrintSubMenu(
494 array($Language->getText('menu','my_personal_page'),
495 $Language->getText('menu','diary_notes'),
496 $Language->getText('menu','account_maintenance')),
497 array('"/my/"','"/my/diary.php"','"/account/"')));
498 plugin_hook ("usermenu", false) ;
499 echo ($HTML->EndSubMenu());
503 * site_user_footer() - currently a simple shim that should be on every user page,
504 * rather than a direct call to site_footer() or theme_footer()
506 * @param params array() empty
508 function site_user_footer($params) {
511 echo html_feedback_bottom($GLOBALS['feedback']);
512 echo $HTML->footer($params);
516 * html_clean_hash_string() - Remove noise characters from hex hash string
518 * Thruout SourceForge, URLs with hexadecimal hash string parameters
519 * are being sent via email to request confirmation of user actions.
520 * It was found that some mail clients distort this hash, so we take
521 * special steps to encode it in the way which help to preserve its
522 * recognition. This routine
524 * @param hashstr required hash parameter as received from browser
525 * @return pure hex string
527 function html_clean_hash_string($hashstr) {
529 if (substr($hashstr,0,1)=="_") {
530 $hashstr = substr($hashstr, 1);
533 if (substr($hashstr, strlen($hashstr)-1, 1)==">") {
534 $hashstr = substr($hashstr, 0, strlen($hashstr)-1);