Changeset 21579


Ignore:
Timestamp:
2012/03/03 15:42:05 (12 years ago)
Author:
Seasoft
Message:

#1607 (未使用定義の削除)

  • 未使用メソッド削除
    • GC_Utils#gfDownloadCsv
    • GC_Utils#gfSetCsv
    • GC_Utils#gfGetAge
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/util/GC_Utils.php

    r21516 r21579  
    3030 */ 
    3131class GC_Utils { 
    32  
    33     /*---------------------------------------------------------------------- 
    34      * [名称] gfDownloadCsv 
    35      * [概要] 引数データをCSVとして、クライアントにダウンロードさせる 
    36      * [引数] 1:ヘッダ文字列 2:CSVデータ 
    37      * [戻値] - 
    38      * [依存] - 
    39      * [注釈] 引数は1,2ともカンマ区切りになっていること 
    40      *----------------------------------------------------------------------*/ 
    41     function gfDownloadCsv($header, $contents) { 
    42  
    43         $fiest_name = date('YmdHis') .'.csv'; 
    44  
    45         /* HTTPヘッダの出力 */ 
    46         Header("Content-disposition: attachment; filename=${fiest_name}"); 
    47         Header("Content-type: application/octet-stream; name=${fiest_name}"); 
    48  
    49         $return = $header.$contents; 
    50         if (mb_detect_encoding($return) == CHAR_CODE) { 
    51             // 文字コード変換 
    52             $return = mb_convert_encoding($return,'SJIS',CHAR_CODE); 
    53             // 改行方法の統一 
    54             $return = str_replace( array("\r\n", "\r"), "\n", $return); 
    55         } 
    56         echo $return; 
    57     } 
    58  
    59     /*---------------------------------------------------------------------- 
    60      * [名称] gfSetCsv 
    61      * [概要] 引数の配列をCSV形式に変換する 
    62      * [引数] 1:CSVにする配列 2:引数1が連想配列時の添え字を指定した配列 
    63      * [戻値] CSVデータ 
    64      * [依存] - 
    65      * [注釈] - 
    66      *----------------------------------------------------------------------*/ 
    67     function gfSetCsv($array, $arrayIndex = '') { 
    68         //引数$arrayIndexは、$arrayが連想配列のときに添え字を指定してやるために使用する 
    69  
    70         $return = ''; 
    71         for ($i=0; $i<count($array); $i++) { 
    72  
    73             for ($j=0; $j<count($array[$i]); $j++) { 
    74                 if ($j > 0) $return .= ','; 
    75                 $return .= "\""; 
    76                 if ($arrayIndex) { 
    77                     $return .= mb_ereg_replace('<','<',mb_ereg_replace("\"","\"\"",$array[$i][$arrayIndex[$j]])) ."\""; 
    78                 } else { 
    79                     $return .= mb_ereg_replace('<','<',mb_ereg_replace("\"","\"\"",$array[$i][$j])) ."\""; 
    80                 } 
    81             } 
    82             $return .= "\n"; 
    83         } 
    84  
    85         return $return; 
    86     } 
    87  
    88     /*---------------------------------------------------------------------- 
    89      * [名称] gfGetAge 
    90      * [概要] 日付より年齢を計算する。 
    91      * [引数] 1:日付文字列(yyyy/mm/dd、yyyy-mm-dd hh:mm:ss等) 
    92      * [戻値] 年齢の数値 
    93      * [依存] - 
    94      * [注釈] - 
    95      *----------------------------------------------------------------------*/ 
    96     function gfGetAge($dbdate) { 
    97         $ty = date('Y'); 
    98         $tm = date('m'); 
    99         $td = date('d'); 
    100         list($by, $bm, $bd) = preg_split('/[-/ ]/', $dbdate); 
    101         $age = $ty - $by; 
    102         if($tm * 100 + $td < $bm * 100 + $bd) $age--; 
    103         return $age; 
    104     } 
    10532 
    10633    /** 
Note: See TracChangeset for help on using the changeset viewer.