Fix #11417: Allow EVENT_MENU_MAIN plugin events to return null
[mantis/radio.git] / manage_tags_page.php
blob5a90a7dbbea98f5157688dc804161c6754535424
1 <?php
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/>.
17 /**
18 * @package MantisBT
19 * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
20 * @link http://www.mantisbt.org
22 * @uses core.php
23 * @uses access_api.php
24 * @uses compress_api.php
25 * @uses config_api.php
26 * @uses database_api.php
27 * @uses form_api.php
28 * @uses gpc_api.php
29 * @uses helper_api.php
30 * @uses html_api.php
31 * @uses lang_api.php
32 * @uses print_api.php
33 * @uses string_api.php
34 * @uses user_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' ) );
53 compress_enable();
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' );
64 # Start Index Menu
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' );
80 } else {
81 $t_caption = $t_prefix;
84 if ( $t_prefix == $f_filter ) {
85 $t_link = "<strong>$t_caption</strong>";
86 } else {
87 $t_link = '<a href="manage_tags_page.php?filter=' . $t_prefix .'">' . $t_caption . '</a>';
90 echo '<td>' . $t_link . '</td>';
93 echo '</tr></table>';
95 $t_where_params = array();
97 if ( $f_filter === 'ALL' ) {
98 $t_where = '';
99 } else {
100 $t_where_params[] = $f_filter . '%';
101 $t_where = 'WHERE ' . db_helper_like( 'name' );
104 # Set the number of Tags per page.
105 $t_per_page = 20;
106 $t_offset = (( $f_page_number - 1 ) * $t_per_page );
108 # Determine number of tags in tag table
109 $t_total_tag_count = 0;
110 $t_result = '';
111 $t_query = "SELECT count(*)
112 FROM $t_tag_table
113 $t_where";
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 ) {
123 $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 ) {
133 $f_page_number = 1;
136 # Retrive Tags from tag table
137 $t_query = "SELECT *
138 FROM $t_tag_table
139 $t_where ORDER BY name";
141 $t_result = db_query_bound( $t_query, $t_where_params, $t_per_page, $t_offset );
145 <br/>
147 <!-- Tag Table Start -->
148 <table class="width100" cellspacing="1">
149 <tr>
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' ) ) ?>
153 </td>
154 </tr>
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>
160 </tr>
161 <?php
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>
169 <?php } else { ?>
170 <td><?php echo $t_tag_name ?></td>
171 <?php } ?>
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>
175 </tr>
176 <?php } ?>
178 <tr>
179 <td class="right" colspan="8">
180 <span class="small">
181 <?php
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 );
185 </span>
186 </td>
187 </tr>
188 </table>
190 <?php if ( $t_can_edit ) { ?>
192 <br />
193 <a name="tagcreate">
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">
202 <!-- Title -->
204 <tr>
205 <td class="form-title" colspan="2">
206 <?php echo lang_get( 'tag_create' ) ?>
207 </td>
208 </tr>
209 <tr class="row-1">
210 <td class="category">
211 <span class="required">*</span>
212 <?php echo lang_get( 'tag_name' ) ?>
213 </td>
214 <td>
215 <input type="text" name="name" size="50" maxlength="100" />
216 <?php echo sprintf( lang_get( 'tag_separate_by' ), config_get( 'tag_separator' ) ); ?>
217 </td>
218 </tr>
219 <tr class="row-2">
220 <td class="category">
221 <?php echo lang_get( 'tag_description' ) ?>
222 </td>
223 <td><textarea name="description" cols="80" rows="6"></textarea>
224 </td>
225 </tr>
226 <tr>
227 <td class="left">
228 <span class="required"> * <?php echo lang_get( 'required' ) ?></span>
229 </td>
230 <td class="center" colspan="2">
231 <input type="submit" class="button" value="<?php echo lang_get( 'tag_create' ) ?>" />
232 </td>
233 </tr>
235 </table>
236 </form>
238 <?php
239 } #End can Edit
241 html_page_bottom();