Ignore:
Timestamp:
2007/07/20 15:58:59 (17 years ago)
Author:
nanasess
Message:

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
Location:
branches/feature-module-update
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update

    • Property svn:ignore set to
      .cache

      .settings

      .projectOptions
  • branches/feature-module-update/html/admin/products/category.php

    r12157 r15078  
    1414        $this->tpl_subno = 'category'; 
    1515        $this->tpl_onload = " fnSetFocus('category_name'); "; 
    16         $this->tpl_subtitle = '¥«¥Æ¥´¥ê¡¼ÅÐÏ¿'; 
     16        $this->tpl_subtitle = 'カテゴリー登録'; 
    1717    } 
    1818} 
     
    2323$objSess = new SC_Session(); 
    2424 
    25 // ǧ¾Ú²ÄÈݤÎȽÄê 
     25// 認証可否の判定 
    2626sfIsSuccess($objSess); 
    2727 
    28 // ¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹ 
     28// パラメータ管理クラス 
    2929$objFormParam = new SC_FormParam(); 
    30 // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ 
     30// パラメータ情報の初期化 
    3131lfInitParam(); 
    32 // POSTÃͤμèÆÀ 
     32// POST値の取得 
    3333$objFormParam->setParam($_POST); 
    3434 
    35 // Ä̾ï»þ¤Ï¿Æ¥«¥Æ¥´¥ê¤ò0¤ËÀßÄꤹ¤ë¡£ 
     35// 通常時は親カテゴリを0に設定する。 
    3636$objPage->arrForm['parent_category_id'] = $_POST['parent_category_id']; 
    3737 
     
    4949                lfInsertCat($_POST['parent_category_id']); 
    5050            } else { 
    51                 print("¥«¥Æ¥´¥ê¤ÎÅÐÏ¿ºÇÂç¿ô¤òĶ¤¨¤Þ¤·¤¿¡£"); 
     51                print("カテゴリの登録最大数を超えました。"); 
    5252            } 
    5353        } else { 
     
    6060    break; 
    6161case 'pre_edit': 
    62     // ÊÔ½¸¹àÌܤΥ«¥Æ¥´¥ê̾¤òDB¤è¤ê¼èÆÀ¤¹¤ë¡£ 
     62    // 編集項目のカテゴリ名をDBより取得する。 
    6363    $oquery = new SC_Query(); 
    6464    $where = "category_id = ?"; 
    6565    $cat_name = $oquery->get("dtb_category", "category_name", $where, array($_POST['category_id'])); 
    66     // ÆþÎϹàÌܤ˥«¥Æ¥´¥ê̾¤òÆþÎϤ¹¤ë¡£ 
     66    // 入力項目にカテゴリ名を入力する。 
    6767    $objPage->arrForm['category_name'] = $cat_name; 
    68     // POST¥Ç¡¼¥¿¤ò°ú¤­·Ñ¤° 
     68    // POSTデータを引き継ぐ 
    6969    $objPage->arrForm['category_id'] = $_POST['category_id']; 
    7070    break; 
    7171case 'delete': 
    7272    $objQuery = new SC_Query(); 
    73     // »Ò¥«¥Æ¥´¥ê¤Î¥Á¥§¥Ã¥¯ 
     73    // 子カテゴリのチェック 
    7474    $where = "parent_category_id = ? AND del_flg = 0"; 
    7575    $count = $objQuery->count("dtb_category", $where, array($_POST['category_id'])); 
    7676    if($count != 0) { 
    77         $objPage->arrErr['category_name'] = "¢¨ »Ò¥«¥Æ¥´¥ê¤¬Â¸ºß¤¹¤ë¤¿¤áºï½ü¤Ç¤­¤Þ¤»¤ó¡£<br>"; 
    78     } 
    79     // ÅÐÏ¿¾¦ÉʤΥÁ¥§¥Ã¥¯ 
     77        $objPage->arrErr['category_name'] = "※ 子カテゴリが存在するため削除できません。<br>"; 
     78    } 
     79    // 登録商品のチェック 
    8080    $where = "category_id = ? AND del_flg = 0"; 
    8181    $count = $objQuery->count("dtb_products", $where, array($_POST['category_id'])); 
    8282    if($count != 0) { 
    83         $objPage->arrErr['category_name'] = "¢¨ ¥«¥Æ¥´¥êÆâ¤Ë¾¦Éʤ¬Â¸ºß¤¹¤ë¤¿¤áºï½ü¤Ç¤­¤Þ¤»¤ó¡£<br>"; 
     83        $objPage->arrErr['category_name'] = "※ カテゴリ内に商品が存在するため削除できません。<br>"; 
    8484    }    
    8585     
    8686    if(!isset($objPage->arrErr['category_name'])) { 
    87         // ¥é¥ó¥¯ÉÕ¤­¥ì¥³¡¼¥É¤Îºï½ü(¢¨½èÍýÉé²Ù¤ò¹Íθ¤·¤Æ¥ì¥³¡¼¥É¤´¤Èºï½ü¤¹¤ë¡£) 
     87        // ランク付きレコードの削除(※処理負荷を考慮してレコードごと削除する。) 
    8888        sfDeleteRankRecord("dtb_category", "category_id", $_POST['category_id'], "", true); 
    8989    } 
     
    9494    $up_id = lfGetUpRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 
    9595    if($up_id != "") { 
    96         // ¾å¤Î¥°¥ë¡¼¥×¤Îrank¤«¤é¸º»»¤¹¤ë¿ô 
     96        // 上のグループのrankから減算する数 
    9797        $my_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 
    98         // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Îrank¤Ë²Ã»»¤¹¤ë¿ô 
     98        // 自分のグループのrankに加算する数 
    9999        $up_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id); 
    100100        if($my_count > 0 && $up_count > 0) { 
    101             // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Ë²Ã»» 
     101            // 自分のグループに加算 
    102102            lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $up_count); 
    103             // ¾å¤Î¥°¥ë¡¼¥×¤«¤é¸º»» 
     103            // 上のグループから減算 
    104104            lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $up_id, $my_count); 
    105105        } 
     
    112112    $down_id = lfGetDownRankID($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 
    113113    if($down_id != "") { 
    114         // ²¼¤Î¥°¥ë¡¼¥×¤Îrank¤Ë²Ã»»¤¹¤ë¿ô 
     114        // 下のグループのrankに加算する数 
    115115        $my_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id']); 
    116         // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤Îrank¤«¤é¸º»»¤¹¤ë¿ô 
     116        // 自分のグループのrankから減算する数 
    117117        $down_count = lfCountChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id); 
    118118        if($my_count > 0 && $down_count > 0) { 
    119             // ¼«Ê¬¤Î¥°¥ë¡¼¥×¤«¤é¸º»» 
     119            // 自分のグループから減算 
    120120            lfUpRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $down_id, $my_count); 
    121             // ²¼¤Î¥°¥ë¡¼¥×¤Ë²Ã»» 
     121            // 下のグループに加算 
    122122            lfDownRankChilds($objQuery, "dtb_category", "parent_category_id", "category_id", $_POST['category_id'], $down_count); 
    123123        } 
     
    139139//----------------------------------------------------------------------------------------------------------------------------------- 
    140140 
    141 // ¥«¥Æ¥´¥ê¤Î¿·µ¬Äɲà
     141// カテゴリの新規追加 
    142142function lfInsertCat($parent_category_id) { 
    143143    global $objFormParam; 
    144144     
    145145    $objQuery = new SC_Query(); 
    146     $objQuery->begin(); // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î³«»Ï 
     146    $objQuery->begin(); // トランザクションの開始 
    147147     
    148148     
    149149    if($parent_category_id == 0) { 
    150         // ROOT³¬ÁؤǺÇÂç¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£        
     150        // ROOT階層で最大のランクを取得する。       
    151151        $where = "parent_category_id = ?"; 
    152152        $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1; 
    153153    } else { 
    154         // ¿Æ¤Î¥é¥ó¥¯¤ò¼«Ê¬¤Î¥é¥ó¥¯¤È¤¹¤ë¡£ 
     154        // 親のランクを自分のランクとする。 
    155155        $where = "category_id = ?"; 
    156156        $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id)); 
    157         // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯°Ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤¢¤²¤ë¡£ 
     157        // 追加レコードのランク以上のレコードを一つあげる。 
    158158        $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; 
    159159        $objQuery->exec($sqlup, array($rank)); 
     
    161161     
    162162    $where = "category_id = ?"; 
    163     // ¼«Ê¬¤Î¥ì¥Ù¥ë¤ò¼èÆÀ¤¹¤ë(¿Æ¤Î¥ì¥Ù¥ë + 1)    
     163    // 自分のレベルを取得する(親のレベル + 1)    
    164164    $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1; 
    165165     
    166     // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ 
     166    // 入力データを渡す。 
    167167    $sqlval = $objFormParam->getHashArray(); 
    168168    $sqlval['create_date'] = "Now()"; 
     
    173173    $sqlval['level'] = $level; 
    174174     
    175     // INSERT¤Î¼Â¹Ô 
     175    // INSERTの実行 
    176176    $objQuery->insert("dtb_category", $sqlval); 
    177177     
    178     $objQuery->commit();    // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î½ªÎ» 
    179 } 
    180  
    181 // ¥«¥Æ¥´¥ê¤ÎÊÔ½¸ 
     178    $objQuery->commit();    // トランザクションの終了 
     179} 
     180 
     181// カテゴリの編集 
    182182function lfUpdateCat($category_id) { 
    183183    global $objFormParam; 
    184184    $objQuery = new SC_Query(); 
    185     // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ 
     185    // 入力データを渡す。 
    186186    $sqlval = $objFormParam->getHashArray(); 
    187187    $sqlval['update_date'] = "Now()"; 
     
    190190} 
    191191 
    192 // ¥«¥Æ¥´¥ê¤Î¼èÆÀ 
     192// カテゴリの取得 
    193193function lfGetCat($parent_category_id) { 
    194194    $objQuery = new SC_Query(); 
     
    205205} 
    206206 
    207 /* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */ 
     207/* パラメータ情報の初期化 */ 
    208208function lfInitParam() { 
    209209    global $objFormParam; 
    210     $objFormParam->addParam("¥«¥Æ¥´¥ê̾", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 
    211 } 
    212  
    213 /* ÆþÎÏÆâÍƤΥÁ¥§¥Ã¥¯ */ 
     210    $objFormParam->addParam("カテゴリ名", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 
     211} 
     212 
     213/* 入力内容のチェック */ 
    214214function lfCheckError($array) { 
    215215    global $objFormParam; 
     
    217217    $objErr->arrErr = $objFormParam->checkError(); 
    218218     
    219     // ³¬ÁØ¥Á¥§¥Ã¥¯ 
     219    // 階層チェック 
    220220    if(!isset($objErr->arrErr['category_name'])) { 
    221221        $objQuery = new SC_Query(); 
     
    223223         
    224224        if($level >= LEVEL_MAX) { 
    225             $objErr->arrErr['category_name'] = "¢¨ ".LEVEL_MAX."³¬Áذʾå¤ÎÅÐÏ¿¤Ï¤Ç¤­¤Þ¤»¤ó¡£<br>"; 
     225            $objErr->arrErr['category_name'] = "※ ".LEVEL_MAX."階層以上の登録はできません。<br>"; 
    226226        } 
    227227    } 
    228228         
    229     // ½ÅÊ£¥Á¥§¥Ã¥¯ 
     229    // 重複チェック 
    230230    if(!isset($objErr->arrErr['category_name'])) { 
    231231        $objQuery = new SC_Query(); 
    232232        $where = "parent_category_id = ? AND category_name = ?"; 
    233233        $arrRet = $objQuery->select("category_id, category_name", "dtb_category", $where, array($_POST['parent_category_id'], $array['category_name'])); 
    234         // ÊÔ½¸Ãæ¤Î¥ì¥³¡¼¥É°Ê³°¤ËƱ¤¸Ì¾¾Î¤¬Â¸ºß¤¹¤ë¾ì¹ç 
     234        // 編集中のレコード以外に同じ名称が存在する場合 
    235235        if ($arrRet[0]['category_id'] != $_POST['category_id'] && $arrRet[0]['category_name'] == $_POST['category_name']) { 
    236             $objErr->arrErr['category_name'] = "¢¨ ´û¤ËƱ¤¸ÆâÍƤÎÅÐÏ¿¤¬Â¸ºß¤·¤Þ¤¹¡£<br>"; 
     236            $objErr->arrErr['category_name'] = "※ 既に同じ内容の登録が存在します。<br>"; 
    237237        } 
    238238    } 
     
    242242 
    243243 
    244 // ʤӤ¬1¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ 
     244// 並びが1つ下のIDを取得する。 
    245245function lfGetDownRankID($objQuery, $table, $pid_name, $id_name, $id) { 
    246     // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£ 
     246    // 親IDを取得する。 
    247247    $col = "$pid_name"; 
    248248    $where = "$id_name = ?"; 
    249249    $pid = $objQuery->get($table, $col, $where, $id); 
    250     // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£ 
     250    // すべての子を取得する。 
    251251    $col = "$id_name"; 
    252252    $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; 
     
    263263} 
    264264 
    265 // ʤӤ¬1¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ 
     265// 並びが1つ上のIDを取得する。 
    266266function lfGetUpRankID($objQuery, $table, $pid_name, $id_name, $id) { 
    267     // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£ 
     267    // 親IDを取得する。 
    268268    $col = "$pid_name"; 
    269269    $where = "$id_name = ?"; 
    270270    $pid = $objQuery->get($table, $col, $where, $id); 
    271     // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£ 
     271    // すべての子を取得する。 
    272272    $col = "$id_name"; 
    273273    $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; 
     
    285285 
    286286function lfCountChilds($objQuery, $table, $pid_name, $id_name, $id) { 
    287     // »ÒID°ìÍ÷¤ò¼èÆÀ 
     287    // 子ID一覧を取得 
    288288    $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    289289    return count($arrRet); 
     
    291291 
    292292function lfUpRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 
    293     // »ÒID°ìÍ÷¤ò¼èÆÀ 
     293    // 子ID一覧を取得 
    294294    $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    295295    $line = sfGetCommaList($arrRet); 
     
    301301 
    302302function lfDownRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 
    303     // »ÒID°ìÍ÷¤ò¼èÆÀ 
     303    // 子ID一覧を取得 
    304304    $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    305305    $line = sfGetCommaList($arrRet); 
Note: See TracChangeset for help on using the changeset viewer.