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 | */ |
---|
23 | class 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() { |
---|
34 | |
---|
35 | GC_Utils_Ex::gfPrintLog("start install"); |
---|
36 | |
---|
37 | // ファイルコピーの事前チェック? |
---|
38 | |
---|
39 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
40 | $objQuery->begin(); |
---|
41 | |
---|
42 | // テーブル作成SQLなどを実行 |
---|
43 | $arrSql = $this->arrInstallData["plugin_code"]['sql']; |
---|
44 | |
---|
45 | foreach ($arrSql as $sql) { |
---|
46 | GC_Utils_Ex::gfPrintLog("start install"); |
---|
47 | $objQuery->query($sql['sql'], $sql['params']); |
---|
48 | } |
---|
49 | |
---|
50 | // プラグインのディレクトリコピー |
---|
51 | $arrCopyDirectories = $this->arrInstallData["plugin_code"]['copy_directory']; |
---|
52 | |
---|
53 | foreach ($arrCopyDirectories as $directory) { |
---|
54 | // ディレクトリコピー -> HTML配下とDATA配下を別関数にする |
---|
55 | // SC_Utils::copyDirectory(PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/" . $directory, PLUGIN_HTML_REALDIR . $arrPlugin['plugin_code'] . "/" . $directory); |
---|
56 | } |
---|
57 | |
---|
58 | // プラグインのファイルコピー |
---|
59 | $arrCopyFiles = $this->arrInstallData["plugin_code"]['copy_file']; |
---|
60 | |
---|
61 | foreach ($arrCopyFiles as $file) { |
---|
62 | // ファイルコピー |
---|
63 | copy(PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/" . $file['src'], PLUGIN_HTML_REALDIR . $arrPlugin['plugin_code'] . "/" . $file['dist']); |
---|
64 | } |
---|
65 | |
---|
66 | $objQuery->commit(); |
---|
67 | GC_Utils_Ex::gfPrintLog("end install"); |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | function copyFile($src, $dist) { |
---|
72 | $this->arrInstallData["plugin_code"]['copy_file'] = array( |
---|
73 | 'src' => $src, |
---|
74 | 'dist' => $dist |
---|
75 | ); |
---|
76 | } |
---|
77 | |
---|
78 | function copyDirectory($src, $dist) { |
---|
79 | $this->arrInstallData["plugin_code"]['copy_directory'] = array( |
---|
80 | 'src' => $src, |
---|
81 | 'dist' => $dist |
---|
82 | ); |
---|
83 | } |
---|
84 | |
---|
85 | function removeFile($dist) { |
---|
86 | |
---|
87 | } |
---|
88 | |
---|
89 | function sql($sql, array $params) { |
---|
90 | $plugin_code = $this->arrPlugin['plugin_code']; |
---|
91 | $this->arrInstallData[$plugin_code]['sql'] = array( |
---|
92 | 'sql' => $sql, |
---|
93 | 'params' => $params |
---|
94 | ); |
---|
95 | } |
---|
96 | } |
---|