[Svn-src-all:1320] [version-2_5-dev 20209] #1016 コンテンツ管理リファクタリング

kishida admin @ mail.ec-cube.net
2011年 2月 19日 (土) 21:39:14 JST


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

Log:
--------------------------------------------------------
#1016 コンテンツ管理リファクタリング

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php

変更: branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php	2011-02-19 11:54:52 UTC (rev 20208)
+++ branches/version-2_5-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents_FileView.php	2011-02-19 12:39:14 UTC (rev 20209)
@@ -62,46 +62,91 @@
      * @return void
      */
     function action() {
-        // FIXME パスのチェック関数が必要
-        if (preg_match('|\./|', $_GET['file'])) {
-            SC_Utils_Ex::sfDispError('');
-        }
         // ユーザー認証
         SC_Utils_Ex::sfIsSuccess(new SC_Session());
 
+        switch($this->getMode()){
+            default:
+                // フォーム操作クラス
+                $objFormParam = new SC_FormParam();
+                // パラメータ情報の初期化
+                $this->lfInitParam($objFormParam);
+                $objFormParam->setParam($_GET);
+                $objFormParam->convParam();
+
+                // 表示するファイルにエラーチェックを行う
+                if ($this->checkErrorDispFile($objFormParam)) {
+                    $this->execFileView($objFormParam);
+                } else {
+                    SC_Utils_Ex::sfDispError('');
+                }
+                exit;
+            break;
+        }
+    }
+
+    /**
+     * デストラクタ.
+     *
+     * @return void
+     */
+    function destroy() {
+        parent::destroy();
+    }
+
+    /**
+     * 初期化を行う.
+     *
+     * @param SC_FormParam $objFormParam SC_FormParamインスタンス
+     * @return void
+     */
+    function lfInitParam(&$objFormParam) {
+        $objFormParam->addParam("ファイル名", "file", MTEXT_LEN, "a", array("EXIST_CHECK"));
+    }
+
+    /**
+     * 表示するファイルにエラーチェックを行う
+     *
+     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
+     * @return boolen $file_check_flg エラーチェックの結果
+     */
+    function checkErrorDispFile($objFormParam) {
+        $file_check_flg = false;
+
+        // FIXME パスのチェック関数が必要
+        $file = $objFormParam->getValue('file');
+
         // ソースとして表示するファイルを定義(直接実行しないファイル)
         $arrViewFile = array(
-                             'html',
-                             'htm',
-                             'tpl',
-                             'php',
-                             'css',
-                             'js',
-                             );
+            'html',
+            'htm',
+            'tpl',
+            'php',
+            'css',
+            'js',
+        );
 
         // 拡張子取得
-        $arrResult = split('\.', $_GET['file']);
+        $arrResult = split('\.', $objFormParam->getValue('file'));
         $ext = $arrResult[count($arrResult)-1];
 
-        // ファイル内容表示
-        if(in_array($ext, $arrViewFile)) {
-            $objFileManager = new SC_Helper_FileManager_Ex();
-            // ファイルを読み込んで表示
-            header("Content-type: text/plain\n\n");
-            print($objFileManager->sfReadFile(USER_REALDIR . $_GET['file']));
-        } else {
-            SC_Response_Ex::sendRedirect(USER_URL . $_GET['file']);
+        if (!preg_match('|\./|', $file) && in_array($ext, $arrViewFile)) {
+            $file_check_flg = true;
         }
-        exit;
+
+        return $file_check_flg;
     }
 
     /**
-     * デストラクタ.
-     *
+     * ファイル内容を表示する
+     * 
      * @return void
      */
-    function destroy() {
-        parent::destroy();
+    function execFileView($objFormParam) {
+        $objFileManager = new SC_Helper_FileManager_Ex();
+        // ファイルを読み込んで表示
+        header("Content-type: text/plain\n\n");
+        print($objFileManager->sfReadFile(USER_REALDIR . $objFormParam->getValue('file')));
     }
 }
 ?>




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