- Timestamp:
- 2013/05/02 18:11:36 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/helper/SC_Helper_CSV.php
r22567 r22796 13 13 * @version $Id$ 14 14 */ 15 class SC_Helper_CSV 16 { 15 class SC_Helper_CSV { 17 16 18 17 // {{{ properties … … 30 29 * デフォルトコンストラクタ. 31 30 */ 32 function __construct() 33 { 31 function __construct() { 34 32 $this->init(); 35 33 } … … 44 42 * @return void 45 43 */ 46 function init() 47 { 44 function init() { 48 45 $this->arrSubnavi = array( 49 46 1 => 'product', … … 73 70 * @return mixed $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string 74 71 */ 75 function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false) 76 { 72 function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false) { 77 73 // CSV出力タイトル行の作成 78 74 $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE)); … … 104 100 $sql = 'SELECT ' . $cols . ' FROM dtb_category ' . $where; 105 101 } 106 // 「getSqlを使っているcsv_id=1」以外で「order指定」がある場合は末尾に付与107 // 全csv_idでgetSqlを使用して生成するよう統一する場合は当メソッドの呼び元も要修正108 $sql = ($csv_id != '1' && strlen($order) >= 1) ? $sql.' order by '.$order : $sql;109 102 // 固有処理ここまで 110 103 return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download); … … 120 113 * @return array CSV 項目の配列 121 114 */ 122 function sfGetCsvOutput($csv_id = '', $where = '', $arrVal = array(), $order = 'rank, no') 123 { 115 function sfGetCsvOutput($csv_id = '', $where = '', $arrVal = array(), $order = 'rank, no') { 124 116 $objQuery =& SC_Query_Ex::getSingletonInstance(); 125 117 … … 147 139 * @return boolean true:インポート可能、false:インポート不可 148 140 */ 149 function sfIsImportCSVFrame(&$arrCSVFrame) 150 { 141 function sfIsImportCSVFrame(&$arrCSVFrame) { 151 142 $result = true; 152 143 foreach ($arrCSVFrame as $val) { … … 169 160 * @return boolean true:更新可能、false:新規追加のみ不可 170 161 */ 171 function sfIsUpdateCSVFrame(&$arrCSVFrame) 172 { 162 function sfIsUpdateCSVFrame(&$arrCSVFrame) { 173 163 $result = true; 174 164 foreach ($arrCSVFrame as $val) { … … 189 179 * @return integer CSV のカウント数 190 180 */ 191 function sfGetCSVRecordCount($fp) 192 { 181 function sfGetCSVRecordCount($fp) { 193 182 $count = 0; 194 183 while (!feof($fp)) { … … 210 199 * @return boolean true (true:固定 false:中断) 211 200 */ 212 function cbOutputCSV($data) 213 { 201 function cbOutputCSV($data) { 214 202 $line = $this->sfArrayToCSV($data); 215 203 $line = mb_convert_encoding($line, 'SJIS-Win'); … … 230 218 * @return mixed $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string 231 219 */ 232 function sfDownloadCsvFromSql($sql, $arrVal = array(), $file_head = 'csv', $arrHeader = array(), $is_download = false) 233 { 220 function sfDownloadCsvFromSql($sql, $arrVal = array(), $file_head = 'csv', $arrHeader = array(), $is_download = false) { 234 221 $objQuery =& SC_Query_Ex::getSingletonInstance(); 235 222 … … 275 262 * @return string 結果行 276 263 */ 277 function sfArrayToCsv($fields, $delimiter = ',', $enclosure = '"', $arrayDelimiter = '|') 278 { 264 function sfArrayToCsv($fields, $delimiter = ',', $enclosure = '"', $arrayDelimiter = '|') { 279 265 if (strlen($delimiter) != 1) { 280 266 trigger_error('delimiter must be a single character', E_USER_WARNING); … … 313 299 * @return void 314 300 */ 315 function lfDownloadCsv($arrData, $prefix = '') 316 { 301 function lfDownloadCsv($arrData, $prefix = '') { 317 302 318 303 if ($prefix == '') { … … 344 329 * @return void 345 330 */ 346 function lfDownloadCSVFile($filepath, $prefix = '') 347 { 331 function lfDownloadCSVFile($filepath, $prefix = '') { 348 332 $file_name = $prefix . date('YmdHis') . '.csv'; 349 333
Note: See TracChangeset
for help on using the changeset viewer.