source: branches/camp/camp-2_13-plugin/data/class/plugin/SC_Plugin_Installer.php @ 22655

Revision 22655, 3.5 KB checked in by adachi, 11 years ago (diff)

#2181 データ修正

RevLine 
[22630]1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23class SC_Plugin_Installer {
24   
25    protected $arrPlugin;
26   
27    protected $arrInstallData;
28   
29    function __construct($arrPlugin) {
30        $this->arrPlugin = $arrPlugin;
31    }
32   
33    function execInstall() {
[22648]34        GC_Utils_Ex::gfPrintLog("start install");
[22630]35       
[22648]36        $plugin_code = $this->arrPlugin['plugin_code'];
[22646]37
[22630]38        $objQuery =& SC_Query::getSingletonInstance();
39        $objQuery->begin();
40       
41        // テーブル作成SQLなどを実行
[22648]42        $arrSql = $this->arrInstallData[$plugin_code]['sql'];
[22630]43       
44        foreach ($arrSql as $sql) {
[22648]45            GC_Utils_Ex::gfPrintLog("exec sql:" . $sql['sql']);
[22630]46            $objQuery->query($sql['sql'], $sql['params']);
47        }
[22646]48
49        // プラグインのディレクトリコピー
[22648]50        $arrCopyDirectories = $this->arrInstallData[$plugin_code]['copy_directory'];
[22646]51
52        foreach ($arrCopyDirectories as $directory) {
[22648]53            GC_Utils_Ex::gfPrintLog("exec dir copy:" . $directory['src']);
[22646]54            // ディレクトリコピー -> HTML配下とDATA配下を別関数にする
[22648]55            SC_Utils::copyDirectory(
56                    PLUGIN_UPLOAD_REALDIR . $plugin_code . DIRECTORY_SEPARATOR . $directory['src'],
57                    PLUGIN_HTML_REALDIR   . $plugin_code . DIRECTORY_SEPARATOR . $directory['dist']);
[22646]58        }
59
[22630]60        // プラグインのファイルコピー
[22648]61        $arrCopyFiles = $this->arrInstallData[$plugin_code]['copy_file'];
[22646]62
[22630]63        foreach ($arrCopyFiles as $file) {
[22648]64            GC_Utils_Ex::gfPrintLog("exec file copy:" . $file['src']);
[22630]65            // ファイルコピー
[22648]66            copy(PLUGIN_UPLOAD_REALDIR . $plugin_code . DIRECTORY_SEPARATOR . $file['src'],
67                 PLUGIN_HTML_REALDIR   . $plugin_code . DIRECTORY_SEPARATOR . $file['dist']);
[22630]68        }
[22646]69
[22630]70        $objQuery->commit();
71        GC_Utils_Ex::gfPrintLog("end install");
[22646]72       
[22630]73    }
74   
[22633]75    function copyFile($src, $dist) {
[22648]76        $plugin_code = $this->arrPlugin['plugin_code'];
[22655]77        $this->arrInstallData[$plugin_code]['copy_file'][] = array(
[22646]78            'src'    => $src,
79            'dist' => $dist
80        );
[22630]81    }
[22646]82
83    function copyDirectory($src, $dist) {
[22648]84        $plugin_code = $this->arrPlugin['plugin_code'];
[22655]85        $this->arrInstallData[$plugin_code]['copy_directory'][] = array(
[22646]86            'src'    => $src,
87            'dist' => $dist
88        );       
89    }
90
[22630]91    function removeFile($dist) {
92       
93    }
94   
[22652]95    public function sql($sql, array $params = array()) {
[22630]96        $plugin_code = $this->arrPlugin['plugin_code'];
[22655]97        $this->arrInstallData[$plugin_code]['sql'][] = array(
[22630]98            'sql'    => $sql,
99            'params' => $params
100        );
101    }
102}
Note: See TracBrowser for help on using the repository browser.