Changeset 17194
- Timestamp:
- 2008/04/01 10:11:46 (18 years ago)
- Location:
- branches/comu-ver2
- Files:
-
- 4 edited
- 1 copied
-
data/Smarty/templates/default/admin/products/subnavi.tpl (modified) (1 diff)
-
data/Smarty/templates/default/admin/products/upload_csv_category.tpl (modified) (3 props)
-
data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSVCategory.php (copied) (copied from branches/version-2/data/class/pages/admin/products/LC_Page_Admin_Products_UploadCSVCategory.php)
-
data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php (modified) (5 diffs)
-
html/admin/products/upload_csv_category.php (modified) (3 props)
Legend:
- Unmodified
- Added
- Removed
-
branches/comu-ver2/data/Smarty/templates/default/admin/products/subnavi.tpl
r17035 r17194 32 32 <tr><td class=<!--{if $tpl_subno != 'class'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./class.php" onMouseOver="naviStyleChange('class', '#a5a5a5')" <!--{if $tpl_subno != 'class'}-->onMouseOut="naviStyleChange('class', '#636469')"<!--{/if}--> id="class"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">規格管理</span></a></td></tr> 33 33 <tr><td><img src="<!--{$TPL_DIR}-->img/contents/navi_line.gif" width="140" height="2" alt=""></td></tr> 34 <tr><td class=<!--{if $tpl_subno != 'category'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./category.php" onMouseOver="naviStyleChange('category', '#a5a5a5')" <!--{if $tpl_subno != 'category'}-->onMouseOut="naviStyleChange('category', '#636469')"<!--{/if}--> id="category"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">カテゴリ ー管理</span></a></td></tr>34 <tr><td class=<!--{if $tpl_subno != 'category'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./category.php" onMouseOver="naviStyleChange('category', '#a5a5a5')" <!--{if $tpl_subno != 'category'}-->onMouseOut="naviStyleChange('category', '#636469')"<!--{/if}--> id="category"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">カテゴリ管理</span></a></td></tr> 35 35 <tr><td><img src="<!--{$TPL_DIR}-->img/contents/navi_line.gif" width="140" height="2" alt=""></td></tr> 36 <tr><td class=<!--{if $tpl_subno != 'upload_csv_category'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./upload_csv_category.php" onMouseOver="naviStyleChange('upload_csv_category', '#a5a5a5')" <!--{if $tpl_subno != 'upload_csv_category'}-->onMouseOut="naviStyleChange('upload_csv_category', '#636469')"<!--{/if}--> id="upload_csv_category"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">カテゴリ ーCSV</span></a></td></tr>37 <tr><td><img src="<!--{$TPL_DIR}-->img/contents/navi_line.gif" width="140" height="2" alt=""></td></tr>38 <tr><td class=<!--{if $tpl_subno != 'product_rank'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./product_rank.php" onMouseOver="naviStyleChange('product_rank', '#a5a5a5')" <!--{if $tpl_subno != 'product_rank'}-->onMouseOut="naviStyleChange('product_rank', '#636469')"<!--{/if}--> id="product_rank"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">商品並び替え</span></a></td></tr>36 <tr><td class=<!--{if $tpl_subno != 'upload_csv_category'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./upload_csv_category.php" onMouseOver="naviStyleChange('upload_csv_category', '#a5a5a5')" <!--{if $tpl_subno != 'upload_csv_category'}-->onMouseOut="naviStyleChange('upload_csv_category', '#636469')"<!--{/if}--> id="upload_csv_category"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">カテゴリ登録CSV</span></a></td></tr> 37 <tr><td><img src="<!--{$TPL_DIR}-->img/contents/navi_line.gif" width="140" height="2" alt=""></td></tr> 38 <tr><td class=<!--{if $tpl_subno != 'product_rank'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./product_rank.php" onMouseOver="naviStyleChange('product_rank', '#a5a5a5')" <!--{if $tpl_subno != 'product_rank'}-->onMouseOut="naviStyleChange('product_rank', '#636469')"<!--{/if}--> id="product_rank"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">商品並び替え</span></a></td></tr> 39 39 <tr><td><img src="<!--{$TPL_DIR}-->img/contents/navi_line.gif" width="140" height="2" alt=""></td></tr> 40 40 <tr><td class=<!--{if $tpl_subno != 'review'}-->"navi"<!--{else}-->"navi-on"<!--{/if}-->><a href="./review.php" onMouseOver="naviStyleChange('review', '#a5a5a5')" <!--{if $tpl_subno != 'review'}-->onMouseOut="naviStyleChange('review', '#636469')"<!--{/if}--> id="review"><img src="<!--{$TPL_DIR}-->img/contents/icon.jpg" width="15" height="9" alt="" border="0"><span class="navi_text">レビュー管理</span></a></td></tr> -
branches/comu-ver2/data/Smarty/templates/default/admin/products/upload_csv_category.tpl
- Property svn:eol-style set to LF
- Property svn:keywords set to Id
- Property svn:mime-type set to text/html
-
branches/comu-ver2/data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_UploadCSVCategory_Ex.php
r17035 r17194 1 1 <?php 2 /* 3 * This file is part of EC-CUBE 4 * 5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 6 * 7 * http://www.lockon.co.jp/ 8 * 9 * This program is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU General Public License 11 * as published by the Free Software Foundation; either version 2 12 * of the License, or (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 */ 2 23 3 24 // {{{ requires 4 require_once(CLASS_PATH . "pages/admin/products/LC_Page_Admin_Products_UploadCSV .php");25 require_once(CLASS_PATH . "pages/admin/products/LC_Page_Admin_Products_UploadCSVCategory.php"); 5 26 6 27 /** … … 13 34 * @version $$Id: LC_Page_Admin_Products_UploadCSV_Ex.php 16741 2007-11-08 00:43:24Z adachi $$ 14 35 */ 15 class LC_Page_Admin_Products_UploadCSVCategory_Ex extends LC_Page_Admin_Products_UploadCSV {36 class LC_Page_Admin_Products_UploadCSVCategory_Ex extends LC_Page_Admin_Products_UploadCSVCategory { 16 37 17 38 // }}} … … 25 46 function init() { 26 47 parent::init(); 27 $this->tpl_mainpage = 'products/upload_csv_category.tpl';28 $this->tpl_subnavi = 'products/subnavi.tpl';29 $this->tpl_mainno = 'products';30 $this->tpl_subno = 'upload_csv_category';31 48 } 32 49 … … 37 54 */ 38 55 function process() { 39 $conn = new SC_DBConn(); 40 $objView = new SC_AdminView(); 41 $objSess = new SC_Session(); 42 $objDb = new SC_Helper_DB_Ex(); 43 44 // 認証可否の判定 45 SC_Utils_Ex::sfIsSuccess($objSess); 46 47 // ファイル管理クラス 48 $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR); 49 // ファイル情報の初期化 50 $this->lfInitFile(); 51 // パラメータ管理クラス 52 $this->objFormParam = new SC_FormParam(); 53 // パラメータ情報の初期化 54 $this->lfInitParam(); 55 $colmax = $this->objFormParam->getCount(); 56 $this->objFormParam->setHtmlDispNameArray(); 57 $this->arrTitle = $this->objFormParam->getHtmlDispNameArray(); 58 59 if (!isset($_POST['mode'])) $_POST['mode'] = ""; 60 61 switch($_POST['mode']) { 62 case 'csv_upload': 63 $err = false; 64 // エラーチェック 65 $arrErr['csv_file'] = $this->objUpFile->makeTempFile('csv_file'); 66 67 if($arrErr['css_file'] == "") { 68 $arrErr = $this->objUpFile->checkEXISTS(); 69 } 70 71 // 実行時間を制限しない 72 set_time_limit(0); 73 74 // 出力をバッファリングしない(==日本語自動変換もしない) 75 ob_end_clean(); 76 77 // IEのために256バイト空文字出力 78 echo str_pad('',256); 79 80 if(empty($arrErr['csv_file'])) { 81 // 一時ファイル名の取得 82 $filepath = $this->objUpFile->getTempFilePath('csv_file'); 83 // エンコード 84 $enc_filepath = SC_Utils_Ex::sfEncodeFile($filepath, 85 CHAR_CODE, CSV_TEMP_DIR); 86 87 // レコード数を得る 88 $rec_count = $this->lfCSVRecordCount($enc_filepath); 89 90 $fp = fopen($enc_filepath, "r"); 91 $line = 0; // 行数 92 $regist = 0; // 登録数 93 94 $objQuery = new SC_Query(); 95 $objQuery->begin(); 96 97 echo "■ CSV登録進捗状況 <br/><br/>\n"; 98 99 while(!feof($fp) && !$err) { 100 $arrCSV = fgetcsv($fp, CSV_LINE_MAX); 101 102 // 行カウント 103 $line++; 104 105 if($line <= 1) { 106 continue; 107 } 108 109 // 項目数カウント 110 $max = count($arrCSV); 111 112 // 項目数が1以下の場合は無視する 113 if($max <= 1) { 114 continue; 115 } 116 117 // 項目数チェック 118 if($max != $colmax) { 119 echo "※ 項目数が" . $max . "個検出されました。項目数は" . $colmax . "個になります。</br>\n"; 120 $err = true; 121 } else { 122 // シーケンス配列を格納する。 123 $this->objFormParam->setParam($arrCSV, true); 124 $arrRet = $this->objFormParam->getHashArray(); 125 $this->objFormParam->setParam($arrRet); 126 // 入力値の変換 127 $this->objFormParam->convParam(); 128 // <br>なしでエラー取得する。 129 $arrCSVErr = $this->lfCheckError(); 130 } 131 132 // 入力エラーチェック 133 if(count($arrCSVErr) > 0) { 134 echo "<font color=\"red\">■" . $line . "行目でエラーが発生しました。</font></br>\n"; 135 foreach($arrCSVErr as $val) { 136 $this->printError($val); 137 } 138 $err = true; 139 } 140 141 if(!$err) { 142 $this->lfRegistProduct($objQuery, $line); 143 $regist++; 144 } 145 $arrParam = $this->objFormParam->getHashArray(); 146 147 if(!$err) echo $line." / ".$rec_count. "行目 (カテゴリID:".$arrParam['category_id']." / カテゴリ名:".$arrParam['category_name'].")\n<br />"; 148 flush(); 149 } 150 fclose($fp); 151 152 if(!$err) { 153 $objQuery->commit(); 154 echo "■" . $regist . "件のレコードを登録しました。"; 155 // カテゴリ件数カウント関数の実行 156 $objDb->sfCategory_Count($objQuery); 157 } else { 158 $objQuery->rollback(); 159 } 160 } else { 161 foreach($arrErr as $val) { 162 $this->printError($val); 163 } 164 } 165 echo "<br/><a href=\"javascript:window.close()\">→閉じる</a>"; 166 flush(); 167 exit; 168 break; 169 default: 170 break; 171 } 172 173 $objView->assignobj($this); 174 $objView->display(MAIN_FRAME); 56 parent::process(); 175 57 } 176 58 … … 183 65 parent::destroy(); 184 66 } 185 186 187 /**188 * ファイル情報の初期化を行う.189 *190 * @return void191 */192 function lfInitFile() {193 $this->objUpFile->addFile("CSVファイル", 'csv_file', array('csv'),194 CSV_SIZE, true, 0, 0, false);195 }196 197 /**198 * 入力情報の初期化を行う.199 *200 * @return void201 */202 function lfInitParam() {203 $this->objFormParam->addParam("カテゴリID","category_id",INT_LEN,"n",array("MAX_LENGTH_CHECK","NUM_CHECK"));204 $this->objFormParam->addParam("カテゴリ名","category_name",STEXT_LEN,"KVa",array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK"));205 $this->objFormParam->addParam("親カテゴリID","parent_category_id",INT_LEN,"n",array("MAX_LENGTH_CHECK","NUM_CHECK"));206 $this->objFormParam->addParam("階層","level",INT_LEN,"n",array("MAX_LENGTH_CHECK","NUM_CHECK"));207 $this->objFormParam->addParam("表示順","rank",INT_LEN,"n",array("MAX_LENGTH_CHECK","NUM_CHECK"));208 // $this->objFormParam->addParam("削除フラグ","del_flg",INT_LEN,"n",array());209 }210 211 /**212 * カテゴリ登録を行う.213 *214 * @param SC_Query $objQuery SC_Queryインスタンス215 * @param string|integer $line 処理中の行数216 * @return void217 */218 function lfRegistProduct($objQuery, $line = "") {219 $objDb = new SC_Helper_DB_Ex();220 $arrRet = $this->objFormParam->getHashArray();221 foreach($arrRet as $key => $val) {222 switch($key) {223 // case 'recommend_comment6':224 // break;225 default:226 if(!ereg("^dummy", $key)) {227 $sqlval[$key] = $val;228 }229 break;230 }231 }232 // 登録時間を生成(DBのnow()だとcommitした際、すべて同一の時間になってしまう)233 $time = date("Y-m-d H:i:s");234 // 秒以下を生成235 if($line != "") {236 $microtime = sprintf("%06d", $line);237 $time .= ".$microtime";238 }239 $sqlval['update_date'] = $time;240 $sqlval['creator_id'] = $_SESSION['member_id'];241 $count = $objQuery->count("dtb_category", "category_id = ?", array($arrRet['category_id']));242 if($count != 0) {243 // UPDATEの実行244 echo "UPDATEの実行";245 $where = "category_id = ?";246 $objQuery->update("dtb_category", $sqlval, $where, array($sqlval['category_id']));247 } else {248 // 新規登録249 $sqlval['category_id'] = $arrRet['category_id'];250 $sqlval['create_date'] = $time;251 if($arrRet['rank'] == ""){252 // カテゴリ内で最大のランクを割り当てる253 $sqlval['rank'] = $objQuery->max("dtb_category", "rank", "parent_category_id = ?", array($arrRet['parent_category_id'])) + 1;254 }255 // INSERTの実行256 $objQuery->insert("dtb_category", $sqlval);257 }258 }259 260 /**261 * 入力チェックを行う.262 *263 * @return void264 */265 function lfCheckError() {266 // 入力データを渡す。267 $arrRet = $this->objFormParam->getHashArray();268 $objErr = new SC_CheckError($arrRet);269 $objErr->arrErr = $this->objFormParam->checkError(false);270 if(count($objErr->arrErr) == 0) {271 $objQuery = new SC_Query();272 // 存在する親カテゴリIDかチェック273 if($arrRet['parent_category_id'] != 0){274 $count = $objQuery->count("dtb_category", "category_id = ?", array($arrRet['parent_category_id']));275 if($count == 0) {276 $objErr->arrErr['parent_category_id'] = "※ 指定の親カテゴリID(".$arrRet['parent_category_id'].")は、存在しません。";277 }278 }279 }280 return $objErr->arrErr;281 }282 283 /**284 * CSVのカウント数を得る.285 *286 * @param string $file_name ファイルパス287 * @return integer CSV のカウント数288 */289 function lfCSVRecordCount($file_name) {290 291 $count = 0;292 $fp = fopen($file_name, "r");293 while(!feof($fp)) {294 $arrCSV = fgetcsv($fp, CSV_LINE_MAX);295 $count++;296 }297 298 return $count-1;299 }300 301 /**302 * 引数の文字列をエラー出力する.303 *304 * 引数 $val の内容は, htmlspecialchars() によってサニタイズされ305 *306 * @param string $val 出力する文字列307 * @return void308 */309 function printError($val) {310 echo "<font color=\"red\">"311 . htmlspecialchars($val, ENT_QUOTES)312 . "</font></br>\n";313 }314 67 } 315 68 ?> -
branches/comu-ver2/html/admin/products/upload_csv_category.php
- Property svn:eol-style set to LF
- Property svn:keywords set to Id
- Property svn:mime-type set to text/x-httpd-php
Note: See TracChangeset
for help on using the changeset viewer.
