Ignore:
Timestamp:
2007/09/10 13:52:18 (17 years ago)
Author:
nanasess
Message:

クラス化に伴う修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/html/admin/contents/recommend.php

    r15532 r15660  
    55 * http://www.lockon.co.jp/ 
    66 */ 
    7  require_once("../require.php"); 
    87 
    9 class LC_Page { 
    10      
    11     function LC_Page() { 
    12         $this->tpl_mainpage = 'contents/recomend.tpl'; 
    13         $this->tpl_mainno = 'contents'; 
    14         $this->tpl_subnavi = 'contents/subnavi.tpl'; 
    15         $this->tpl_subno = "recommend"; 
    16         $this->tpl_subtitle = 'オススメ管理'; 
    17     } 
    18 } 
     8// {{{ requires 
     9require_once("../../require.php"); 
     10require_once(CLASS_PATH . "page_extends/admin/contents/LC_Page_Admin_Contents_Recommend_Ex.php"); 
    1911 
    20 $conn = new SC_DBConn(); 
    21 $objPage = new LC_Page(); 
    22 $objView = new SC_AdminView(); 
    23 $objSess = new SC_Session(); 
     12// }}} 
     13// {{{ generate page 
    2414 
    25 $arrRegistColumn = array( 
    26                              array(  "column" => "product_id", "convert" => "n" ), 
    27                              array(  "column" => "category_id", "convert" => "n" ), 
    28                              array(  "column" => "rank", "convert" => "n" ), 
    29                              array(  "column" => "title", "convert" => "aKV" ), 
    30                              array(  "column" => "comment", "convert" => "aKV" ), 
    31                         ); 
    32  
    33 // 認証可否の判定 
    34 sfIsSuccess($objSess); 
    35  
    36 //最大登録数の表示 
    37 $objPage->tpl_disp_max = RECOMMEND_NUM; 
    38  
    39 // 登録時 
    40 if ( $_POST['mode'] == 'regist' ){ 
    41          
    42     // 入力文字の強制変換 
    43     $objPage->arrForm = $_POST;  
    44     $objPage->arrForm = lfConvertParam($objPage->arrForm, $arrRegistColumn); 
    45     // エラーチェック 
    46     $objPage->arrErr[$objPage->arrForm['rank']] = lfErrorCheck(); 
    47     if ( ! $objPage->arrErr[$objPage->arrForm['rank']]) { 
    48         // 古いのを消す 
    49         $sql = "DELETE FROM dtb_best_products WHERE category_id = ? AND rank = ?"; 
    50         $conn->query($sql, array($objPage->arrForm['category_id'] ,$objPage->arrForm['rank'])); 
    51      
    52         // DB登録 
    53         $objPage->arrForm['creator_id'] = $_SESSION['member_id']; 
    54         $objPage->arrForm['update_date'] = "NOW()"; 
    55         $objPage->arrForm['create_date'] = "NOW()"; 
    56          
    57         $objQuery = new SC_Query(); 
    58         $objQuery->insert("dtb_best_products", $objPage->arrForm ); 
    59 //      $conn->autoExecute("dtb_best_products", $objPage->arrForm ); 
    60     }    
    61  
    62 } elseif ( $_POST['mode'] == 'delete' ){ 
    63 // 削除時 
    64  
    65     $sql = "DELETE FROM dtb_best_products WHERE category_id = ? AND rank = ?"; 
    66     $conn->query($sql, array($_POST['category_id'] ,$_POST['rank'])); 
    67      
    68 } 
    69  
    70 // カテゴリID取得 無いときはトップページ 
    71 if ( sfCheckNumLength($_POST['category_id']) ){ 
    72     $objPage->category_id = $_POST['category_id']; 
    73 } else { 
    74     $objPage->category_id = 0; 
    75 } 
    76  
    77 // 既に登録されている内容を取得する 
    78 $sql = "SELECT B.name, B.main_list_image, A.* FROM dtb_best_products as A INNER JOIN dtb_products as B USING (product_id) 
    79          WHERE A.del_flg = 0 ORDER BY rank"; 
    80 $arrItems = $conn->getAll($sql); 
    81 foreach( $arrItems as $data ){ 
    82     $objPage->arrItems[$data['rank']] = $data; 
    83 } 
    84  
    85 // 商品変更時は、選択された商品に一時的に置き換える 
    86 if ( $_POST['mode'] == 'set_item'){ 
    87     $sql = "SELECT product_id, name, main_list_image FROM dtb_products WHERE product_id = ? AND del_flg = 0"; 
    88     $result = $conn->getAll($sql, array($_POST['product_id'])); 
    89     if ( $result ){ 
    90         $data = $result[0]; 
    91         foreach( $data as $key=>$val){ 
    92             $objPage->arrItems[$_POST['rank']][$key] = $val; 
    93         } 
    94         $objPage->arrItems[$_POST['rank']]['rank'] = $_POST['rank']; 
    95     } 
    96     $objPage->checkRank = $_POST['rank']; 
    97 } 
    98  
    99 //各ページ共通 
    100 $objPage->cnt_question = 6; 
    101 $objPage->arrActive = $arrActive; 
    102 $objPage->arrQuestion = $arrQuestion; 
    103  
    104 // カテゴリ取得 
    105 $objPage->arrCatList = sfGetCategoryList("level = 1"); 
    106  
    107 //---- ページ表示 
    108 $objView->assignobj($objPage); 
    109 $objView->display(MAIN_FRAME); 
    110  
    111  
    112 //--------------------------------------------------------------------------------------------------------------------------------------------------------- 
    113 //---- 取得文字列の変換 
    114 function lfConvertParam($array, $arrRegistColumn) { 
    115  
    116     // カラム名とコンバート情報 
    117     foreach ($arrRegistColumn as $data) { 
    118         $arrConvList[ $data["column"] ] = $data["convert"]; 
    119     } 
    120     // 文字変換 
    121     $new_array = array(); 
    122     foreach ($arrConvList as $key => $val) { 
    123         $new_array[$key] = $array[$key]; 
    124         if( strlen($val) > 0) { 
    125             $new_array[$key] = mb_convert_kana($new_array[$key] ,$val); 
    126         } 
    127     } 
    128     return $new_array; 
    129      
    130 } 
    131  
    132 /* 入力エラーチェック */ 
    133 function lfErrorCheck() { 
    134     $objQuery = new SC_Query; 
    135     $objErr = new SC_CheckError(); 
    136      
    137     $objErr->doFunc(array("見出しコメント", "title", STEXT_LEN), array("MAX_LENGTH_CHECK")); 
    138     $objErr->doFunc(array("オススメコメント", "comment", LTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); 
    139      
    140     return $objErr->arrErr; 
    141 } 
    142  
     15$objPage = new LC_Page_Admin_Contents_Recommend_Ex(); 
     16$objPage->init(); 
     17$objPage->process(); 
     18register_shutdown_function(array($objPage, "destroy")); 
    14319?> 
Note: See TracChangeset for help on using the changeset viewer.