Changeset 21925


Ignore:
Timestamp:
2012/06/19 16:15:24 (12 years ago)
Author:
pineray
Message:

#1669 #1859 初期化漏れ、無駄な変数等

Location:
branches/version-2_12-dev/data/class
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/SC_CartSession.php

    r21920 r21925  
    5151        } 
    5252        // 1世代古いコピー情報は、削除しておく 
    53         foreach ($_SESSION as $k => $val) { 
     53        foreach (array_keys($_SESSION) as $k) { 
    5454            if ($k != $this->key_tmp && preg_match('/^savecart_/', $k)) { 
    5555                unset($this->cartSession[$productTypeId][$k]); 
     
    8787            // 一時カートのクリア 
    8888            unset($_SESSION[$this->key_tmp]); 
    89             $this->cartSession[$productTypeId][$key]['cancel_purchase'] = true; 
     89            $this->cartSession[$productTypeId]['cancel_purchase'] = true; 
    9090        } else { 
    9191            $this->cartSession[$productTypeId]['cancel_purchase'] = false; 
     
    9696    // 次に割り当てるカートのIDを取得する 
    9797    function getNextCartID($productTypeId) { 
    98         foreach ($this->cartSession[$productTypeId] as $key => $val) { 
    99             $arrRet[] = $this->cartSession[$productTypeId][$key]['cart_no']; 
    100         } 
    101         return max($arrRet) + 1; 
     98        $count = array(); 
     99        foreach (array_keys($this->cartSession[$productTypeId]) as $key) { 
     100            $count[] = $this->cartSession[$productTypeId][$key]['cart_no']; 
     101        } 
     102        return max($count) + 1; 
    102103    } 
    103104 
     
    143144        $max = 0; 
    144145        if (count($this->cartSession[$productTypeId]) > 0) { 
    145             foreach ($this->cartSession[$productTypeId] as $key => $val) { 
     146            foreach (array_keys($this->cartSession[$productTypeId]) as $key) { 
    146147                if (is_numeric($key)) { 
    147148                    if ($max < $key) { 
     
    393394    function getAllProductID($productTypeId) { 
    394395        $max = $this->getMax($productTypeId); 
     396        $productIDs = array(); 
    395397        for ($i = 0; $i <= $max; $i++) { 
    396398            if ($this->cartSession[$productTypeId][$i]['cart_no'] != '') { 
    397                 $arrRet[] = $this->cartSession[$productTypeId][$i]['id'][0]; 
    398             } 
    399         } 
    400         return $arrRet; 
     399                $productIDs[] = $this->cartSession[$productTypeId][$i]['id'][0]; 
     400            } 
     401        } 
     402        return $productIDs; 
    401403    } 
    402404 
     
    409411    function getAllProductClassID($productTypeId) { 
    410412        $max = $this->getMax($productTypeId); 
     413        $productClassIDs = array(); 
    411414        for ($i = 0; $i <= $max; $i++) { 
    412415            if ($this->cartSession[$productTypeId][$i]['cart_no'] != '') { 
    413                 $arrRet[] = $this->cartSession[$productTypeId][$i]['id']; 
    414             } 
    415         } 
    416         return $arrRet; 
     416                $productClassIDs[] = $this->cartSession[$productTypeId][$i]['id']; 
     417            } 
     418        } 
     419        return $productClassIDs; 
    417420    } 
    418421 
     
    497500     */ 
    498501    function getProductClassId($cart_no, $productTypeId) { 
    499         for ($i = 0; $i <= $max; $i++) { 
     502        for ($i = 0; $i < count($this->cartSession[$productTypeId]); $i++) { 
    500503            if ($this->cartSession[$productTypeId][$i]['cart_no'] == $cart_no) { 
    501504                return $this->cartSession[$productTypeId][$i]['id']; 
     
    625628    ) { 
    626629 
     630        $results = array(); 
    627631        $total_point = $this->getAllProductsPoint($productTypeId); 
    628632        $results['tax'] = $this->getAllProductsTax($productTypeId); 
  • branches/version-2_12-dev/data/class/SC_CheckError.php

    r21920 r21925  
    5959        $this->createParam($value); 
    6060        // HTMLに含まれているタグを抽出する 
    61         preg_match_all('/<\/?([a-z]+)/i', $this->arrParam[$value[1]], $arrTagIncludedHtml); 
     61        preg_match_all('/<\/?([a-z]+)/i', $this->arrParam[$value[1]], $arrTagIncludedHtml = array()); 
    6262 
    6363        $arrDiffTag = array_diff($arrTagIncludedHtml[1], $value[2]); 
     
    630630        $quoted_string = "\"$qcontent*\""; 
    631631        $atext         = '[a-zA-Z0-9!#$%&\'*+\-\/\=?^_`{|}~]'; 
    632         $dot_atom_text = "$atext+(?:[.]$atext+)*"; 
    633         $dot_atom      = $dot_atom_text; 
     632        $dot_atom      = "$atext+(?:[.]$atext+)*"; 
    634633        $local_part    = "(?:$dot_atom|$quoted_string)"; 
    635634        $domain        = $dot_atom; 
    636         $addr_spec     = "${local_part}[@]$domain"; 
     635        $addr_spec     = "{$local_part}[@]$domain"; 
    637636 
    638637        $dot_atom_loose   = "$atext+(?:[.]|$atext)*"; 
    639638        $local_part_loose = "(?:$dot_atom_loose|$quoted_string)"; 
    640         $addr_spec_loose  = "${local_part_loose}[@]$domain"; 
     639        $addr_spec_loose  = "{$local_part_loose}[@]$domain"; 
    641640 
    642641        if (RFC_COMPLIANT_EMAIL_CHECK) { 
    643             $regexp = "/\A${addr_spec}\z/"; 
     642            $regexp = "/\A{$addr_spec}\z/"; 
    644643        } else { 
    645644            // 携帯メールアドレス用に、..や.@を許容する。 
    646             $regexp = "/\A${addr_spec_loose}\z/"; 
     645            $regexp = "/\A{$addr_spec_loose}\z/"; 
    647646        } 
    648647 
     
    932931        } 
    933932        $this->createParam($value); 
    934         $error = 0; 
    935933        if ((strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0 || strlen($this->arrParam[$value[4]]) > 0) && ! checkdate($this->arrParam[$value[3]], $this->arrParam[$value[4]], $this->arrParam[$value[2]])) { 
    936934            $this->arrErr[$value[2]] = '※ ' . $value[0] . 'を正しく指定してください。<br />'; 
     
    983981        } 
    984982        $this->createParam($value); 
    985         $error = 0; 
    986983        if ((strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0 || strlen($this->arrParam[$value[4]]) > 0 || strlen($this->arrParam[$value[5]]) > 0) && ! checkdate($this->arrParam[$value[3]], $this->arrParam[$value[4]], $this->arrParam[$value[2]])) { 
    987984            $this->arrErr[$value[2]] = '※ ' . $value[0] . 'を正しく指定してください。<br />'; 
     
    10271024        } 
    10281025        $this->createParam($value); 
    1029         $error = 0; 
    10301026        if ((strlen($this->arrParam[$value[2]]) > 0 || strlen($this->arrParam[$value[3]]) > 0) && ! checkdate($this->arrParam[$value[3]], 1, $this->arrParam[$value[2]])) { 
    10311027            $this->arrErr[$value[2]] = '※ ' . $value[0] . 'を正しく指定してください。<br />'; 
     
    11231119 
    11241120        $pattern = '/' . join('|', $prohibitedStr) . '/i'; 
    1125         if (preg_match_all($pattern, $this->arrParam[$value[1]], $matches)) { 
     1121        if (preg_match_all($pattern, $targetStr, $matches = array())) { 
    11261122            $this->arrErr[$value[1]] = '※ ' . $value[0] . 'は入力できません。<br />'; 
    11271123        } 
  • branches/version-2_12-dev/data/class/SC_CustomerList.php

    r21867 r21925  
    3131    function __construct($array, $mode = '') { 
    3232        parent::__construct($array); 
    33  
    34         $masterData = new SC_DB_MasterData_Ex(); 
    3533 
    3634        $objDb = new SC_Helper_DB_Ex(); 
  • branches/version-2_12-dev/data/class/SC_Date.php

    r21867 r21925  
    146146    function getHour() { 
    147147 
    148         $day_array = array(); 
     148        $hour_array = array(); 
    149149        for ($i=0; $i<=23; $i++) { 
    150150            $hour_array[$i] = $i; 
  • branches/version-2_12-dev/data/class/SC_Display.php

    r21867 r21925  
    142142        $nu = new Net_UserAgent_Mobile(); 
    143143        $su = new SC_SmartphoneUserAgent_Ex(); 
    144         $retDevice = 0; 
    145144        if ($nu->isMobile()) { 
    146145            return DEVICE_TYPE_MOBILE; 
  • branches/version-2_12-dev/data/class/SC_FormParam.php

    r21921 r21925  
    336336    function getHashArray($arrKey = array()) { 
    337337        $arrRet = array(); 
    338         foreach ($this->keyname as $index => $keyname) { 
     338        foreach ($this->keyname as $keyname) { 
    339339            if (empty($arrKey) || in_array($keyname, $arrKey)) { 
    340340                $arrRet[$keyname] = $this->getValue($keyname); 
     
    346346    // DB格納用配列の作成 
    347347    function getDbArray() { 
     348        $dbArray = array(); 
    348349        foreach ($this->keyname as $index => $key) { 
    349350            if ($this->input_db[$index]) { 
    350                 $arrRet[$key] = $this->getValue($key); 
    351             } 
    352         } 
    353         return $arrRet; 
     351                $dbArray[$key] = $this->getValue($key); 
     352            } 
     353        } 
     354        return $dbArray; 
    354355    } 
    355356 
     
    378379    // フォームに渡す用のパラメーターを返す 
    379380    function getFormParamList() { 
     381        $formParamList = array(); 
    380382        foreach ($this->keyname as $index => $key) { 
    381383            // キー名 
    382             $arrRet[$key]['keyname'] = $key; 
     384            $formParamList[$key]['keyname'] = $key; 
    383385            // 表示名 
    384             $arrRet[$key]['disp_name'] = $this->disp_name[$index]; 
     386            $formParamList[$key]['disp_name'] = $this->disp_name[$index]; 
    385387            // 文字数制限 
    386             $arrRet[$key]['length'] = $this->length[$index]; 
     388            $formParamList[$key]['length'] = $this->length[$index]; 
    387389            // 入力値 
    388             $arrRet[$key]['value'] = $this->getValue($key); 
    389         } 
    390         return $arrRet; 
     390            $formParamList[$key]['value'] = $this->getValue($key); 
     391        } 
     392        return $formParamList; 
    391393    } 
    392394 
     
    403405    function getValue($keyname, $default = '') { 
    404406        $ret = null; 
    405         foreach ($this->keyname as $index => $key) { 
     407        foreach ($this->keyname as $key) { 
    406408            if ($key == $keyname) { 
    407409                $ret = isset($this->arrValue[$key]) ? $this->arrValue[$key] : $this->arrDefault[$key]; 
     
    482484    function getSearchArray($prefix = 'search_') { 
    483485        $arrResults = array(); 
    484         foreach ($this->keyname as $index => $key) { 
     486        foreach ($this->keyname as $key) { 
    485487            if (preg_match('/^' . $prefix . '/', $key)) { 
    486488                $arrResults[$key] = $this->getValue($key); 
     
    497499     */ 
    498500    function getFormDispArray() { 
     501        $formDispArray = array(); 
    499502        foreach ($this->keyname as $index => $key) { 
    500503            // キー名 
    501             $arrRet[$index]['keyname'] = $key; 
     504            $formDispArray[$index]['keyname'] = $key; 
    502505            // 表示名 
    503             $arrRet[$index]['disp_name']  = $this->disp_name[$index]; 
     506            $formDispArray[$index]['disp_name']  = $this->disp_name[$index]; 
    504507            // 文字数制限 
    505             $arrRet[$index]['length'] = $this->length[$index]; 
     508            $formDispArray[$index]['length'] = $this->length[$index]; 
    506509            // 入力値 
    507             $arrRet[$index]['value'] = $this->getValue($key); 
    508         } 
    509         return $arrRet; 
     510            $formDispArray[$index]['value'] = $this->getValue($key); 
     511        } 
     512        return $formDispArray; 
    510513    } 
    511514 
     
    521524            // $this->paramに歯抜けが存在する場合は、NULLで埋めておく。 
    522525            // 最後に配列を詰める際に、全ての項目が埋まっている必要がある。 
    523             foreach ($this->keyname as $key => $val) { 
     526            foreach (array_keys($this->keyname) as $key) { 
    524527                if (!isset($this->param[$key])) { 
    525528                    $this->param[$key] = NULL; 
Note: See TracChangeset for help on using the changeset viewer.