Changeset 15173 for branches/feature-module-update/html
- Timestamp:
- 2007/08/03 20:25:11 (17 years ago)
- Location:
- branches/feature-module-update/html/products
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update/html/products/review.php
r15080 r15173 5 5 * http://www.lockon.co.jp/ 6 6 */ 7 8 // {{{ requires 7 9 require_once("../require.php"); 10 require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_Review_Ex.php"); 8 11 9 class LC_Page { 10 function LC_Page() { 11 $this->tpl_mainpage = 'products/review.tpl'; 12 global $arrRECOMMEND; 13 $this->arrRECOMMEND = $arrRECOMMEND; 14 global $arrSex; 15 $this->arrSex = $arrSex; 16 } 17 } 12 // }}} 13 // {{{ generate page 18 14 19 $objPage = new LC_Page(); 20 $objView = new SC_SiteView(); 21 $objQuery = new SC_Query(); 22 23 //---- 登録用カラム配列 24 $arrRegistColumn = array( 25 array( "column" => "review_id", "convert" => "aKV" ), 26 array( "column" => "product_id", "convert" => "aKV" ), 27 array( "column" => "reviewer_name", "convert" => "aKV" ), 28 array( "column" => "reviewer_url", "convert" => "a"), 29 array( "column" => "sex", "convert" => "n" ), 30 array( "column" => "email", "convert" => "a" ), 31 array( "column" => "recommend_level", "convert" => "n" ), 32 array( "column" => "title", "convert" => "aKV" ), 33 array( "column" => "comment", "convert" => "aKV" ), 34 35 ); 36 switch ($_POST['mode']){ 37 case 'confirm': 38 $arrForm = lfConvertParam($_POST, $arrRegistColumn); 39 $objPage->arrErr = lfErrorCheck($arrForm); 40 //重複メッセージの判定 41 $flag = $objQuery->count("dtb_review","product_id = ? AND title = ? ", array($arrForm['product_id'], $arrForm['title'])); 42 43 if ($flag > 0){ 44 $objPage->arrErr['title'] .= "重複したタイトルは登録できません。"; 45 } 46 47 //エラーチェック 48 if($objPage->arrErr == ""){ 49 //重複タイトルでない 50 if($flag == 0){ 51 //商品名の取得 52 $arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($arrForm['product_id'])); 53 $objPage->arrForm = $arrForm; 54 $objPage->tpl_mainpage = 'products/review_confirm.tpl'; 55 } 56 } else { 57 //商品名の取得 58 $arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($arrForm['product_id'])); 59 $objPage->arrForm = $arrForm; 60 } 61 break; 62 63 case 'return': 64 foreach($_POST as $key => $val){ 65 $objPage->arrForm[ $key ] = $val; 66 } 67 68 //商品名の取得 69 $objPage->arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($objPage->arrForm['product_id'])); 70 if(empty($objPage->arrForm['name'])) { 71 sfDispSiteError(PAGE_ERROR); 72 } 73 break; 74 75 case 'complete': 76 $arrForm = lfConvertParam($_POST, $arrRegistColumn); 77 $arrErr = lfErrorCheck($arrForm); 78 //重複メッセージの判定 79 $flag = $objQuery->count("dtb_review","product_id = ? AND title = ? ", array($arrForm['product_id'], $arrForm['title'])); 80 //エラーチェック 81 if ($arrErr == ""){ 82 //重複タイトルでない 83 if($flag == 0) { 84 //登録実行 85 lfRegistRecommendData($arrForm, $arrRegistColumn); 86 //レビュー書き込み完了ページへ 87 header("Location: ./review_complete.php"); 88 exit; 89 } 90 } else { 91 if($flag > 0) { 92 sfDispSiteError(PAGE_ERROR); 93 } 94 } 95 break; 96 97 default: 98 if(sfIsInt($_GET['product_id'])) { 99 //商品情報の取得 100 $arrForm = $objQuery->select("product_id, name", "dtb_products", "del_flg = 0 AND status = 1 AND product_id=?", array($_GET['product_id'])); 101 if(empty($arrForm)) { 102 sfDispSiteError(PAGE_ERROR); 103 } 104 $objPage->arrForm = $arrForm[0]; 105 } 106 break; 107 108 } 109 110 $objView->assignobj($objPage); 111 $objView->display($objPage->tpl_mainpage); 112 113 //----------------------------------------------------------------------------------------------------------------------------------- 114 115 116 //エラーチェック 117 118 function lfErrorCheck() { 119 $objErr = new SC_CheckError(); 120 $objErr->doFunc(array("商品ID", "product_id", INT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK")); 121 $objErr->doFunc(array("投稿者名", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 122 $objErr->doFunc(array("URL", "reviewer_url", MTEXT_LEN), array("MAX_LENGTH_CHECK", "URL_CHECK")); 123 $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK")); 124 $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 125 $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); 126 127 if (REVIEW_ALLOW_URL == false) { 128 // コメント欄へのURLの入力を禁止 129 global $arrReviewDenyURL; 130 $objErr->doFunc(array("URL", "comment", $arrReviewDenyURL), array("PROHIBITED_STR_CHECK")); 131 } 132 133 return $objErr->arrErr; 134 } 135 136 //---- 取得文字列の変換 137 function lfConvertParam($array, $arrRegistColumn) { 138 /* 139 * 文字列の変換 140 * K : 「半角(ハンカク)片仮名」を「全角片仮名」に変換 141 * C : 「全角ひら仮名」を「全角かた仮名」に変換 142 * V : 濁点付きの文字を一文字に変換。"K","H"と共に使用します 143 * n : 「全角」数字を「半角(ハンカク)」に変換 144 * a : 全角英数字を半角英数字に変換する 145 */ 146 // カラム名とコンバート情報 147 foreach ($arrRegistColumn as $data) { 148 $arrConvList[ $data["column"] ] = $data["convert"]; 149 } 150 // 文字変換 151 foreach ($arrConvList as $key => $val) { 152 // POSTされてきた値のみ変換する。 153 if(strlen(($array[$key])) > 0) { 154 $array[$key] = mb_convert_kana($array[$key] ,$val); 155 } 156 } 157 return $array; 158 } 159 160 //登録実行 161 function lfRegistRecommendData ($array, $arrRegistColumn) { 162 global $objQuery; 163 164 // 仮登録 165 foreach ($arrRegistColumn as $data) { 166 if (strlen($array[ $data["column"] ]) > 0 ) { 167 $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; 168 } 169 } 170 $arrRegist['create_date'] = 'now()'; 171 $arrRegist['update_date'] = 'now()'; 172 $arrRegist['creator_id'] = '0'; 173 //-- 登録実行 174 $objQuery->begin(); 175 $objQuery->insert("dtb_review", $arrRegist); 176 $objQuery->commit(); 177 } 178 15 $objPage = new LC_Page_Products_Review_Ex(); 16 $objPage->init(); 17 $objPage->process(); 18 register_shutdown_function(array($objPage, "destroy")); 179 19 ?> -
branches/feature-module-update/html/products/review_complete.php
r15080 r15173 5 5 * http://www.lockon.co.jp/ 6 6 */ 7 // {{{ requires 8 require_once("../require.php"); 9 require_once(CLASS_PATH . "page_extends/products/LC_Page_Products_ReviewComplete_Ex.php"); 7 10 8 require_once("../require.php"); 11 // }}} 12 // {{{ generate page 9 13 10 class LC_Page { 11 function LC_Page() { 12 $this->tpl_mainpage = 'products/review_complete.tpl'; 13 } 14 } 15 16 $objPage = new LC_Page(); 17 $objView = new SC_SiteView(); 18 19 $objView->assignobj($objPage); 20 $objView->display($objPage->tpl_mainpage); 21 14 $objPage = new LC_Page_Products_ReviewComplete_Ex(); 15 $objPage->init(); 16 $objPage->process(); 17 register_shutdown_function(array($objPage, "destroy")); 22 18 ?>
Note: See TracChangeset
for help on using the changeset viewer.