Changeset 20211


Ignore:
Timestamp:
2011/02/19 22:11:56 (13 years ago)
Author:
fukuda
Message:

・/admin/mail/template_input.php をリファクタリング
・インストール時に追加される不要な mtb_magazine_type の値を削除

Location:
branches/version-2_5-dev
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/Smarty/templates/admin/mail/template_input.tpl

    r20116 r20211  
    5454<form name="form1" id="form1" method="post" action="?" onSubmit="return lfnCheckSubmit();"> 
    5555<input type="hidden" name="mode" value="<!--{$mode}-->" /> 
    56 <input type="hidden" name="template_id" value="<!--{$arrForm.template_id}-->" /> 
     56<input type="hidden" name="template_id" value="<!--{$arrForm.template_id|h}-->" /> 
    5757<div id="mail" class="contents-main"> 
    5858  <table class="form"> 
  • branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_TemplateInput.php

    r20203 r20211  
    4949        $this->tpl_subtitle = 'テンプレート設定'; 
    5050        $this->tpl_subno = "template"; 
     51        $this->mode = "regist"; 
    5152        $masterData = new SC_DB_MasterData_Ex(); 
    5253        $this->arrMagazineType = $masterData->getMasterData("mtb_magazine_type"); 
    53         // arrMagazineTypAll ではないため, unset する. 
    54         unset($this->arrMagazineType['3']); 
    5554    } 
    5655 
     
    7170     */ 
    7271    function action() { 
    73         $objQuery = new SC_Query(); 
     72        $objMailHelper = new SC_Helper_Mail_Ex(); 
    7473        $objSess = new SC_Session(); 
    7574 
     
    7776        SC_Utils_Ex::sfIsSuccess($objSess); 
    7877 
    79  
    80         $this->mode = "regist"; 
    81  
    82         // idが指定されているときは「編集」表示 
    83         if (!isset($_REQUEST['template_id'])) $_REQUEST['template_id'] = ""; 
    84         if ( $_REQUEST['template_id'] ){ 
    85             $this->title = "編集"; 
    86         } else { 
    87             $this->title = "新規登録"; 
    88         } 
    89  
    9078        switch ($this->getMode()) { 
    9179        case 'edit': 
    92             // モードによる処理分岐 
     80            // 編集 
    9381            if ( SC_Utils_Ex::sfIsInt($_GET['template_id'])===true ){ 
    94                 // 編集 
    95                 $sql = "SELECT * FROM dtb_mailmaga_template WHERE template_id = ? AND del_flg = 0"; 
    96                 $result = $objQuery->getAll($sql, array($_GET['template_id'])); 
    97                 $this->arrForm = $result[0]; 
     82                $arrMail = $objMailHelper->sfGetMailTemplate($_GET['template_id']); 
     83                $this->arrForm = $arrMail[0]; 
    9884            } 
    9985            break; 
    10086        case 'regist': 
    10187            // 新規登録 
    102             $this->arrForm = $this->lfConvData( $_POST ); 
    103             $this->arrErr = $this->lfErrorCheck($this->arrForm); 
    104  
    105             if ( ! $this->arrErr ){ 
     88            $objFormParam = new SC_FormParam(); 
     89             
     90            $this->lfInitParam($objFormParam); 
     91            $objFormParam->setParam($_POST); 
     92            $this->arrErr = $objFormParam->checkError(); 
     93            $this->arrForm = $objFormParam->getHashArray(); 
     94                         
     95            if (SC_Utils_Ex::isBlank($this->arrErr)) { 
    10696                // エラーが無いときは登録・編集 
    107                 $this->lfRegistData( $this->arrForm, $_POST['template_id']); 
     97                $this->lfRegistData( $objFormParam, $_POST['template_id']); 
    10898                // 自分を再読込して、完了画面へ遷移 
    10999                $this->objDisplay->reload(array("mode" => "complete")); 
     100            } else { 
     101                $this->arrForm['template_id'] = $_POST['template_id']; 
    110102            } 
    111103            break; 
     
    128120    } 
    129121 
    130     function lfRegistData( $arrVal, $id = null ){ 
     122    /** 
     123     * メルマガテンプレートデータの登録・更新を行う 
     124     *  
     125     * @param SC_FormParam $objFormParam SC_FormParam インスタンス 
     126     * @param integer template_id 更新時は指定 
     127     * @return void 
     128     */ 
     129    function lfRegistData( &$objFormParam, $template_id = null ){ 
     130         
     131        $objQuery =& SC_Query::getSingletonInstance(); 
     132        $sqlval = $objFormParam->getDbArray(); 
    131133 
    132         $objQuery = new SC_Query(); 
    133  
    134         $sqlval['subject'] = $arrVal['subject']; 
    135         $sqlval['mail_method'] = $arrVal['mail_method']; 
    136134        $sqlval['creator_id'] = $_SESSION['member_id']; 
    137         $sqlval['body'] = $arrVal['body']; 
    138135        $sqlval['update_date'] = "now()"; 
    139136 
    140         if ( $id ){ 
    141             $objQuery->update("dtb_mailmaga_template", $sqlval, "template_id=".$id ); 
     137        if ( SC_Utils_Ex::sfIsInt($template_id) ){ 
     138            // 更新時 
     139            $objQuery->update("dtb_mailmaga_template", $sqlval, "template_id=".$template_id ); 
    142140        } else { 
     141            // 新規登録時 
    143142            $sqlval['create_date'] = "now()"; 
    144143            $sqlval['template_id'] = $objQuery->nextVal('dtb_mailmaga_template_template_id'); 
     
    147146    } 
    148147 
    149     function lfConvData( $data ){ 
    150  
    151         // 文字列の変換(mb_convert_kanaの変換オプション) 
    152         $arrFlag = array( 
    153                          "subject" => "KV" 
    154                          ,"body" => "KV" 
    155                          ); 
    156  
    157         if ( is_array($data) ){ 
    158             foreach ($arrFlag as $key=>$line) { 
    159                 $data[$key] = mb_convert_kana($data[$key], $line); 
    160             } 
    161         } 
    162  
    163         return $data; 
     148    /** 
     149     * お問い合わせ入力時のパラメータ情報の初期化を行う. 
     150     * 
     151     * @param SC_FormParam $objFormParam SC_FormParam インスタンス 
     152     * @return void 
     153     */ 
     154    function lfInitParam(&$objFormParam) { 
     155        $objFormParam->addParam("メール形式", 'mail_method', INT_LEN, "n", array("EXIST_CHECK","ALNUM_CHECK")); 
     156        $objFormParam->addParam("Subject", 'subject', STEXT_LEN, "KVa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 
     157        $objFormParam->addParam("本文", 'body', LLTEXT_LEN, "KVCa", array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK")); 
    164158    } 
    165159 
    166     // 入力エラーチェック 
    167     function lfErrorCheck() { 
    168         $objErr = new SC_CheckError(); 
    169  
    170         $objErr->doFunc(array("メール形式", "mail_method"), array("EXIST_CHECK", "ALNUM_CHECK")); 
    171         $objErr->doFunc(array("Subject", "subject", STEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); 
    172         $objErr->doFunc(array("本文", 'body', LLTEXT_LEN), array("EXIST_CHECK","MAX_LENGTH_CHECK")); 
    173  
    174         return $objErr->arrErr; 
    175     } 
    176160} 
    177161?> 
  • branches/version-2_5-dev/html/install/sql/column_comment.sql

    r20198 r20211  
    100100INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (414, 'dtb_order', 'deliv_pref', '都道府県'); 
    101101INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (100, 'dtb_mailmaga_template', 'subject', '件名'); 
    102 INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (102, 'dtb_mailmaga_template', 'mail_method', '1:テキストメール 2:HTMLメール 3:HTMLTEMPLATE'); 
     102INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (102, 'dtb_mailmaga_template', 'mail_method', '1:テキストメール 2:HTMLメール'); 
    103103INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (103, 'dtb_mailmaga_template', 'header', 'ヘッダーテキスト'); 
    104104INSERT INTO dtb_table_comment (id, table_name, column_name, description) VALUES (104, 'dtb_mailmaga_template', 'body', '本文(テキスト登録用)'); 
  • branches/version-2_5-dev/html/install/sql/insert_data.sql

    r20207 r20211  
    745745INSERT INTO mtb_magazine_type (id, name, rank) VALUES (1, 'HTML', 0); 
    746746INSERT INTO mtb_magazine_type (id, name, rank) VALUES (2, 'テキスト', 1); 
    747 INSERT INTO mtb_magazine_type (id, name, rank) VALUES (3, 'HTMLテンプレート', 2); 
    748747 
    749748INSERT INTO mtb_mail_magazine_type (id, name, rank) VALUES (1, 'HTMLメール', 0); 
Note: See TracChangeset for help on using the changeset viewer.