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

Revision 19802, 5.4 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部改修

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_PATH . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * システム情報 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id: LC_Page_Admin_System_System.php 18701 2010-06-14 08:30:18Z nanasess $
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        var_dump($_POST);
61        $objForm->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
62        $objForm->addParam('plugin_name', 'plugin_name', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
63
64        $objForm->setParam($_POST);
65        $this->objForm = $objForm;
66    }
67
68    /**
69     * Page のプロセス.
70     *
71     * @return void
72     */
73    function process() {
74        $this->action();
75        $this->sendResponse();
76    }
77
78    /**
79     * Page のアクション.
80     *
81     * @return void
82     */
83    function action() {
84        SC_Utils_Ex::sfIsSuccess(new SC_Session);
85        $this->initForm();
86        switch($this->objForm->getValue('mode')) {
87            // PHP INFOを表示
88            case 'install':
89                $name = $this->objForm->getValue('plugin_name');
90                require_once(DATA_FILE_PATH.'/plugin/'.$name.'/'.$name.'.php');
91                $plugin = new $name();
92                $plugin->install();
93                break;
94            case 'uninstall':
95                $name = $this->objForm->getValue('plugin_name');
96                require_once(DATA_FILE_PATH.'/plugin/'.$name.'/'.$name.'.php');
97                $plugin = new $name();
98                $plugin->uninstall();
99                break;
100            case 'enable':
101                $name = $this->objForm->getValue('plugin_name');
102                require_once(DATA_FILE_PATH.'/plugin/'.$name.'/'.$name.'.php');
103                $plugin = new $name();
104                $plugin->enable();
105               
106                break;
107            case 'disable':
108              $name = $this->objForm->getValue('plugin_name');
109                require_once(DATA_FILE_PATH.'/'.$name.'/'.$name.'.php');
110                $plugin = new $name();
111                $plugin->disable();
112                break;
113            default:
114                $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
115                $this->plugins = array_merge($plugins,
116                $this->getPluginOnFilesystem($plugins));
117                break;
118        }
119
120        $this->arrSystemInfo = $this->getSystemInfo();
121    }
122
123    /*
124     CREATE TABLE dtb_plugin (
125     plugin_id INT NOT NULL,
126     plugin_name VARCHAR(255) NOT NULL DEFAULT "",
127     enable INT NOT NULL DEFAULT 0,
128     del_flg INT NOT NULL DEFAULT 0,
129     class_name VARCHAR(255) NOT NULL DEFAULT NULL,
130     create_date DATETIME NOT NULL,
131     update_date DATETIME NOT NULL,
132     PRIMARY KEY (plugin_id)
133     ) TYPE=InnoDB;
134     */
135
136    function getPluginOnFilesystem($existsPlugins){
137
138        $dir = DATA_FILE_PATH."plugin/";
139        $arrPlugins = array();
140        if($dh =  opendir($dir)){
141            while(($file = readdir($dh)) !== false){
142                if(!preg_match('/^\\./', $file) && $file !='..' && filetype($dir.$file) == 'dir'){
143                    $arrPlugins[] = array('plugin_name'=>$file,'class_name'=>$file);
144
145                }
146            }
147        }
148        //        var_dump($arrPlugins);
149        return $arrPlugins;
150    }
151
152    /**
153     * デストラクタ.
154     *
155     * @return void
156     */
157    function destroy() {
158        parent::destroy();
159    }
160
161    /**
162     * システム情報を取得する
163     *
164     * @return array
165     */
166    function getSystemInfo() {
167        $objDB = SC_DB_DBFactory_Ex::getInstance();
168
169        $arrSystemInfo = array(
170        array('title' => 'EC-CUBE',  'value' => ECCUBE_VERSION),
171        array('title' => 'OS',       'value' => php_uname()),
172        array('title' => 'DBサーバ',  'value' => $objDB->sfGetDBVersion()),
173        array('title' => 'WEBサーバ', 'value' => $_SERVER['SERVER_SOFTWARE']),
174        array('title' => 'PHP',      'value' => phpversion()),
175        array('title' => 'GD',       'value' => extension_loaded('GD') ? 'Loaded' : '--'),
176        );
177
178        return $arrSystemInfo;
179    }
180}
Note: See TracBrowser for help on using the repository browser.