/
icon_api.php
100 lines (92 loc) · 3.17 KB
/
icon_api.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
# Mantis - a php based bugtracking system
# Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
# Copyright (C) 2002 - 2003 Mantis Team - mantisbt-dev@lists.sourceforge.net
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details
# --------------------------------------------------------
# $Id: icon_api.php,v 1.8 2003-03-31 07:10:11 int2str Exp $
# --------------------------------------------------------
###########################################################################
# Icon API
###########################################################################
# --------------------
# Icon associative arrays
# --------------------
# Status to icon mapping
$g_status_icon_arr = array (
NONE => '',
LOW => '',
NORMAL => '',
HIGH => 'priority_1.gif',
URGENT => 'priority_2.gif',
IMMEDIATE => 'priority_3.gif'
);
# --------------------
# Sort direction to icon mapping
$g_sort_icon_arr = array (
ASC => 'up.gif',
DESC => 'down.gif'
);
# --------------------
# Read status to icon mapping
$g_unread_icon_arr = array (
READ => 'mantis-space.gif',
UNREAD => 'unread.gif'
);
# --------------------
###########################################################################
# Icon Print API
###########################################################################
# --------------------
# prints the staus icon
function icon_get_status_icon( $p_icon ) {
global $g_icon_path, $g_status_icon_arr;
$t_none = NONE;
if ( !is_blank( $g_status_icon_arr[$p_icon] ) ) {
return "<img src=\"$g_icon_path$g_status_icon_arr[$p_icon]\" alt=\"\" />";
} else {
return " ";
}
}
function print_status_icon( $p_icon ) {
echo icon_get_status_icon( $p_icon );
}
# --------------------
# The input $p_dir is either ASC or DESC
# The inputs $p_sort_by and $p_field are compared to see if they match
# If the fields match then the sort icon is printed
# This is a convenience feature to push the comparison code into this
# function instead of in the page(s)
# $p_field is a constant and $p_sort_by is whatever the page happens to
# be sorting by at the moment
# Multiple sort keys are not supported
function print_sort_icon( $p_dir, $p_sort_by, $p_field ) {
global $g_icon_path, $g_sort_icon_arr;
if ( $p_sort_by != $p_field ) return;
if ( 'DESC' == $p_dir || DESC == $p_dir) {
$t_dir = DESC;
} else {
$t_dir = ASC;
}
$t_none = NONE;
if ( !is_blank( $g_sort_icon_arr[$t_dir] ) ) {
PRINT "<img src=\"$g_icon_path$g_sort_icon_arr[$t_dir]\" alt=\"\" />";
} else {
PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$t_none]\" alt=\"\" />";
}
}
# --------------------
# prints the unread icon if the parameter is UNREAD
# @@@ UNUSED
function print_unread_icon( $p_unread=READ ) {
global $g_icon_path, $g_unread_icon_arr;
$t_none = NONE;
if ( !is_blank( $g_unread_icon_arr[$p_unread] ) ) {
PRINT "<img src=\"$g_icon_path$g_unread_icon_arr[$p_unread]\" alt=\"\" />";
} else {
PRINT "<img src=\"$g_icon_path$g_status_icon_arr[$t_none]\" alt=\"\" />";
}
}
# --------------------
?>