OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / container / baseInstallWidgetContainer.php
1 <?php
2 /**
3  * ウィジェットインストールコンテナ作成用ベースクラス
4  *
5  * PHP versions 5
6  *
7  * LICENSE: This source file is licensed under the terms of the GNU General Public License.
8  *
9  * @package    Magic3 Framework
10  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
11  * @copyright  Copyright 2006-2010 Magic3 Project.
12  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
13  * @version    SVN: $Id: baseInstallWidgetContainer.php 3187 2010-06-06 06:35:07Z fishbone $
14  * @link       http://www.magic3.org
15  */
16 require_once($gEnvManager->getContainerPath() . '/baseWidgetContainer.php');
17
18 class BaseInstallWidgetContainer extends BaseWidgetContainer
19 {
20         /**
21          * コンストラクタ
22          */
23         function __construct()
24         {
25                 // 親クラスを呼び出す
26                 parent::__construct();
27         }
28         /**
29          * 起動マネージャから呼ばれる唯一のメソッド
30          *
31          * @param RequestManager $request               HTTPリクエスト処理クラス
32          * @param int $install                                  インストール種別(0=インストール、1=アンインストール、2=アップグレード)
33          * @return                                                              なし
34          */
35         function process($request, $install)
36         {
37                 // 管理者権限がなければ実行できない
38                 if (!$this->gEnv->isSystemAdmin()) return;
39                 
40                 // スクリプト実行前処理
41                 if (method_exists($this, '_preScript')) $this->_preScript($request, $install);
42                 
43                 // スクリプト実行処理
44                 if (method_exists($this, '_doScript')){
45                         // 初期化フラグがオフの場合のみスクリプト処理を実行
46                         $widgetId = $this->gEnv->getCurrentWidgetId();
47                         $ret = $this->_db->getWidgetInfo($widgetId, $row);
48                         if ($ret){
49                                 $version = $row['wd_version'];          // ウィジェットのバージョン
50                                 if ($row['wd_initialized']){            // 初期化完了済み(再初期化禁止)
51                                         $this->setMsg(self::MSG_GUIDANCE, 'データの再初期化が禁止されているため、スクリプトは実行できません');
52                                 } else {
53                                         // 実行するスクリプトファイルを取得
54                                         $scriptFiles = $this->_doScript($request, $install, $version);
55                                         for ($i = 0; $i < count($scriptFiles); $i++){
56                                                 $scriptPath = $this->gEnv->getCurrentWidgetSqlPath() . '/' . $scriptFiles[$i];
57
58                                                 // スクリプト実行
59                                                 if ($this->gInstance->getDbManager()->execScriptWithConvert($scriptPath, $errors)){// 正常終了の場合
60                                                         $this->setMsg(self::MSG_GUIDANCE, 'スクリプト実行完了しました(ファイル名=' . $scriptFiles[$i] . ')');
61                                                 } else {
62                                                         $this->setMsg(self::MSG_APP_ERR, 'スクリプト実行に失敗しました(ファイル名=' . $scriptFiles[$i] . ')');
63                                                 }
64                                                 if (!empty($errors)){
65                                                         foreach ($errors as $error) {
66                                                                 $this->setMsg(self::MSG_APP_ERR, $error);
67                                                         }
68                                                 }
69                                         }
70                                 }
71                         }
72                 }
73                 
74                 // スクリプト実行後処理
75                 if (method_exists($this, '_postScript')) $this->_postScript($request, $install);
76                 
77                 // 出力メッセージをメッセージマネージャに設定
78                 $this->addMsgToGlobal();
79         }
80         /**
81          * メッセージテーブルにグローバルメッセージを追加する
82          *
83          * @return                              なし
84          */
85         function addMsgToGlobal()
86         {
87                 $this->gInstance->getMessageManager()->addMessage($this->errorMessage, $this->warningMessage, $this->guidanceMessage);
88         }
89 }
90 ?>