2 # MantisBT - A PHP based bugtracking system
4 # MantisBT is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
9 # MantisBT is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
19 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
20 * @link http://www.mantisbt.org
23 * @uses access_api.php
24 * @uses compress_api.php
25 * @uses config_api.php
26 * @uses database_api.php
29 * @uses helper_api.php
33 * @uses string_api.php
37 require_once( 'core.php' );
38 require_api( 'access_api.php' );
39 require_api( 'compress_api.php' );
40 require_api( 'config_api.php' );
41 require_api( 'database_api.php' );
42 require_api( 'form_api.php' );
43 require_api( 'gpc_api.php' );
44 require_api( 'helper_api.php' );
45 require_api( 'html_api.php' );
46 require_api( 'lang_api.php' );
47 require_api( 'print_api.php' );
48 require_api( 'string_api.php' );
49 require_api( 'user_api.php' );
51 access_ensure_global_level( config_get( 'tag_view_threshold' ) );
55 html_page_top( lang_get( 'manage_tags_link' ) );
57 print_manage_menu( 'manage_tags_page.php' );
59 $t_can_edit = access_has_global_level( config_get( 'tag_edit_threshold' ) );
60 $f_filter = utf8_strtoupper( gpc_get_string( 'filter', config_get( 'default_manage_tag_prefix' ) ) );
61 $f_page_number = gpc_get_int( 'page_number', 1 );
62 $t_tag_table = db_get_table( 'tag' );
65 $t_prefix_array = array( 'ALL' );
67 for ( $i = 'A'; $i != 'AA'; $i++
) {
68 $t_prefix_array[] = $i;
71 for ( $i = 0; $i <= 9; $i++
) {
72 $t_prefix_array[] = "$i";
75 echo '<br /><table align="center" class="width75"><tr>';
77 foreach ( $t_prefix_array as $t_prefix ) {
78 if ( $t_prefix === 'ALL' ) {
79 $t_caption = lang_get( 'show_all_tags' );
81 $t_caption = $t_prefix;
84 if ( $t_prefix == $f_filter ) {
85 $t_link = "<strong>$t_caption</strong>";
87 $t_link = '<a href="manage_tags_page.php?filter=' . $t_prefix .'">' . $t_caption . '</a>';
90 echo '<td>' . $t_link . '</td>';
95 $t_where_params = array();
97 if ( $f_filter === 'ALL' ) {
100 $t_where_params[] = $f_filter . '%';
101 $t_where = 'WHERE ' . db_helper_like( 'name' );
104 # Set the number of Tags per page.
106 $t_offset = (( $f_page_number - 1 ) * $t_per_page );
108 # Determine number of tags in tag table
109 $t_total_tag_count = 0;
111 $t_query = "SELECT count(*)
115 $t_result = db_query_bound( $t_query, $t_where_params );
116 $t_row = db_fetch_array( $t_result );
117 $t_total_tag_count = (int)db_result( $t_result );
119 #Number of pages from result
120 $t_page_count = ceil( $t_total_tag_count / $t_per_page );
122 if ( $t_page_count < 1 ) {
126 # Make sure $p_page_number isn't past the last page.
127 if ( $f_page_number > $t_page_count ) {
128 $f_page_number = $t_page_count;
131 # Make sure $p_page_number isn't before the first page
132 if ( $f_page_number < 1 ) {
136 # Retrive Tags from tag table
139 $t_where ORDER BY name";
141 $t_result = db_query_bound( $t_query, $t_where_params, $t_per_page, $t_offset );
147 <!-- Tag Table Start
-->
148 <table
class="width100" cellspacing
="1">
150 <td
class="form-title" colspan
="4">
151 <?php
echo lang_get( 'manage_tags_link' ) ?
> [<?php
echo $t_total_tag_count ?
>]
152 <?php
print_link( '#tagcreate', lang_get( 'tag_create' ) ) ?
>
155 <tr
class="row-category">
156 <td width
="25%"><?php
echo lang_get( 'tag_name' ) ?
></td
>
157 <td width
="20%"><?php
echo lang_get( 'tag_creator' ) ?
></td
>
158 <td width
="20%"><?php
echo lang_get( 'tag_created' ) ?
></td
>
159 <td width
="20%"><?php
echo lang_get( 'tag_updated' ) ?
></td
>
162 foreach ( $t_result as $t_tag_row ) {
163 $t_tag_name = string_display_line( $t_tag_row['name'] );
164 $t_tag_description = string_display( $t_tag_row['description'] );
166 <tr
<?php
echo helper_alternate_class() ?
>>
167 <?php
if ( $t_can_edit ) { ?
>
168 <td
><a href
="tag_view_page.php?tag_id=<?php echo $t_tag_row['id'] ?>" ><?php
echo $t_tag_name ?
></a
></td
>
170 <td
><?php
echo $t_tag_name ?
></td
>
172 <td
><?php
echo string_display_line( user_get_name( $t_tag_row['user_id'] ) ) ?
></td
>
173 <td
><?php
echo date( config_get( 'normal_date_format' ), $t_tag_row['date_created'] ) ?
></td
>
174 <td
><?php
echo date( config_get( 'normal_date_format' ), $t_tag_row['date_updated'] ) ?
></td
>
179 <td
class="right" colspan
="8">
182 /* @todo hack - pass in the hide inactive filter via cheating the actual filter value */
183 print_page_links( 'manage_tags_page.php', 1, $t_page_count, (int)$f_page_number, $f_filter );
190 <?php
if ( $t_can_edit ) { ?
>
195 <!-- Create Tag Form
-->
197 <form method
="post" action
="tag_create.php">
198 <?php
echo form_security_field( 'tag_create' ); ?
>
200 <table align
="center" class="width75" cellspacing
="1">
205 <td
class="form-title" colspan
="2">
206 <?php
echo lang_get( 'tag_create' ) ?
>
210 <td
class="category">
211 <span
class="required">*</span
>
212 <?php
echo lang_get( 'tag_name' ) ?
>
215 <input type
="text" name
="name" size
="50" maxlength
="100" />
216 <?php
echo sprintf( lang_get( 'tag_separate_by' ), config_get( 'tag_separator' ) ); ?
>
220 <td
class="category">
221 <?php
echo lang_get( 'tag_description' ) ?
>
223 <td
><textarea name
="description" cols
="80" rows
="6"></textarea
>
228 <span
class="required"> * <?php
echo lang_get( 'required' ) ?
></span
>
230 <td
class="center" colspan
="2">
231 <input type
="submit" class="button" value
="<?php echo lang_get( 'tag_create' ) ?>" />