/
manage_tags_page.php
196 lines (171 loc) · 6.43 KB
/
manage_tags_page.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* @package MantisBT
* @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*
* @uses core.php
* @uses access_api.php
* @uses compress_api.php
* @uses config_api.php
* @uses database_api.php
* @uses form_api.php
* @uses gpc_api.php
* @uses helper_api.php
* @uses html_api.php
* @uses lang_api.php
* @uses print_api.php
* @uses string_api.php
* @uses user_api.php
*/
/**
* MantisBT Core API's
*/
require_once( 'core.php' );
require_api( 'access_api.php' );
require_api( 'compress_api.php' );
require_api( 'config_api.php' );
require_api( 'database_api.php' );
require_api( 'form_api.php' );
require_api( 'gpc_api.php' );
require_api( 'helper_api.php' );
require_api( 'html_api.php' );
require_api( 'lang_api.php' );
require_api( 'print_api.php' );
require_api( 'string_api.php' );
require_api( 'user_api.php' );
access_ensure_global_level( config_get( 'tag_view_threshold' ) );
compress_enable();
$t_can_edit = access_has_global_level( config_get( 'tag_edit_threshold' ) );
$f_filter = utf8_strtoupper( gpc_get_string( 'filter', config_get( 'default_manage_tag_prefix' ) ) );
$f_page_number = gpc_get_int( 'page_number', 1 );
$t_tag_table = db_get_table( 'tag' );
# Start Index Menu
$t_prefix_array = array( 'ALL' );
for ( $i = 'A'; $i != 'AA'; $i++ ) {
$t_prefix_array[] = $i;
}
for ( $i = 0; $i <= 9; $i++ ) {
$t_prefix_array[] = "$i";
}
$t_where_params = array();
if ( $f_filter === 'ALL' ) {
$t_where = '';
} else {
$t_where_params[] = $f_filter . '%';
$t_where = 'WHERE ' . db_helper_like( 'name' );
}
# Set the number of Tags per page.
$t_per_page = 20;
$t_offset = (( $f_page_number - 1 ) * $t_per_page );
# Determine number of tags in tag table
$t_total_tag_count = 0;
$t_result = '';
$t_query = "SELECT count(*)
FROM $t_tag_table
$t_where";
$t_result = db_query_bound( $t_query, $t_where_params );
$t_row = db_fetch_array( $t_result );
$t_total_tag_count = (int)db_result( $t_result );
#Number of pages from result
$t_page_count = ceil( $t_total_tag_count / $t_per_page );
if ( $t_page_count < 1 ) {
$t_page_count = 1;
}
# Make sure $p_page_number isn't past the last page.
if ( $f_page_number > $t_page_count ) {
$f_page_number = $t_page_count;
}
# Make sure $p_page_number isn't before the first page
if ( $f_page_number < 1 ) {
$f_page_number = 1;
}
# Retrive Tags from tag table
$t_query = "SELECT *
FROM $t_tag_table
$t_where ORDER BY name";
$t_result = db_query_bound( $t_query, $t_where_params, $t_per_page, $t_offset );
html_page_top( lang_get( 'manage_tags_link' ) );
print_manage_menu( 'manage_tags_page.php' ); ?>
<div id="manage-tags-filter-menu">
<ul class="menu"><?php
foreach ( $t_prefix_array as $t_prefix ) {
$t_caption = ( $t_prefix === 'ALL' ? lang_get( 'show_all_tags' ) : $t_prefix );
if ( $t_prefix == $f_filter ) {
$t_link = "<strong>$t_caption</strong>";
} else {
$t_link = '<a href="manage_tags_page.php?filter=' . $t_prefix .'">' . $t_caption . '</a>';
}
echo "<li>$t_link </li>";
} ?>
</ul>
</div>
<div class="table-container">
<h2><?php echo lang_get( 'manage_tags_link' ) ?> [<?php echo $t_total_tag_count ?>]</h2>
<div class="section-link"><?php print_link( '#tagcreate', lang_get( 'tag_create' ) ) ?></div>
<table cellspacing="1" cellpadding="5" border="1">
<tr class="row-category">
<td><?php echo lang_get( 'tag_name' ) ?></td>
<td><?php echo lang_get( 'tag_creator' ) ?></td>
<td><?php echo lang_get( 'tag_created' ) ?></td>
<td><?php echo lang_get( 'tag_updated' ) ?></td>
</tr><?php
foreach ( $t_result as $t_tag_row ) {
$t_tag_name = string_display_line( $t_tag_row['name'] );
$t_tag_description = string_display( $t_tag_row['description'] ); ?>
<tr <?php echo helper_alternate_class() ?>><?php
if ( $t_can_edit ) { ?>
<td><a href="tag_view_page.php?tag_id=<?php echo $t_tag_row['id'] ?>" ><?php echo $t_tag_name ?></a></td><?php
} else { ?>
<td><?php echo $t_tag_name ?></td><?php
} ?>
<td><?php echo string_display_line( user_get_name( $t_tag_row['user_id'] ) ) ?></td>
<td><?php echo date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?></td>
<td><?php echo date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?></td>
</tr><?php
} ?>
</table>
<div class="pager-links"><?php
/* @todo hack - pass in the hide inactive filter via cheating the actual filter value */
print_page_links( 'manage_tags_page.php', 1, $t_page_count, (int)$f_page_number, $f_filter ); ?>
</div>
</div>
<?php if ( $t_can_edit ) { ?>
<div id="manage-tags-create-div" class="form-container">
<a name="tagcreate" />
<form id="manage-tags-create-form" method="post" action="tag_create.php">
<fieldset class="has-required">
<legend><span><?php echo lang_get( 'tag_create' ) ?></span></legend>
<?php echo form_security_field( 'tag_create' ); ?>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="tag-name" class="required"><span><?php echo lang_get( 'tag_name' ) ?></span></label>
<span class="input"><input type="text" id="tag-name" name="name" size="40" maxlength="100" />
<span><?php echo sprintf( lang_get( 'tag_separate_by' ), config_get( 'tag_separator' ) ); ?></span>
</span>
<span class="label-style"></span>
</div>
<div class="field-container <?php echo helper_alternate_class_no_attribute(); ?>">
<label for="tag-description"><span><?php echo lang_get( 'tag_description' ) ?></span></label>
<span class="textarea"><textarea id="tag-description" name="description" cols="80" rows="6"></textarea></span>
<span class="label-style"></span>
</div>
<span class="submit-button"><input type="submit" class="button" value="<?php echo lang_get( 'tag_create' ) ?>" /></span>
</fieldset>
</form>
</div>
<?php
} #End can Edit
html_page_bottom();