Go to the source code of this file.
Functions | |
| if(realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) | html_redirect ($url, $success=TRUE, $message='') |
| html_checkbox ($name, $state, $value='', $attributes= '') | |
| gravatar ($email, $size=32, $hyperlink=TRUE) | |
| percent_bar ($percent) | |
| colheader ($colname, $coltitle, $sort=FALSE, $order='', $filter='', $defaultorder='a', $width='') | |
| array_drop_down ($array, $name, $setting='', $attributes='', $usekey=NULL, $multi=FALSE) | |
| user_alert ($message, $severity, $helpcontext= '') | |
| icon ($filename, $size='', $alt='', $title='', $id='') | |
| date_picker ($formelement) | |
| autocomplete ($formelement, $action= 'autocomplete_sitecontact') | |
| protectform ($formelement, $message= '') | |
| array_drop_down | ( | $ | array, | |
| $ | name, | |||
| $ | setting = '', |
|||
| $ | attributes = '', |
|||
| $ | usekey = NULL, |
|||
| $ | multi = FALSE | |||
| ) |
Takes an array and makes an HTML selection box
| array | $array - The array of options to display in the drop-down | |
| string | $name - The HTML name attribute (also used for id) | |
| mixed | $setting - The value to pre-select | |
| string | $attributes - Extra attributes for the select tag | |
| mixed | $usekey - (optional) Set the option value to be the array key instead of the array value. When TRUE the array key will be used as the option value When FALSE the array value will be usedoption value When NULL the function detects which is most appropriate | |
| bool | $multi - When TRUE a multiple selection box is returned and $setting can be an array of values to pre-select |
| string | HTML select element |
Definition at line 286 of file html.inc.php.
References $items, $name, count, and elseif.
Referenced by cfgVarInput().
{
if ($multi AND substr($name, -2) != '[]') $name .= '[]';
$html = "<select name='$name' id='$name' ";
if (!empty($attributes))
{
$html .= "$attributes ";
}
if ($multi)
{
$items = count($array);
if ($items > 5) $size = floor($items / 3);
if ($size > 10) $size = 10;
$html .= "multiple='multiple' size='$size' ";
}
$html .= ">\n";
if ($usekey === '')
{
if ((array_key_exists($setting, $array) AND
in_array((string)$setting, $array) == FALSE) OR
$usekey == TRUE)
{
$usekey = TRUE;
}
else
{
$usekey = FALSE;
}
}
foreach ($array AS $key => $value)
{
$value = htmlentities($value, ENT_COMPAT, $GLOBALS['i18ncharset']);
if ($usekey)
{
$html .= "<option value='$key'";
if ($multi === TRUE AND is_array($setting))
{
if (in_array($key, $setting))
{
$html .= " selected='selected'";
}
}
elseif ($key == $setting)
{
$html .= " selected='selected'";
}
}
else
{
$html .= "<option value='$value'";
if ($multi === TRUE AND is_array($setting))
{
if (in_array($value, $setting))
{
$html .= " selected='selected'";
}
}
elseif ($value == $setting)
{
$html .= " selected='selected'";
}
}
$html .= ">{$value}</option>\n";
}
$html .= "</select>\n";
return $html;
}
| autocomplete | ( | $ | formelement, | |
| $ | action = 'autocomplete_sitecontact' | |||
| ) |
Uses scriptaculous and AutoComplete.js to make a form text input box autocomplete
| string | $formelement. form element id, eg. textinput | |
| string | $action. ajaxdata.php action to return JSON data |
Definition at line 505 of file html.inc.php.
Referenced by autocomplete_ccfield_function(), and autocomplete_tofield_function().
{
$html .= "<script type=\"text/javascript\">\n//<![CDATA[\n";
// Disable browser autocomplete (it clashes)
$html .= "$('$formelement').setAttribute(\"autocomplete\", \"off\"); \n";
$html .= "new AutoComplete('{$formelement}', 'ajaxdata.php?action={$action}&s=', {\n";
$html .= "delay: 0.25,\n";
$html .= "resultFormat: AutoComplete.Options.RESULT_FORMAT_JSON\n";
$html .= "}); \n//]]>\n</script>\n";
return $html;
}
| colheader | ( | $ | colname, | |
| $ | coltitle, | |||
| $ | sort = FALSE, |
|||
| $ | order = '', |
|||
| $ | filter = '', |
|||
| $ | defaultorder = 'a', |
|||
| $ | width = '' | |||
| ) |
Return HTML for a table column header (th and /th) with links for sorting Filter parameter can be an assocative array containing fieldnames and values to pass on the url for data filtering purposes
| string | $colname. Column name | |
| string | $coltitle. Column title (to display in the table header) | |
| bool | $sort Whether to sort the column | |
| string | $order ASC or DESC | |
| array | $filter assoc. array of variables to pass on the link url | |
| string | $defaultorder The order to display by default (a = ASC, d = DESC) | |
| string | $width cell width |
Definition at line 221 of file html.inc.php.
References $CONFIG, $filter, $order, $sort, and global.
Referenced by create_report(), dashboard_engineer_display(), dashboard_incoming_display(), dashboard_manager_display(), dashboard_my_incidents_display(), dashboard_tasks(), dashboard_tms_backup(), dashboard_watch_incidents_display(), and portal_incident_table().
{
global $CONFIG;
if ($width != '')
{
$html = "<th width='".intval($width)."%'>";
}
else
{
$html = "<th>";
}
$qsappend='';
if (!empty($filter) AND is_array($filter))
{
foreach ($filter AS $key => $var)
{
if ($var != '') $qsappend .= "&{$key}=".urlencode($var);
}
}
else
{
$qsappend='';
}
if ($sort==$colname)
{
//if ($order=='') $order=$defaultorder;
if ($order=='a')
{
$html .= "<a href='{$_SERVER['PHP_SELF']}?sort=$colname&order=d{$qsappend}'>{$coltitle}</a> ";
$html .= "<img src='{$CONFIG['application_webpath']}images/sort_a.png' width='5' height='5' alt='{$GLOBALS['strSortAscending']}' /> ";
}
else
{
$html .= "<a href='{$_SERVER['PHP_SELF']}?sort=$colname&order=a{$qsappend}'>{$coltitle}</a> ";
$html .= "<img src='{$CONFIG['application_webpath']}images/sort_d.png' width='5' height='5' alt='{$GLOBALS['strSortDescending']}' /> ";
}
}
else
{
if ($sort === FALSE) $html .= "{$coltitle}";
else $html .= "<a href='{$_SERVER['PHP_SELF']}?sort=$colname&order={$defaultorder}{$qsappend}'>{$coltitle}</a> ";
}
$html .= "</th>";
return $html;
}
| date_picker | ( | $ | formelement | ) |
Uses calendar.js to make a popup date picker
| string | $formelement. form element id, eg. myform.dateinputbox |
Definition at line 482 of file html.inc.php.
References $CONFIG, and global.
Referenced by show_next_action().
{
global $CONFIG, $iconset;
$divid = "datediv".str_replace('.','',$formelement);
$html = "<img src='{$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/pickdate.png' ";
$html .= "onmouseup=\"toggleDatePicker('$divid','$formelement')\" width='16' height='16' alt='date picker' style='cursor: pointer; vertical-align: bottom;' />";
$html .= "\n<div id='$divid' style='position: absolute;'></div>\n";
return $html;
}
| gravatar | ( | $ | email, | |
| $ | size = 32, |
|||
| $ | hyperlink = TRUE | |||
| ) |
Returns HTML for a gravatar (Globally recognised avatar)
| string | $email - Email address | |
| int | $size - Size in pixels (Default 32) | |
| bool | $hyperlink - Make a link back to gravatar.com, default TRUE |
Definition at line 161 of file html.inc.php.
References $_SERVER, $CONFIG, $email, and global.
Referenced by generate_row().
{
global $CONFIG, $iconset;
$default = $CONFIG['default_gravatar'];
if (isset( $_SERVER['HTTPS']) && (strtolower( $_SERVER['HTTPS'] ) != 'off' ))
{
// Secure
$grav_url = "https://secure.gravatar.com";
}
else
{
$grav_url = "http://www.gravatar.com";
}
$grav_url .= "/avatar.php?";
$grav_url .= "gravatar_id=".md5(strtolower($email));
$grav_url .= "&default=".urlencode($CONFIG['default_gravatar']);
$grav_url .= "&size=".$size;
$grav_url .= "&rating=G";
if ($hyperlink) $html = "<a href='http://site.gravatar.com/'>";
$html .= "<img src='{$grav_url}' width='{$size}' height='{$size}' alt='' />";
if ($hyperlink) $html .= "</a>";
return $html;
}
| html_checkbox | ( | $ | name, | |
| $ | state, | |||
| $ | value = '', |
|||
| $ | attributes = '' | |||
| ) |
Returns a HTML string for a checkbox
| string | $name The HTML name attribute | |
| mixed | $state | |
| string | $value. (optional) Value, state is used if blank | |
| string | $attributes. (optional) Extra attributes for input tag |
Definition at line 133 of file html.inc.php.
Referenced by show_add_contact().
{
if ($state === TRUE) $state = 'TRUE';
if ($state === FALSE) $state = 'FALSE';
if ($state === 1 OR $state === 'Yes' OR $state === 'yes' OR
$state === 'true' OR $state === 'TRUE')
{
if ($value == '') $value = $state;
$html = "<input type='checkbox' checked='checked' name='{$name}' id='{$name}' value='{$value}' {$attributes} />" ;
}
else
{
if ($value == '') $value = $state;
$html = "<input type='checkbox' name='{$name}' id='{$name}' value='{$value}' {$attributes} />" ;
}
return $html;
}
| if (realpath(__FILE__)==realpath($_SERVER['SCRIPT_FILENAME'])) html_redirect | ( | $ | url, | |
| $ | success = TRUE, |
|||
| $ | message = '' | |||
| ) |
Generate HTML for a redirect/confirmation page
| string | $url. URL to redirect to | |
| bool | $success. (optional) TRUE = Success, FALSE = Failure | |
| string | $message. (optional) HTML message to display on the page before redirection. This parameter is optional and only required if the default success/failure will not suffice |
Definition at line 36 of file html.inc.php.
References $_SESSION, $CONFIG, $headerdisplayed, $refresh, $siterrors, $title, elseif, and global.
Referenced by dashboard_rss_edit(), delete_signature(), and process_add_contact().
{
global $CONFIG, $headerdisplayed, $siterrors;
if (!empty($_REQUEST['dashboard']))
{
$headerdisplayed = TRUE;
}
if (empty($message))
{
$refreshtime = 1;
}
elseif ($success == FALSE)
{
$refreshtime = 3;
}
else
{
$refreshtime = 6;
}
// Catch all, make refresh time slow if errors are detected
if ($siterrors > 0)
{
$refreshtime = 10;
}
$refresh = "{$refreshtime}; url={$url}";
$title = $GLOBALS['strPleaseWaitRedirect'];
if (!$headerdisplayed)
{
if ($_SESSION['portalauth'] == TRUE)
{
include (APPLICATION_INCPATH . 'portalheader.inc.php');
}
else
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
}
}
else
{
echo "<meta http-equiv=\"refresh\" content=\"$refreshtime; url=$url\" />\n";
}
echo "<h3>";
if ($success)
{
echo "<span class='success'>{$GLOBALS['strSuccess']}</span>";
}
else
{
echo "<span class='failure'>{$GLOBALS['strFailed']}</span>";
}
if (!empty($message))
{
echo ": {$message}";
}
echo "</h3>";
if (empty($_REQUEST['dashboard']))
{
echo "<h4>{$GLOBALS['strPleaseWaitRedirect']}</h4>";
if ($headerdisplayed)
{
echo "<p align='center'><a href=\"{$url}\">{$GLOBALS['strContinue']}</a></p>";
}
}
// TODO 3.35 Add a link to refresh the dashlet if this is run inside a dashlet
if ($headerdisplayed)
{
if ($_SESSION['portalauth'] == TRUE)
{
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
else
{
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
}
}
| icon | ( | $ | filename, | |
| $ | size = '', |
|||
| $ | alt = '', |
|||
| $ | title = '', |
|||
| $ | id = '' | |||
| ) |
Output the html for an icon
| string | $filename filename of the string, minus extension, we assume .png | |
| int | $size size of the icon, from: 12, 16, 32 | |
| string | $alt alt text of the icon (optional) | |
| string | $title (optional) | |
| string | $id ID attribute (optional) |
Definition at line 420 of file html.inc.php.
References $CONFIG, $file, $filename, $id, $title, E_USER_WARNING, and global.
Referenced by add_note_form(), contact_info(), dashboard_engineer(), dashboard_incoming(), dashboard_links(), dashboard_manager(), dashboard_my_incidents(), dashboard_random_tip(), dashboard_rss(), dashboard_rss_edit(), dashboard_statistics(), dashboard_tags(), dashboard_tasks(), dashboard_tms_backup(), dashboard_user_incidents(), dashboard_watch_incidents(), dashlet(), display_drafts(), display_update_page(), show_notes(), triggeraction_description(), and user_online_icon().
{
global $iconset, $CONFIG;
$sizes = array(12, 16, 32);
if (!in_array($size, $sizes) OR empty($size))
{
trigger_error("Incorrect image size for '{$filename}.png' ", E_USER_WARNING);
$size = 16;
}
$file = dirname( __FILE__ ).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR."images/icons/{$iconset}";
$file .= "/{$size}x{$size}/{$filename}.png";
$urlpath = "{$CONFIG['application_webpath']}images/icons/{$iconset}";
$urlpath .= "/{$size}x{$size}/{$filename}.png";
if (!file_exists($file))
{
$alt = "Missing icon: '$filename.png', ($file) size {$size}";
if ($CONFIG['debug']) trigger_error($alt, E_USER_WARNING);
$urlpath = dirname( __FILE__ ).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR."images/icons/sit";
$urlpath .= "/16x16/blank.png";
}
$icon = "<img src=\"{$urlpath}\"";
if (!empty($alt))
{
$icon .= " alt=\"{$alt}\" ";
}
else
{
$alt = $filename;
$icon .= " alt=\"{$alt}\" ";
}
if (!empty($title))
{
$icon .= " title=\"{$title}\"";
}
else
{
$icon .= " title=\"{$alt}\"";
}
if (!empty($id))
{
$icon .= " id=\"{$id}\"";
}
$icon .= " width=\"{$size}\" height=\"{$size}\" ";
$icon .= " />";
return $icon;
}
| percent_bar | ( | $ | percent | ) |
Produces HTML for a percentage indicator
| int | $percent. Number between 0 and 100 |
Definition at line 195 of file html.inc.php.
{
if ($percent == '') $percent = 0;
if ($percent < 0) $percent = 0;
if ($percent > 100) $percent = 100;
// #B4D6B4;
$html = "<div class='percentcontainer'>";
$html .= "<div class='percentbar' style='width: {$percent}%;'> {$percent}%";
$html .= "</div></div>\n";
return $html;
}
| protectform | ( | $ | formelement, | |
| $ | message = '' | |||
| ) |
Uses prototype.js and FormProtector.js to prevent navigating away from an unsubmitted form
| string | $formelement. form element id | |
| string | $message. (optional) Message to display in the warning popup |
Definition at line 530 of file html.inc.php.
References $strRememberToSave, and global.
{
global $strRememberToSave;
if (empty($message)) $message = $strRememberToSave;
$html = "\n<script type='text/javascript'>\n";
$html .= " var fp = new FormProtector('$formelement');\n";
$html .= " fp.setMessage('{$message}');\n";
$html .= "</script>\n";
return $html;
}
| user_alert | ( | $ | message, | |
| $ | severity, | |||
| $ | helpcontext = '' | |||
| ) |
Prints a user alert message, these are errors caused by users that can be corrected by users, as opposed to system errors that should use trigger_error() instead
| string | $message The message to display | |
| int | severity. Same as php error constants so E_USER_ERROR / 256 E_USER_WARNING / 512 E_USER_NOTICE / 1024 | |
| string | $helpcontext (optional) - will display a help link. [?] to the given help context |
E_USER_NOTICE would indicate pure information, nothing is wrong E_USER_WARNING would indicate that something is wrong, but nothing needs correcting E_USER_ERROR would indicate that something is wrong and needs to be corrected (not a system problem though!)
Definition at line 381 of file html.inc.php.
References $class, E_USER_ERROR, E_USER_WARNING, and help_link().
Referenced by show_form_errors().
{
switch ($severity)
{
case E_USER_ERROR:
$class = 'alert error';
$info = $GLOBALS['strError'];
break;
case E_USER_WARNING:
$class = 'alert warning';
$info = $GLOBALS['strWarning'];
break;
case E_USER_NOTICE:
default:
$class = 'alert info';
$info = $GLOBALS['strInfo'];
}
$html = "<p class='{$class}'>";
if (!empty($helpcontext)) $html .= help_link($helpcontext);
$html .= "<strong>{$info}</strong>: {$message}";
$html .= "</p>";
return $html;
}
For more help developing with SiT! see http://sitracker.org/wiki/DevelopmentHowTo