[ Index ] |
|
Code source de Mantis 1.1.0rc3 |
1 <?php 2 # Mantis - a php based bugtracking system 3 4 # Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org 5 # Copyright (C) 2002 - 2007 Mantis Team - mantisbt-dev@lists.sourceforge.net 6 7 # Mantis is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Mantis is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with Mantis. If not, see <http://www.gnu.org/licenses/>. 19 20 # -------------------------------------------------------- 21 # $Id: csv_api.php,v 1.10.2.1 2007-10-13 22:35:20 giallu Exp $ 22 # -------------------------------------------------------- 23 24 ### CSV API ### 25 26 # -------------------- 27 # get the csv file new line, can be moved to config in the future 28 function csv_get_newline() { 29 return "\r\n"; 30 } 31 32 # -------------------- 33 # get the csv file separator, can be moved to config in the future 34 function csv_get_separator() { 35 return config_get( 'csv_separator' ); 36 } 37 38 # -------------------- 39 # if all projects selected, default to <username>.csv, otherwise default to 40 # <projectname>.csv. 41 function csv_get_default_filename() { 42 $t_current_project_id = helper_get_current_project(); 43 44 if ( ALL_PROJECTS == $t_current_project_id ) { 45 $t_filename = user_get_name( auth_get_current_user_id() ); 46 } else { 47 $t_filename = project_get_field( $t_current_project_id, 'name' ); 48 } 49 50 return $t_filename . '.csv'; 51 } 52 53 # -------------------- 54 # escape a string before writing it to csv file. 55 function csv_escape_string( $p_str ) { 56 if ( strpos( $p_str, csv_get_separator() ) !== false ) { 57 $p_str = '"' . str_replace( '"', '""', $p_str ) . '"'; 58 } 59 60 return $p_str; 61 } 62 63 # -------------------- 64 # An array of column names that are used to identify fields to include and in which order. 65 function csv_get_columns() { 66 $t_columns = helper_get_columns_to_view( COLUMNS_TARGET_CSV_PAGE ); 67 return $t_columns; 68 } 69 70 # 71 # Formatting Functions 72 # 73 # Names for formatting functions are csv_format_*, where * corresponds to the 74 # field name as return get csv_get_columns() and by the filter api. 75 # 76 77 # -------------------- 78 # format bug id 79 function csv_format_id( $p_bug_id ) { 80 return bug_format_id( $p_bug_id ); 81 } 82 83 # -------------------- 84 # returns the project name corresponding to the supplied project id. 85 function csv_format_project_id( $p_project_id ) { 86 return csv_escape_string( project_get_name( $p_project_id ) ); 87 } 88 89 # -------------------- 90 # returns the reporter name corresponding to the supplied id. 91 function csv_format_reporter_id( $p_reporter_id ) { 92 return csv_escape_string( user_get_name( $p_reporter_id ) ); 93 } 94 95 # -------------------- 96 # returns the handler name corresponding to the supplied id 97 function csv_format_handler_id( $p_handler_id ) { 98 if ( $p_handler_id > 0 ) { 99 return csv_escape_string( user_get_name( $p_handler_id ) ); 100 } 101 } 102 103 # -------------------- 104 # return the priority string 105 function csv_format_priority( $p_priority ) { 106 return csv_escape_string( get_enum_element( 'priority', $p_priority ) ); 107 } 108 109 # -------------------- 110 # return the severity string 111 function csv_format_severity( $p_severity ) { 112 return csv_escape_string( get_enum_element( 'severity', $p_severity ) ); 113 } 114 115 # -------------------- 116 # return the reproducability string 117 function csv_format_reproducibility( $p_reproducibility ) { 118 return csv_escape_string( get_enum_element( 'reproducibility', $p_reproducibility ) ); 119 } 120 121 # -------------------- 122 # return the version 123 function csv_format_version( $p_version ) { 124 return csv_escape_string( $p_version ); 125 } 126 127 # -------------------- 128 # return the fixed_in_version 129 function csv_format_fixed_in_version( $p_fixed_in_version ) { 130 return csv_escape_string( $p_fixed_in_version ); 131 } 132 133 # -------------------- 134 # return the target_version 135 function csv_format_target_version( $p_target_version ) { 136 return csv_escape_string( $p_target_version ); 137 } 138 139 # -------------------- 140 # return the projection 141 function csv_format_projection( $p_projection ) { 142 return csv_escape_string( get_enum_element( 'projection', $p_projection ) ); 143 } 144 145 # -------------------- 146 # return the category 147 function csv_format_category( $p_category ) { 148 return csv_escape_string( $p_category ); 149 } 150 151 # -------------------- 152 # return the date submitted 153 function csv_format_date_submitted( $p_date_submitted ) { 154 return date( config_get( 'short_date_format' ), $p_date_submitted ); 155 } 156 157 # -------------------- 158 # return the eta 159 function csv_format_eta( $p_eta ) { 160 return csv_escape_string( get_enum_element( 'eta', $p_eta ) ); 161 } 162 163 # -------------------- 164 # return the operating system 165 function csv_format_os( $p_os ) { 166 return csv_escape_string( $p_os ); 167 } 168 169 # -------------------- 170 # return the os build (os version) 171 function csv_format_os_build( $p_os_build ) { 172 return csv_escape_string( $p_os_build ); 173 } 174 175 # -------------------- 176 # return the platform 177 function csv_format_platform( $p_platform ) { 178 return csv_escape_string( $p_platform ); 179 } 180 181 # -------------------- 182 # return the view state (eg: private / public) 183 function csv_format_view_state( $p_view_state ) { 184 return csv_escape_string( get_enum_element( 'view_state', $p_view_state ) ); 185 } 186 187 # -------------------- 188 # return the last updated date 189 function csv_format_last_updated( $p_last_updated ) { 190 return date( config_get( 'short_date_format' ), $p_last_updated ); 191 } 192 193 # -------------------- 194 # return the summary 195 function csv_format_summary( $p_summary ) { 196 return csv_escape_string( $p_summary ); 197 } 198 199 # -------------------- 200 # return the status string 201 function csv_format_status( $p_status ) { 202 return csv_escape_string( get_enum_element( 'status', $p_status ) ); 203 } 204 205 # -------------------- 206 # return the resolution string 207 function csv_format_resolution( $p_resolution ) { 208 return csv_escape_string( get_enum_element( 'resolution', $p_resolution ) ); 209 } 210 211 # -------------------- 212 # return the duplicate bug id 213 function csv_format_duplicate_id( $p_duplicate_id ) { 214 return bug_format_id( $p_duplicate_id ); 215 } 216 217 # -------------------- 218 # return the selection 219 function csv_format_selection( $p_duplicate_id ) { 220 return csv_escape_string( '' ); 221 } 222 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 09:42:17 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |