Changeset 22673


Ignore:
Timestamp:
2013/03/10 02:16:05 (11 years ago)
Author:
adachi
Message:

#2181 ログ出力

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/camp/camp-2_13-plugin/data/class/plugin/SC_Plugin_Installer.php

    r22665 r22673  
    2323class SC_Plugin_Installer { 
    2424     
     25    protected $exec_func; 
     26     
    2527    protected $plugin_code; 
    2628     
     
    2931    protected $arrInstallData; 
    3032     
    31     public function __construct($arrPlugin) { 
     33    public function __construct($exec_func, $arrPlugin) { 
     34        define('PLUGIN_LOG_REALFILE', DATA_REALDIR . "logs/plugin.log"); 
     35        $this->exec_func   = $exec_func; 
     36        $this->plugin_code = $arrPlugin['plugin_code']; 
    3237        $this->arrPlugin   = $arrPlugin; 
    3338        $this->arrInstallData = array(); 
     
    4550 
    4651        $objQuery =& SC_Query::getSingletonInstance(); 
    47         $objQuery->begin(); 
    4852         
    4953        // テーブル作成SQLなどを実行 
     
    7680        } 
    7781 
    78         $objQuery->commit(); 
    7982        GC_Utils_Ex::gfPrintLog("end install: " . $this->arrPlugin['plugin_code']); 
    8083    } 
    8184     
     85    public function execPlugin($exec_func) { 
     86        $this->log("start"); 
     87         
     88        $plugin_code = $this->arrPlugin['plugin_code']; 
     89 
     90        $objQuery =& SC_Query::getSingletonInstance(); 
     91         
     92        // テーブル作成SQLなどを実行 
     93        $arrSql = $this->arrInstallData['sql']; 
     94         
     95        foreach ($arrSql as $sql) { 
     96            $this->log("exec sql: " . $sql['sql']); 
     97            $objQuery->query($sql['sql'], $sql['params']); 
     98        } 
     99         
     100        // プラグインのディレクトリコピー 
     101        $arrCopyDirectories = $this->arrInstallData['copy_directory']; 
     102 
     103        foreach ($arrCopyDirectories as $directory) { 
     104            $this->log("exec dir copy: " . $directory['src'] . ' -> ' . $directory['dist']); 
     105            // ディレクトリコピー -> HTML配下とDATA配下を別関数にする 
     106            SC_Utils::copyDirectory( 
     107                    PLUGIN_UPLOAD_REALDIR . $plugin_code . DIRECTORY_SEPARATOR . $directory['src'], 
     108                    PLUGIN_HTML_REALDIR   . $plugin_code . DIRECTORY_SEPARATOR . $directory['dist']); 
     109        } 
     110 
     111        // プラグインのファイルコピー 
     112        $arrCopyFiles = $this->arrInstallData['copy_file']; 
     113 
     114        foreach ($arrCopyFiles as $file) { 
     115            $this->log("exec file copy: " . $file['src'] . ' -> ' . $file['dist']); 
     116            // ファイルコピー 
     117            copy(PLUGIN_UPLOAD_REALDIR . $plugin_code . DIRECTORY_SEPARATOR . $file['src'], 
     118                 PLUGIN_HTML_REALDIR   . $plugin_code . DIRECTORY_SEPARATOR . $file['dist']); 
     119        } 
     120         
     121        $this->log("end");          
     122    } 
     123 
    82124    public function copyFile($src, $dist) { 
    83125        $this->arrInstallData['copy_file'][] = array( 
     
    116158        $this->sql($sql, $params); 
    117159    } 
     160     
     161    protected function log($msg) { 
     162        $msg = sprintf("%s %s: %s", $this->exec_func, $this->plugin_code, $msg); 
     163        GC_Utils::gfPrintLog($msg, PLUGIN_LOG_REALFILE); 
     164    } 
    118165} 
Note: See TracChangeset for help on using the changeset viewer.