Ignore:
Timestamp:
2006/10/13 18:25:45 (20 years ago)
Author:
naka
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • temp/trunk/data/update/admin/products/category.php

    r6332 r6333  
    142142//----------------------------------------------------------------------------------------------------------------------------------- 
    143143 
    144 // ¥«¥Æ¥´¥ê¤Î¿·µ¬Äɲà
    145 function lfInsertCat($parent_category_id) { 
    146     global $objFormParam; 
    147      
    148     $objQuery = new SC_Query(); 
    149     $objQuery->begin(); // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î³«»Ï 
    150      
    151      
    152     if($parent_category_id == 0) { 
    153         // ROOT³¬ÁؤǺÇÂç¤Î¥é¥ó¥¯¤ò¼èÆÀ¤¹¤ë¡£        
    154         $where = "parent_category_id = ?"; 
    155         $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1; 
    156     } else { 
    157         // ¿Æ¤Î¥é¥ó¥¯¤ò¼«Ê¬¤Î¥é¥ó¥¯¤È¤¹¤ë¡£ 
    158         $where = "category_id = ?"; 
    159         $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id)); 
    160         // Äɲå쥳¡¼¥É¤Î¥é¥ó¥¯°Ê¾å¤Î¥ì¥³¡¼¥É¤ò°ì¤Ä¤¢¤²¤ë¡£ 
    161         $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; 
    162         $objQuery->exec($sqlup, array($rank)); 
    163     } 
    164      
    165     $where = "category_id = ?"; 
    166     // ¼«Ê¬¤Î¥ì¥Ù¥ë¤ò¼èÆÀ¤¹¤ë(¿Æ¤Î¥ì¥Ù¥ë + 1)    
    167     $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1; 
    168      
    169     // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ 
    170     $sqlval = $objFormParam->getHashArray(); 
    171     $sqlval['create_date'] = "Now()"; 
    172     $sqlval['update_date'] = "Now()"; 
    173     $sqlval['creator_id'] = $_SESSION['member_id']; 
    174     $sqlval['parent_category_id'] = $parent_category_id; 
    175     $sqlval['rank'] = $rank; 
    176     $sqlval['level'] = $level; 
    177      
    178     // INSERT¤Î¼Â¹Ô 
    179     $objQuery->insert("dtb_category", $sqlval); 
    180      
    181     $objQuery->commit();    // ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Î½ªÎ» 
    182 } 
    183  
    184 // ¥«¥Æ¥´¥ê¤ÎÊÔ½¸ 
    185 function lfUpdateCat($category_id) { 
    186     global $objFormParam; 
    187     $objQuery = new SC_Query(); 
    188     // ÆþÎϥǡ¼¥¿¤òÅϤ¹¡£ 
    189     $sqlval = $objFormParam->getHashArray(); 
    190     $sqlval['update_date'] = "Now()"; 
    191     $where = "category_id = ?"; 
    192     $objQuery->update("dtb_category", $sqlval, $where, array($category_id)); 
    193 } 
    194  
    195 // ¥«¥Æ¥´¥ê¤Î¼èÆÀ 
    196 function lfGetCat($parent_category_id) { 
    197     $objQuery = new SC_Query(); 
    198     $col = "category_id, category_name, level, rank"; 
    199     $where = "del_flg = 0 AND parent_category_id = ?"; 
    200     $objQuery->setoption("ORDER BY rank DESC"); 
    201     $arrRet = $objQuery->select($col, "dtb_category", $where, array($parent_category_id)); 
    202     return $arrRet; 
    203 } 
    204  
    205 /* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */ 
    206 function lfInitParam() { 
    207     global $objFormParam; 
    208     $objFormParam->addParam("¥«¥Æ¥´¥ê̾", "category_name", STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 
    209 } 
    210  
    211 /* ÆþÎÏÆâÍÆ¤Î¥Á¥§¥Ã¥¯ */ 
    212 function lfCheckError($array) { 
    213     global $objFormParam; 
    214     $objErr = new SC_CheckError($array); 
    215     $objErr->arrErr = $objFormParam->checkError(); 
    216      
    217     // ³¬ÁØ¥Á¥§¥Ã¥¯ 
    218     if(!isset($objErr->arrErr['category_name'])) { 
    219         $objQuery = new SC_Query(); 
    220         $level = $objQuery->get("dtb_category", "level", "category_id = ?", array($_POST['parent_category_id'])); 
    221          
    222         if($level >= LEVEL_MAX) { 
    223             $objErr->arrErr['category_name'] = "¢¨ ".LEVEL_MAX."³¬Áذʾå¤ÎÅÐÏ¿¤Ï¤Ç¤­¤Þ¤»¤ó¡£<br>"; 
    224         } 
    225     } 
    226          
    227     // ½ÅÊ£¥Á¥§¥Ã¥¯ 
    228     if(!isset($objErr->arrErr['category_name'])) { 
    229         $objQuery = new SC_Query(); 
    230         $where = "parent_category_id = ? AND category_name = ?"; 
    231         $arrRet = $objQuery->select("category_id, category_name", "dtb_category", $where, array($_POST['parent_category_id'], $array['category_name'])); 
    232         // ÊÔ½¸Ãæ¤Î¥ì¥³¡¼¥É°Ê³°¤ËƱ¤¸Ì¾¾Î¤¬Â¸ºß¤¹¤ë¾ì¹ç 
    233         if ($arrRet[0]['category_id'] != $_POST['category_id'] && $arrRet[0]['category_name'] == $_POST['category_name']) { 
    234             $objErr->arrErr['category_name'] = "¢¨ ´û¤ËƱ¤¸ÆâÍÆ¤ÎÅÐÏ¿¤¬Â¸ºß¤·¤Þ¤¹¡£<br>"; 
    235         } 
    236     } 
    237  
    238     return $objErr->arrErr; 
    239 } 
    240  
    241  
    242 // ʤӤ¬1¤Ä²¼¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ 
    243 function lfGetDownRankID($objQuery, $table, $pid_name, $id_name, $id) { 
    244     // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£ 
    245     $col = "$pid_name"; 
    246     $where = "$id_name = ?"; 
    247     $pid = $objQuery->get($table, $col, $where, $id); 
    248     // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£ 
    249     $col = "$id_name"; 
    250     $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; 
    251     $arrRet = $objQuery->select($col, $table, $where, array($pid)); 
    252     $max = count($arrRet); 
    253     $down_id = ""; 
    254     for($cnt = 0; $cnt < $max; $cnt++) { 
    255         if($arrRet[$cnt][$id_name] == $id) { 
    256             $down_id = $arrRet[($cnt + 1)][$id_name]; 
    257             break; 
    258         } 
    259     } 
    260     return $down_id; 
    261 } 
    262  
    263 // ʤӤ¬1¤Ä¾å¤ÎID¤ò¼èÆÀ¤¹¤ë¡£ 
    264 function lfGetUpRankID($objQuery, $table, $pid_name, $id_name, $id) { 
    265     // ¿ÆID¤ò¼èÆÀ¤¹¤ë¡£ 
    266     $col = "$pid_name"; 
    267     $where = "$id_name = ?"; 
    268     $pid = $objQuery->get($table, $col, $where, $id); 
    269     // ¤¹¤Ù¤Æ¤Î»Ò¤ò¼èÆÀ¤¹¤ë¡£ 
    270     $col = "$id_name"; 
    271     $where = "del_flg = 0 AND $pid_name = ? ORDER BY rank DESC"; 
    272     $arrRet = $objQuery->select($col, $table, $where, array($pid)); 
    273     $max = count($arrRet); 
    274     $up_id = ""; 
    275     for($cnt = 0; $cnt < $max; $cnt++) { 
    276         if($arrRet[$cnt][$id_name] == $id) { 
    277             $up_id = $arrRet[($cnt - 1)][$id_name]; 
    278             break; 
    279         } 
    280     } 
    281     return $up_id; 
    282 } 
    283  
    284 function lfCountChilds($objQuery, $table, $pid_name, $id_name, $id) { 
    285     // »ÒID°ìÍ÷¤ò¼èÆÀ 
    286     $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    287     return count($arrRet); 
    288 } 
    289  
    290 function lfUpRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 
    291     // »ÒID°ìÍ÷¤ò¼èÆÀ 
    292     $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    293     $line = sfGetCommaList($arrRet); 
    294     $sql = "UPDATE $table SET rank = (rank + $count) WHERE $id_name IN ($line) "; 
    295     $sql.= "AND del_flg = 0"; 
    296     $ret = $objQuery->exec($sql); 
    297     return $ret; 
    298 } 
    299  
    300 function lfDownRankChilds($objQuery, $table, $pid_name, $id_name, $id, $count) { 
    301     // »ÒID°ìÍ÷¤ò¼èÆÀ 
    302     $arrRet = sfGetChildrenArray($table, $pid_name, $id_name, $id);  
    303     $line = sfGetCommaList($arrRet); 
    304     $sql = "UPDATE $table SET rank = (rank - $count) WHERE $id_name IN ($line) "; 
    305     $sql.= "AND del_flg = 0"; 
    306     $ret = $objQuery->exec($sql); 
    307     return $ret; 
    308 } 
    309144?> 
Note: See TracChangeset for help on using the changeset viewer.