summaryrefslogtreecommitdiff
path: root/misc.php
blob: 971e8583e0f21e830349e04cb9af16eb35c2b378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

///////////////////////////////////////////////////////////////////////////////
//
// pgPhoneHome - Postgres Monitor for iPhone
// Copyright 2008, EnterpriseDB UK Ltd.
// Dave Page (dave.page@enterprisedb.com)
//
// misc.php - Misc functions
//
///////////////////////////////////////////////////////////////////////////////

// Display an error
function www_error($message, $detail)
{
	$app_name = $GLOBALS['APP_NAME'];

	$text = <<<EOT
<div class="panel" title="Error">
<p>An error has occured in $app_name:</p>
<p style="color: red; font-weight: bold;">$message</p>
<p style="color: red; font-weight: normal;">$detail</p>
<p>For support, please visit the EnterpriseDB <a href="http://forums.enterprisedb.com" target="_new">forums</a>.</p>
</div>
EOT;

    echo $text;
    exit();
}

// Return a clean value for display, or a no-break space to maintain box size etc.
function www_clean($text)
{
	if ($text == "")
		return "&nbsp;";
	else
		return htmlspecialchars($text);
}

// Truncate a value for display
function truncate_value($text)
{
	if (strlen($text) > $GLOBALS['config_max_field_size'])
		return substr($text, 0, $GLOBALS['config_max_field_size']) . " [value truncated]";
	else
		return $text;
}

// Truncate a value for use on a menu
function truncate_title($text)
{
       if (strlen($text) > 30)
                return substr($text, 0, 30) . "...";
       else
                return $text;
}
?>