source: branches/version-2_5-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php @ 20116

Revision 20116, 5.3 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2010 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
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * システム情報 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_System_Plugin extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'system/plugin.tpl';
47        $this->tpl_subnavi  = 'system/subnavi.tpl';
48        $this->tpl_subno    = 'plugin';
49        $this->tpl_mainno   = 'system';
50        $this->tpl_subtitle = 'プラグイン管理';
51    }
52
53    /**
54     * フォームパラメータ初期化
55     *
56     * @return void
57     */
58    function initForm() {
59        $objForm = new SC_FormParam();
60        $objForm->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
61        $objForm->addParam('plugin_name', 'plugin_name', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
62
63        $objForm->setParam($_POST);
64        $this->objForm = $objForm;
65    }
66
67    /**
68     * Page のプロセス.
69     *
70     * @return void
71     */
72    function process() {
73        $this->action();
74        $this->sendResponse();
75    }
76
77    /**
78     * Page のアクション.
79     *
80     * @return void
81     */
82    function action() {
83        SC_Utils_Ex::sfIsSuccess(new SC_Session);
84        $this->initForm();
85        switch($this->getMode()) {
86            // PHP INFOを表示
87            case 'install':
88                $name = $this->objForm->getValue('plugin_name');
89                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
90                $plugin = new $name();
91                $plugin->install();
92                break;
93            case 'uninstall':
94                $name = $this->objForm->getValue('plugin_name');
95                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
96                $plugin = new $name();
97                $plugin->uninstall();
98                break;
99            case 'enable':
100                $name = $this->objForm->getValue('plugin_name');
101                require_once(DATA_REALDIR.'/plugin/'.$name.'/'.$name.'.php');
102                $plugin = new $name();
103                $plugin->enable();
104
105                break;
106            case 'disable':
107              $name = $this->objForm->getValue('plugin_name');
108                require_once(DATA_REALDIR.'/'.$name.'/'.$name.'.php');
109                $plugin = new $name();
110                $plugin->disable();
111                break;
112            default:
113                $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
114                $this->plugins = array_merge($plugins,
115                $this->getPluginOnFilesystem($plugins));
116                break;
117        }
118
119        $this->arrSystemInfo = $this->getSystemInfo();
120    }
121
122    /*
123     CREATE TABLE dtb_plugin (
124     plugin_id INT NOT NULL,
125     plugin_name VARCHAR(255) NOT NULL DEFAULT "",
126     enable INT NOT NULL DEFAULT 0,
127     del_flg INT NOT NULL DEFAULT 0,
128     class_name VARCHAR(255) NOT NULL DEFAULT NULL,
129     create_date DATETIME NOT NULL,
130     update_date DATETIME NOT NULL,
131     PRIMARY KEY (plugin_id)
132     ) TYPE=InnoDB;
133     */
134
135    function getPluginOnFilesystem($existsPlugins){
136
137        $dir = DATA_REALDIR."plugin/";
138        $arrPlugins = array();
139        if($dh =  opendir($dir)){
140            while(($file = readdir($dh)) !== false){
141                if(!preg_match('/^\\./', $file) && $file !='..' && filetype($dir.$file) == 'dir'){
142                    $arrPlugins[] = array('plugin_name'=>$file,'class_name'=>$file);
143
144                }
145            }
146        }
147        //        var_dump($arrPlugins);
148        return $arrPlugins;
149    }
150
151    /**
152     * デストラクタ.
153     *
154     * @return void
155     */
156    function destroy() {
157        parent::destroy();
158    }
159
160    /**
161     * システム情報を取得する
162     *
163     * @return array
164     */
165    function getSystemInfo() {
166        $objDB = SC_DB_DBFactory_Ex::getInstance();
167
168        $arrSystemInfo = array(
169        array('title' => 'EC-CUBE',  'value' => ECCUBE_VERSION),
170        array('title' => 'OS',       'value' => php_uname()),
171        array('title' => 'DBサーバ',  'value' => $objDB->sfGetDBVersion()),
172        array('title' => 'WEBサーバ', 'value' => $_SERVER['SERVER_SOFTWARE']),
173        array('title' => 'PHP',      'value' => phpversion()),
174        array('title' => 'GD',       'value' => extension_loaded('GD') ? 'Loaded' : '--'),
175        );
176
177        return $arrSystemInfo;
178    }
179}
Note: See TracBrowser for help on using the repository browser.