PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/view_all_inc.php

https://github.com/markkimsal/mantisbt
PHP | 274 lines | 181 code | 43 blank | 50 comment | 37 complexity | 90edf06e39578b534c38707c1c60ab38 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. # MantisBT - A PHP based bugtracking system
  3. # MantisBT is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # MantisBT is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
  15. /**
  16. * @package MantisBT
  17. * @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
  18. * @copyright Copyright (C) 2002 - 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net
  19. * @link http://www.mantisbt.org
  20. *
  21. * @uses category_api.php
  22. * @uses columns_api.php
  23. * @uses config_api.php
  24. * @uses constant_inc.php
  25. * @uses current_user_api.php
  26. * @uses event_api.php
  27. * @uses filter_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. */
  34. if ( !defined( 'VIEW_ALL_INC_ALLOW' ) ) {
  35. return;
  36. }
  37. require_api( 'category_api.php' );
  38. require_api( 'columns_api.php' );
  39. require_api( 'config_api.php' );
  40. require_api( 'constant_inc.php' );
  41. require_api( 'current_user_api.php' );
  42. require_api( 'event_api.php' );
  43. require_api( 'filter_api.php' );
  44. require_api( 'gpc_api.php' );
  45. require_api( 'helper_api.php' );
  46. require_api( 'html_api.php' );
  47. require_api( 'lang_api.php' );
  48. require_api( 'print_api.php' );
  49. $t_filter = current_user_get_bug_filter();
  50. # NOTE: this check might be better placed in current_user_get_bug_filter()
  51. if ( $t_filter === false ) {
  52. $t_filter = filter_get_default();
  53. }
  54. list( $t_sort, ) = explode( ',', $t_filter['sort'] );
  55. list( $t_dir, ) = explode( ',', $t_filter['dir'] );
  56. $g_checkboxes_exist = false;
  57. $t_icon_path = config_get( 'icon_path' );
  58. # Improve performance by caching category data in one pass
  59. if ( helper_get_current_project() > 0 ) {
  60. category_get_all_rows( helper_get_current_project() );
  61. } else {
  62. $t_categories = array();
  63. foreach ($rows as $t_row) {
  64. $t_categories[] = $t_row->category_id;
  65. }
  66. category_cache_array_rows( array_unique( $t_categories ) );
  67. }
  68. $t_columns = helper_get_columns_to_view( COLUMNS_TARGET_VIEW_PAGE );
  69. $col_count = count( $t_columns );
  70. $t_filter_position = config_get( 'filter_position' );
  71. # -- ====================== FILTER FORM ========================= --
  72. if ( ( $t_filter_position & FILTER_POSITION_TOP ) == FILTER_POSITION_TOP ) {
  73. filter_draw_selection_area( $f_page_number );
  74. }
  75. # -- ====================== end of FILTER FORM ================== --
  76. # -- ====================== BUG LIST ============================ --
  77. $t_status_legend_position = config_get( 'status_legend_position' );
  78. if ( $t_status_legend_position == STATUS_LEGEND_POSITION_TOP || $t_status_legend_position == STATUS_LEGEND_POSITION_BOTH ) {
  79. html_status_legend();
  80. }
  81. /** @todo (thraxisp) this may want a browser check ( MS IE >= 5.0, Mozilla >= 1.0, Safari >=1.2, ...) */
  82. if ( ( ON == config_get( 'dhtml_filters' ) ) && ( ON == config_get( 'use_javascript' ) ) ){
  83. ?>
  84. <script type="text/javascript">
  85. <!--
  86. var string_loading = '<?php echo lang_get( 'loading' );?>';
  87. // -->
  88. </script>
  89. <?php
  90. html_javascript_link( 'xmlhttprequest.js');
  91. html_javascript_link( 'addLoadEvent.js');
  92. html_javascript_link( 'dynamic_filters.js');
  93. }
  94. ?>
  95. <br />
  96. <form name="bug_action" method="get" action="bug_actiongroup_page.php">
  97. <?php # CSRF protection not required here - form does not result in modifications ?>
  98. <table id="buglist" class="width100" cellspacing="1">
  99. <thead>
  100. <tr class="buglist-nav">
  101. <td class="form-title" colspan="<?php echo $col_count; ?>">
  102. <span class="floatleft">
  103. <?php
  104. # -- Viewing range info --
  105. $v_start = 0;
  106. $v_end = 0;
  107. if ( count( $rows ) > 0 ) {
  108. $v_start = $t_filter['per_page'] * ($f_page_number - 1) + 1;
  109. $v_end = $v_start + count( $rows ) - 1;
  110. }
  111. echo lang_get( 'viewing_bugs_title' );
  112. echo " ($v_start - $v_end / $t_bug_count)";
  113. ?> </span>
  114. <span class="floatleft small">
  115. <?php
  116. # -- Print and Export links --
  117. echo '&nbsp;';
  118. print_bracket_link( 'print_all_bug_page.php', lang_get( 'print_all_bug_page_link' ) );
  119. echo '&nbsp;';
  120. print_bracket_link( 'csv_export.php', lang_get( 'csv_export' ) );
  121. echo '&nbsp;';
  122. print_bracket_link( 'excel_xml_export.php', lang_get( 'excel_export' ) );
  123. $t_event_menu_options = $t_links = event_signal( 'EVENT_MENU_FILTER' );
  124. foreach ( $t_event_menu_options as $t_plugin => $t_plugin_menu_options ) {
  125. foreach ( $t_plugin_menu_options as $t_callback => $t_callback_menu_options ) {
  126. if ( !is_array( $t_callback_menu_options ) ) {
  127. $t_callback_menu_options = array( $t_callback_menu_options );
  128. }
  129. foreach ( $t_callback_menu_options as $t_menu_option ) {
  130. print_bracket_link_prepared( $t_menu_option );
  131. }
  132. }
  133. }
  134. ?> </span>
  135. <span class="floatright small"><?php
  136. # -- Page number links --
  137. $f_filter = gpc_get_int( 'filter', 0);
  138. print_page_links( 'view_all_bug_page.php', 1, $t_page_count, (int)$f_page_number, $f_filter );
  139. ?> </span>
  140. </td>
  141. </tr>
  142. <?php # -- Bug list column header row -- ?>
  143. <tr class="buglist-headers row-category">
  144. <?php
  145. foreach( $t_columns as $t_column ) {
  146. $t_title_function = 'print_column_title';
  147. helper_call_custom_function( $t_title_function, array( $t_column ) );
  148. }
  149. ?>
  150. </tr>
  151. <?php # -- Spacer row -- ?>
  152. <tr class="spacer">
  153. <td colspan="<?php echo $col_count; ?>"></td>
  154. </tr>
  155. </thead><tbody>
  156. <?php
  157. function write_bug_rows ( $p_rows )
  158. {
  159. global $t_columns, $t_filter;
  160. $t_in_stickies = ( $t_filter && ( 'on' == $t_filter[FILTER_PROPERTY_STICKY] ) );
  161. # pre-cache custom column data
  162. columns_plugin_cache_issue_data( $p_rows );
  163. # -- Loop over bug rows --
  164. $t_rows = count( $p_rows );
  165. for( $i=0; $i < $t_rows; $i++ ) {
  166. $t_row = $p_rows[$i];
  167. if ( ( 0 == $t_row->sticky ) && ( 0 == $i ) ) {
  168. $t_in_stickies = false;
  169. }
  170. if ( ( 0 == $t_row->sticky ) && $t_in_stickies ) { # demarcate stickies, if any have been shown
  171. ?>
  172. <tr>
  173. <td class="left" colspan="<?php echo count( $t_columns ); ?>" bgcolor="#999999">&nbsp;</td>
  174. </tr>
  175. <?php
  176. $t_in_stickies = false;
  177. }
  178. # choose color based on status
  179. $status_color = get_status_color( $t_row->status );
  180. echo '<tr bgcolor="', $status_color, '" border="1" valign="top">';
  181. foreach( $t_columns as $t_column ) {
  182. $t_column_value_function = 'print_column_value';
  183. helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row ) );
  184. }
  185. echo '</tr>';
  186. }
  187. }
  188. write_bug_rows($rows);
  189. # -- ====================== end of BUG LIST ========================= --
  190. # -- ====================== MASS BUG MANIPULATION =================== --
  191. # @@@ ideally buglist-footer would be in <tfoot>, but that's not possible due to global g_checkboxes_exist set via write_bug_rows()
  192. ?>
  193. <tr class="buglist-footer">
  194. <td class="left" colspan="<?php echo $col_count; ?>">
  195. <span class="floatleft">
  196. <?php
  197. if ( $g_checkboxes_exist && ON == config_get( 'use_javascript' ) ) {
  198. echo "<input type=\"checkbox\" name=\"all_bugs\" value=\"all\" onclick=\"checkall('bug_action', this.form.all_bugs.checked)\" /><span class=\"small\">" . lang_get( 'select_all' ) . '</span>';
  199. }
  200. if ( $g_checkboxes_exist ) {
  201. ?>
  202. <select name="action">
  203. <?php print_all_bug_action_option_list( $t_unique_project_ids ) ?>
  204. </select>
  205. <input type="submit" class="button" value="<?php echo lang_get( 'ok' ); ?>" />
  206. <?php
  207. } else {
  208. echo '&nbsp;';
  209. }
  210. ?> </span>
  211. <span class="floatright small">
  212. <?php
  213. $f_filter = gpc_get_int( 'filter', 0);
  214. print_page_links( 'view_all_bug_page.php', 1, $t_page_count, (int)$f_page_number, $f_filter );
  215. ?>
  216. </span>
  217. </td>
  218. </tr>
  219. <?php # -- ====================== end of MASS BUG MANIPULATION ========================= -- ?>
  220. </tbody>
  221. </table>
  222. </form>
  223. <?php
  224. if ( $t_status_legend_position == STATUS_LEGEND_POSITION_BOTTOM || $t_status_legend_position == STATUS_LEGEND_POSITION_BOTH ) {
  225. html_status_legend();
  226. }
  227. # -- ====================== FILTER FORM ========================= --
  228. if ( ( $t_filter_position & FILTER_POSITION_BOTTOM ) == FILTER_POSITION_BOTTOM ) {
  229. filter_draw_selection_area( $f_page_number );
  230. }
  231. # -- ====================== end of FILTER FORM ================== --