JetTableAllClasses
Current view: C:\xampp\htdocs\table\jettable\JetCsvDownload.class.php
Date: Fri Dec 1 17:20:38 JST 2006 Executable lines: 20
Code covered: 10.00% Executed lines: 2
Legend: executed not executed dead code


       1                 : <?php                                                                             
       2                 : require_once "JetPlugin.class.php";                                               
       3                 :                                                                                   
       4                 : /**                                                                               
       5                 :  * CSVダウンロードリンク出力<br>                                                  
       6                 :  * テーブルの内容をCSVファイルとして出力するためのプラグイン。                    
       7                 :  *                                                                                
       8                 :  * @package    jettable.framework                                                 
       9                 :  * @author     rds <tk@rasign.jp>                                                 
      10                 :  * @license     http://www.opensource.org/licenses/mit-license.php The MIT License
      11                 :  * @version    $Revision: 1.4 $ $Date: 2006/12/01 13:41:52 $                      
      12                 :  * @link       http://jettable.rasign.jp/                                         
      13                 :  */                                                                               
      14                 : class JetCsvDownload extends JetPlugin{                                           
      15                 :     public function __construct(){                                                   
      16               4 :         $this->key = "csv";                                                             
      17               4 :     }                                                                                
      18                 :                                                                                   
      19                 :     public function action($header, $records){                                       
      20               0 :         $headerString = implode("\",\"", $header);                                      
      21               0 :         $headerString = "\"" . $headerString . "\"";                                    
      22               0 :         $contents = $headerString;                                                      
      23               0 :         $contents .= "\r\n";                                                            
      24                 :                                                                                   
      25               0 :         foreach($records as $record){                                                   
      26               0 :             $recordArray = array();                                                        
      27               0 :             foreach($header as $headerKey=>$headerValue){                                  
      28               0 :                 $recordArray[] = $record[$headerKey];                                         
      29               0 :             }                                                                              
      30               0 :             $recordString = implode("\",\"", $recordArray);                                
      31               0 :             $recordString = "\"" . $recordString . "\"";                                   
      32               0 :             $contents .= $recordString;                                                    
      33               0 :             $contents .= "\r\n";                                                           
      34               0 :         }                                                                               
      35                 :                                                                                   
      36               0 :         Header("Content-disposition: attachment; filename=list.csv");                   
      37               0 :         Header("Content-type: application/octet-stream; name=list.csv");             
      38               0 :         print $contents;                                                                
      39                 :                                                                                   
      40               0 :         die();                                                                          
      41                 :     }                                                                                
      42                 : }                                                                                 
      43                 : ?>                                                                                

Generated by: PHPUnit 3.0.0 and Xdebug 2.0.0RC1.