Ignore:
Timestamp:
2011/02/20 02:34:18 (13 years ago)
Author:
miningbrownie
Message:

リファクタリングかなり頑張った。ドヤ顔してもいいレベル

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Mail.php

    r20216 r20221  
    8080        // POST値の取得 
    8181        $objFormParam->setParam($_POST); 
     82        $objFormParam->convParam(); 
    8283        $this->tpl_order_id = $objFormParam->getValue('order_id'); 
    8384 
     
    8889                break; 
    8990            case 'send': 
    90                 // 入力値の変換 TODO ここ気持ち悪いんだ returnの時にやってなかったからもって上でやっていいものなのかどうか。 
    91                 $objFormParam->convParam(); 
    92                 $sendStatus = $this->doSend($objFormParam, 
    93                 $objFormParam->getValue('order_id'), 
    94                 $objFormParam->getValue('template_id'), 
    95                 $objFormParam->getValue('subject'), 
    96                 $objFormParam->getValue('header'), 
    97                 $objFormParam->getValue('footer')); 
    98                 if($sendStatus){ 
     91                $sendStatus = $this->doSend($objFormParam); 
     92                if($sendStatus === true){ 
    9993                    SC_Response_Ex::sendRedirect(ADMIN_ORDER_URLPATH); 
    10094                    exit; 
     95                }else{ 
     96                    $this->arrErr = $sendStatus; 
    10197                } 
    10298            case 'confirm': 
    103                 // 入力値の変換 ここ気持ち悪いんだ 
    104                 $objFormParam->convParam(); 
    105                 $status = $this->confirm($objFormParam, 
    106                 $objFormParam->getValue('order_id'), 
    107                 $objFormParam->getValue('template_id'), 
    108                 $objFormParam->getValue('subject'), 
    109                 $objFormParam->getValue('header'), 
    110                 $objFormParam->getValue('footer')); 
    111                 if($status){ 
     99                $status = $this->confirm($objFormParam); 
     100                if($status === true){ 
     101                    $this->arrHidden = $objFormParam->getHashArray(); 
    112102                    return ; 
     103                }else{ 
     104                    $this->arrErr = $status; 
    113105                } 
    114106                break; 
    115107            case 'change': 
    116                 $this->changeData($objFormParam); 
     108                $objFormParam =  $this->changeData($objFormParam); 
    117109                break; 
    118110        } 
     
    142134     * @param SC_FormParam $objFormParam 
    143135     */ 
    144     function doSend(&$objFormParam,$order_id, $template_id, $subject, $header, $footer){ 
    145         // 入力値の変換 
    146         $objFormParam->convParam(); 
    147  
    148         $this->arrErr = $objFormParam->checkerror(); 
     136    function doSend(&$objFormParam){ 
     137        $arrErr = $objFormParam->checkerror(); 
     138 
    149139        // メールの送信 
    150         if (count($this->arrErr) == 0) { 
     140        if (count($arrErr) == 0) { 
    151141            // 注文受付メール 
    152142            $objMail = new SC_Helper_Mail_Ex(); 
    153             $objSendMail = $objMail->sfSendOrderMail($order_id, $template_id, $subject, $header, $footer); 
     143            $objSendMail = $objMail->sfSendOrderMail($objFormParam->getValue('order_id'), 
     144            $objFormParam->getValue('template_id'), 
     145            $objFormParam->getValue('subject'), 
     146            $objFormParam->getValue('header'), 
     147            $objFormParam->getValue('footer')); 
    154148            // TODO $SC_SendMail から送信がちゃんと出来たか確認できたら素敵。 
    155149            return true; 
    156150        } 
    157         return false; 
     151        return $arrErr; 
    158152    } 
    159153 
     
    161155     * 確認画面を表示する為の準備 
    162156     * @param SC_FormParam $objFormParam 
    163      * @param int $order_id 
    164      * @param int $template_id 
    165      * @param string $subject 
    166      * @param string $header 
    167      * @param string $footer 
    168      */ 
    169     function confirm(&$objFormParam,$order_id, $template_id, $subject, $header, $footer){ 
    170         // 入力値の引き継ぎ 
    171         $this->arrHidden = $objFormParam->getHashArray(); 
    172         $this->arrErr = $objFormParam->checkerror(); 
     157     */ 
     158    function confirm(&$objFormParam){ 
     159        $arrErr = $objFormParam->checkerror(); 
    173160        // メールの送信 
    174         if (count($this->arrErr) == 0) { 
     161        if (count($arrErr) == 0) { 
    175162            // 注文受付メール(送信なし) 
    176163            $objMail = new SC_Helper_Mail_Ex(); 
    177164            $objSendMail = $objMail->sfSendOrderMail( 
    178             $order_id, 
    179             $template_id, 
    180             $subject, 
    181             $header, 
    182             $footer, false); 
    183              
     165            $objFormParam->getValue('order_id'), 
     166            $objFormParam->getValue('template_id'), 
     167            $objFormParam->getValue('subject'), 
     168            $objFormParam->getValue('header'), 
     169            $objFormParam->getValue('footer'), false); 
     170 
    184171            $this->tpl_subject = $objFormParam->getValue('subject'); 
    185172            $this->tpl_body = mb_convert_encoding( $objSendMail->body, CHAR_CODE, "auto" ); 
     
    188175            return true; 
    189176        } 
    190         return false; 
    191     } 
    192  
    193     /** 
    194      *  
     177        return $arrErr; 
     178    } 
     179 
     180    /** 
     181     * 
    195182     * テンプレートの文言をフォームに入れる。 
    196183     * @param SC_FormParam $objFormParam 
    197184     */ 
    198185    function changeData(&$objFormParam){ 
    199         $objFormParam->setValue('template_id', $objFormParam->getValue('template_id')); 
    200186        if(SC_Utils_Ex::sfIsInt($objFormParam->getValue('template_id'))) { 
    201187            $objQuery =& SC_Query::getSingletonInstance(); 
    202188            $where = "template_id = ?"; 
    203189            $mailTemplates = $objQuery->select("subject, header, footer", "dtb_mailtemplate", $where, array($objFormParam->getValue('template_id'))); 
     190            if(!is_null($mailTemplates )){ 
     191                foreach(array('subject','header','footer') as $key){ 
     192                    $objFormParam->setValue($key,$mailTemplates[$key]); 
     193                } 
     194            }else{ 
     195 
     196            } 
    204197            $objFormParam->setParam($mailTemplates[0]); 
    205         } 
     198        }else{ 
     199            foreach(array('subject','header','footer') as $key){ 
     200                $objFormParam->setValue($key,""); 
     201            } 
     202        } 
     203        return $objFormParam; 
    206204    } 
    207205 
Note: See TracChangeset for help on using the changeset viewer.