📄 html.php
字号:
<?php/** * Misc HTML functions * * SourceForge: Breaking Down the Barriers to Open Source Development * Copyright 1999-2001 (c) VA Linux Systems * http://sourceforge.net * * @version $Id: html.php,v 1.390 2001/06/28 16:45:28 pfalcon Exp $ *//** * html_feedback_top() - Show the feedback output at the top of the page. * * @param string The feedback. */function html_feedback_top($feedback) { if (!$feedback) return ''; print ' <h3><span style="color:red">'.$feedback.'</span></h3>';}/** * make_user_link() - Make a username reference into a link to that users User page on SF. * * @param string The username of the user to link. */function make_user_link($username) { if (!strcasecmp($username,'Nobody') || !strcasecmp($username,'None')) { return $username; } else { return '<a href="/users/'.$username.'">'.$username.'</a>' ; }}/** * html_feedback_top() - Show the feedback output at the bottom of the page. * * @param string The feedback. */function html_feedback_bottom($feedback) { if (!$feedback) return ''; print ' <h3><span style="color:red">'.$feedback.'</span></h3>';}/** * html_blankimage() - Show the blank spacer image. * * @param int The height of the image * @param int The width of the image */function html_blankimage($height,$width) { return '<img src="/images/blank.png" width="' . $width . '" height="' . $height . '" alt="" />';}/** * html_dbimage() - Show an image that is stored in the database * * @param int The id of the image to show */function html_dbimage($id, $args=0) { if (!$id) { return ''; } if (!$args) { $args = array(); } $sql="SELECT width,height,version ". "FROM db_images WHERE id='$id'"; $result=db_query($sql); $rows=db_numrows($result); if (!$result || $rows < 1) { return db_error(); } else { return html_abs_image('/dbimage.php?id='.$id.'&v='.db_result($result,0,'version'),db_result($result,0,'width'),db_result($result,0,'height'),$args); }}/** * html_abs_image() - Show an image given an absolute URL. * * @param string URL * @param int width of the image * @param int height of the image * @param array Any <img> tag parameters (i.e. 'border', 'alt', etc...) */function html_abs_image($url, $width, $height, $args){ $return = ('<img src="' . $url . '"'); reset($args); while(list($k,$v) = each($args)) { $return .= ' '.$k.'="'.$v.'"'; } // ## insert a border tag if there isn't one if (!isset($args['border'])) { $return .= ' border="0"'; } if (!isset($args['alt'])) { $return .= ' alt=""'; } // ## add image dimensions $return .= " width=\"" . $width . "\""; $return .= " height=\"" . $height . "\""; $return .= (' />'); return $return;}/** * html_image() - Build an image tag of an image contained in $src * * @param string The source location of the image * @param int The width of the image * @param int The height of the image * @param array Any IMG tag parameters associated with this image (i.e. 'border', 'alt', etc...) * @param bool DEPRECATED */function html_image($src,$width,$height,$args,$display=1) { global $sys_images_url,$sys_images_secure_url,$HTML; $s = ((session_issecure()) ? $sys_images_secure_url : $sys_images_url ); return html_abs_image($s.$HTML->imgroot.$src, $width, $height, $args);}/** * html_get_language_popup() - Pop up box of supported languages * * @param object BaseLanguage object * @param string The title of the popup box * @param string Which element of the box is to be selected */function html_get_language_popup ($Language,$title='language_id',$selected='xzxzxz') { $res=$Language->getLanguages(); return html_build_select_box ($res,$title,$selected,false);}/** * html_get_timezone_popup() - Pop up box of supported Timezones * Assumes you have included Timezones array file * * @param string The title of the popup box * @param string Which element of the box is to be selected */function html_get_timezone_popup ($title='timezone',$selected='xzxz') { global $TZs; if ($selected == 'xzxzxzx') { $r = file ('/etc/timezone'); $selected = str_replace ("\n", '', $r[0]); } return html_build_select_box_from_arrays ($TZs,$TZs,$title,$selected,false);}/** * html_build_select_box_from_array() - Takes one array, with the first array being the "id" * or value and the array being the text you want displayed. * * @param string The name you want assigned to this form element * @param string The value of the item that should be checked */function html_build_select_box_from_array ($vals,$select_name,$checked_val='xzxz',$samevals = 0) { $return .= ' <select name="'.$select_name.'">'; $rows=count($vals); for ($i=0; $i<$rows; $i++) { if ( $samevals ) { $return .= "\n\t\t<option value=\"" . $vals[$i] . "\""; if ($vals[$i] == $checked_val) { $return .= ' selected="selected"'; } } else { $return .= "\n\t\t<option value=\"" . $i .'"'; if ($i == $checked_val) { $return .= ' selected="selection"'; } } $return .= '>'.$vals[$i].'</option>'; } $return .= ' </select>'; return $return;}/** * html_build_select_box_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other * array being the text you want displayed. * * The infamous '100 row' has to do with the SQL Table joins done throughout all this code. * There must be a related row in users, categories, et , and by default that * row is 100, so almost every pop-up box has 100 as the default * Most tables in the database should therefore have a row with an id of 100 in it so that joins are successful * * @param array The ID or value * @param array Text to be displayed * @param string Name to assign to this form element * @param string The item that should be checked * @param bool Whether or not to show the '100 row' * @param string What to call the '100 row' defaults to none */function html_build_select_box_from_arrays ($vals,$texts,$select_name,$checked_val='xzxz',$show_100=true,$text_100='none') { global $Language; if ($text_100=='none'){ $text_100=$Language->getText('include_html','none'); } $return .= ' <select name="'.$select_name.'">'; //we don't always want the default 100 row shown if ($show_100) { $return .= ' <option value="100">'. $text_100 .'</option>'; } $rows=count($vals); if (count($texts) != $rows) { $return .= 'ERROR - uneven row counts'; } for ($i=0; $i<$rows; $i++) { // uggh - sorry - don't show the 100 row // if it was shown above, otherwise do show it if (($vals[$i] != '100') || ($vals[$i] == '100' && !$show_100)) { $return .= ' <option value="'.$vals[$i].'"'; if ($vals[$i] == $checked_val) { $checked_found=true; $return .= ' selected="selected"'; } $return .= '>'.$texts[$i].'</option>'; } } // // If the passed in "checked value" was never "SELECTED" // we want to preserve that value UNLESS that value was 'xzxz', the default value // if (!$checked_found && $checked_val != 'xzxz' && $checked_val && $checked_val != 100) { $return .= ' <option value="'.$checked_val.'" selected="selected">'.$Language->getText('include_html','no_change').'</option>'; } $return .= ' </select>'; return $return;}/** * html_build_select_box() - Takes a result set, with the first column being the "id" or value and * the second column being the text you want displayed. * * @param int The result set * @param string Text to be displayed * @param string The item that should be checked * @param bool Whether or not to show the '100 row' * @param string What to call the '100 row'. Defaults to none. */function html_build_select_box ($result, $name, $checked_val="xzxz",$show_100=true,$text_100='none') { global $Language; if ($text_100=='none'){ $text_100=$Language->getText('include_html','none'); } 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);}/** * html_build_multiple_select_box() - Takes a result set, with the first column being the "id" or value * and the second column being the text you want displayed. * * @param int The result set * @param string Text to be displayed * @param string The item that should be checked * @param int The size of this box * @param bool Whether or not to show the '100 row' */function html_build_multiple_select_box ($result,$name,$checked_array,$size='8',$show_100=true) { global $Language; $checked_count=count($checked_array);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -