[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/ -> csv_export.php (source)

   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_export.php,v 1.26.2.1 2007-10-13 22:33:14 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      require_once ( 'core.php' );
  26  
  27      $t_core_path = config_get( 'core_path' );
  28  
  29      require_once( $t_core_path . 'filter_api.php' );
  30      require_once( $t_core_path . 'csv_api.php' );
  31      require_once( $t_core_path . 'columns_api.php' );
  32  ?>
  33  <?php auth_ensure_user_authenticated() ?>
  34  <?php
  35      helper_begin_long_process();
  36  
  37      $t_page_number = 1;
  38      $t_per_page = -1;
  39      $t_bug_count = null;
  40      $t_page_count = null;
  41  
  42      $t_nl = csv_get_newline();
  43       $t_sep = csv_get_separator();
  44  
  45      # Get bug rows according to the current filter
  46      $t_rows = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count );
  47      if ( $t_rows === false ) {
  48          print_header_redirect( 'view_all_set.php?type=0' );
  49      }
  50  
  51      $t_filename = csv_get_default_filename();
  52  
  53      # Send headers to browser to activate mime loading
  54  
  55      # Make sure that IE can download the attachments under https.
  56      header( 'Pragma: public' );
  57  
  58      header( 'Content-Type: text/plain; name=' . urlencode( $t_filename ) );
  59      header( 'Content-Transfer-Encoding: BASE64;' );
  60  
  61      # Added Quotes (") around file name.
  62      header( 'Content-Disposition: attachment; filename="' . urlencode( $t_filename ) . '"' );
  63  
  64      # Get columns to be exported
  65      $t_columns = csv_get_columns();
  66  
  67      # export the titles
  68      $t_first_column = true;
  69      ob_start();
  70      $t_titles = array();
  71      foreach ( $t_columns as $t_column ) {
  72          if ( !$t_first_column ) {
  73              echo $t_sep;
  74          } else {
  75              $t_first_column = false;
  76          }
  77  
  78          if ( strpos( $t_column, 'custom_' ) === 0 ) {
  79              $t_column_title_function = 'print_column_title';
  80              helper_call_custom_function( $t_column_title_function, array( $t_column, COLUMNS_TARGET_CSV_PAGE ) );
  81          } else {
  82              $t_function = 'print_column_title_' . $t_column;
  83              $t_function( '', 'ASC', COLUMNS_TARGET_CSV_PAGE );
  84          }
  85      }
  86  
  87      echo $t_nl;
  88  
  89      $t_header = ob_get_clean();
  90  
  91      # Fixed for a problem in Excel where it prompts error message "SYLK: File Format Is Not Valid"
  92      # See Microsoft Knowledge Base Article - 323626
  93      # http://support.microsoft.com/default.aspx?scid=kb;en-us;323626&Product=xlw
  94      $t_first_three_chars = substr( $t_header, 0, 3 );
  95      if ( strcmp( $t_first_three_chars, 'ID' . $t_sep ) == 0 ) {
  96          $t_header = str_replace( 'ID' . $t_sep, 'Id' . $t_sep, $t_header );
  97      }
  98      # end of fix
  99  
 100      echo $t_header;
 101  
 102      # export the rows
 103      foreach ( $t_rows as $t_row ) {
 104          $t_first_column = true;
 105  
 106          foreach ( $t_columns as $t_column ) {
 107              if ( !$t_first_column ) {
 108                  echo $t_sep;
 109              } else {
 110                  $t_first_column = false;
 111              }
 112  
 113              if ( strpos( $t_column, 'custom_' ) === 0 ) {
 114                  ob_start();
 115                  $t_column_value_function = 'print_column_value';
 116                  helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row, COLUMNS_TARGET_CSV_PAGE ) );
 117                  $t_value = ob_get_clean();
 118  
 119                  if ( strstr( $t_value, $t_sep ) !== false ) {
 120                      $t_value = '"' . $t_value . '"';
 121                  }
 122  
 123                  echo $t_value;
 124              } else {
 125                  $t_function = 'csv_format_' . $t_column;
 126                  echo $t_function( $t_row[ $t_column ] );
 127              }
 128          }
 129  
 130          echo $t_nl;
 131      }
 132  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics