00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php5 based project management system (c) 2005-2007 / www.streber-pm.org
00003 # Distributed under the terms and conditions of the GPL as stated in lang/license.html
00004
00015 function exportToCSV($header, $content)
00016 {
00017 global $PH;
00018 $pagename= $PH->cur_page_id;
00019
00020 #header('Content-Type: text/plain');
00021 header('Content-Type: text/csv; charset=utf-8');
00022 #header('Content-Type: text/csv; charset=iso-8859-15');
00023 header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
00024 header('Content-Disposition: attachment; filename=' . $pagename . '.csv');
00025 header('Pragma: no-cache');
00026
00027 $export = "";
00028 $num_col = count($header);
00029 $len = count($content);
00030
00031 ## build export-string ##
00032 foreach($header as $key => $value){
00033 $str = $value;
00034 $str = iconv("utf-8", "iso-8859-15//TRANSLIT", $str);
00035 $export .= "" . $str . ";";
00036 }
00037
00038 $export .= "\r\n";
00039
00040 for($i = 1; $i < $len; $i++)
00041 {
00042 if(fmod($i, $num_col) == 0){
00043 $str = $content[$i-1];
00044 $str = iconv("utf-8", "iso-8859-15//TRANSLIT", $str);
00045 $export .= "" . $str . ";\r\n";
00046 }
00047 else{
00048 $str = $content[$i-1];
00049 $str = iconv("utf-8", "iso-8859-15//TRANSLIT", $str);
00050 $export .= "" . $str . ";";
00051 }
00052 }
00053
00054 $export .= "\r\n";
00055
00056
00057 echo $export;
00058 }
00059
00060 ?>