[Svn-src-all:1316] [version-2_5-dev 20205] ・/admin/mail/preview.php のリファクタリング

fukuda admin @ mail.ec-cube.net
2011年 2月 19日 (土) 19:48:25 JST


Subversion committed to /home/svn/open 20205
http://svn.ec-cube.net/open_trac/changeset/20205
┌────────────────────────────┐
│更新者 :  fukuda                                       │
│更新日時:  2011-02-19 19:48:25 +0900 (土, 19  2月 2011)│
└────────────────────────────┘

Log:
--------------------------------------------------------
・/admin/mail/preview.php のリファクタリング
・使用していないmail_method=3に関するコードを削除

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/Smarty/templates/admin/mail/preview.tpl
U   branches/version-2_5-dev/data/Smarty/templates/admin/mail/template.tpl
U   branches/version-2_5-dev/data/class/helper/SC_Helper_Mail.php
U   branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_Preview.php

変更: branches/version-2_5-dev/data/Smarty/templates/admin/mail/preview.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/mail/preview.tpl	2011-02-19 09:50:33 UTC (rev 20204)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/mail/preview.tpl	2011-02-19 10:48:25 UTC (rev 20205)
@@ -21,4 +21,4 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
 *}-->
-<!--{if $escape_flag eq 1}--><!--{$body|h|nl2br}--><!--{else}--><!--{$body}--><!--{/if}-->
+<!--{if $mail.mail_method eq 2}--><!--{$mail.body|h|nl2br}--><!--{else}--><!--{$mail.body}--><!--{/if}-->

変更: branches/version-2_5-dev/data/Smarty/templates/admin/mail/template.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/mail/template.tpl	2011-02-19 09:50:33 UTC (rev 20204)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/mail/template.tpl	2011-02-19 10:48:25 UTC (rev 20205)
@@ -48,9 +48,9 @@
             <td class="left"><!--{$arrTemplates[data].subject|h}--></td>
             <!--{assign var=type value=$arrTemplates[data].mail_method|h}-->
             <td><!--{$arrMagazineType[$type]}--></td>
-            <td><!--{if $arrTemplates[data].mail_method eq 3}--><a href="./htmlmail.php?mode=edit&template_id=<!--{$arrTemplates[data].template_id}-->"><!--{else}--><a href="./template_input.php?mode=edit&template_id=<!--{$arrTemplates[data].template_id}-->"><!--{/if}-->編集</a></td>
+            <td><a href="./template_input.php?mode=edit&template_id=<!--{$arrTemplates[data].template_id}-->">編集</a></td>
             <td><a href="#" onclick="fnDelete('?mode=delete&id=<!--{$arrTemplates[data].template_id}-->'); return false;">削除</a></td>
-            <td><!--{if $arrTemplates[data].mail_method eq 3}--><a href="#" onclick="win03('./preview.php?method=template&id=<!--{$arrTemplates[data].template_id}-->','preview','650','700'); return false;" target="_blank"><!--{else}--><a href="#" onclick="win03('./preview.php?id=<!--{$arrTemplates[data].template_id}-->','preview','650','700'); return false;" target="_blank"><!--{/if}-->プレビュー</a></td>
+            <td><a href="#" onclick="win03('./preview.php?mode=template&template_id=<!--{$arrTemplates[data].template_id}-->','preview','650','700'); return false;" target="_blank">プレビュー</a></td>
         </tr>
         <!--{/section}-->
     </table>

変更: branches/version-2_5-dev/data/class/helper/SC_Helper_Mail.php
===================================================================
--- branches/version-2_5-dev/data/class/helper/SC_Helper_Mail.php	2011-02-19 09:50:33 UTC (rev 20204)
+++ branches/version-2_5-dev/data/class/helper/SC_Helper_Mail.php	2011-02-19 10:48:25 UTC (rev 20205)
@@ -354,5 +354,32 @@
         $arrResults = $objQuery->select('*', 'dtb_mailmaga_template', $where, $arrValues);
         return $arrResults;
     }
+    
+    /**
+     * 保存されている送信履歴の取得
+     * @param integer 特定の送信履歴を取り出したい時はsend_idを指定。未指定時は全件取得
+     * @return array 送信履歴情報を格納した配列
+     */
+    function sfGetSendHistory($send_id = null){
+        // 初期化
+        $where = '';
+        $objQuery =& SC_Query::getSingletonInstance();
+        
+        // 条件文
+        $where = 'del_flg = ?';
+        $arrValues[] = 0;
+        
+        //send_id指定時
+        if (SC_Utils_Ex::sfIsInt($send_id) === true) {
+            $where .= 'AND send_id = ?';
+            $arrValues[] = $send_id;
+        }
+        
+        // 表示順
+        $objQuery->setOrder("create_date DESC");
+        
+        $arrResults = $objQuery->select('*', 'dtb_send_history', $where, $arrValues);
+        return $arrResults;
+    }
 }
 ?>

変更: branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_Preview.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_Preview.php	2011-02-19 09:50:33 UTC (rev 20204)
+++ branches/version-2_5-dev/data/class/pages/admin/mail/LC_Page_Admin_Mail_Preview.php	2011-02-19 10:48:25 UTC (rev 20205)
@@ -62,33 +62,27 @@
      * @return void
      */
     function action() {
-        $objQuery = new SC_Query();
+        
+        $objMailHelper = new SC_Helper_Mail_Ex();
         $objSess = new SC_Session();
-        $objDate = new SC_Date();
-
         // 認証可否の判定
         SC_Utils_Ex::sfIsSuccess($objSess);
 
-        if (SC_Utils_Ex::sfIsInt($_GET['send_id'])
-                   || SC_Utils_Ex::sfIsInt($_GET['id'])){
-                       
-            if (is_numeric($_GET["send_id"])) {
-                $id = $_GET["send_id"];
-                $sql = "SELECT body, mail_method FROM dtb_send_history WHERE send_id = ?";
-            } else {
-                $sql = "SELECT body, mail_method FROM dtb_mailmaga_template WHERE template_id = ?";
-                $id = $_GET['id'];
+        switch ($this->getMode()) {
+        case 'template':
+            if (SC_Utils_Ex::sfIsInt($_GET['template_id'])){
+                $arrMail = $objMailHelper->sfGetMailTemplate($_GET['template_id']);
             }
-            $result = $objQuery->getAll($sql, array($id));
-
-            if ( $result ){
-                if ( $result[0]["mail_method"] == 2 ){
-                    // テキスト形式の時はタグ文字をエスケープ
-                    $this->escape_flag = 1;
-                }    
-                $this->body = $result[0]["body"];
+            break;
+        case 'history';
+            if (SC_Utils_Ex::sfIsInt($_GET['send_id'])){
+                $arrMail = $objMailHelper->sfGetSendHistory($_GET['send_id']);
             }
+            break;
+        default:
         }
+
+        $this->mail = $arrMail[0];
         $this->setTemplate($this->tpl_mainpage);
     }
 




Svn-src-all メーリングリストの案内