source: branches/camp/camp-2_5-E/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php @ 19438

Revision 19438, 5.5 KB checked in by miningbrownie, 14 years ago (diff)

auto commit by watch

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/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        $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    /**
69     * Page のプロセス.
70     *
71     * @return void
72     */
73    function process() {
74        SC_Utils_Ex::sfIsSuccess(new SC_Session);
75        $objView = new SC_AdminView();
76        $this->initForm();
77        switch($this->objForm->getValue('mode')) {
78            // PHP INFOを表示
79            case 'install':
80                $objQuery = new SC_Query();
81                $name = $objForm->getValue('plugin_name');
82                $arrPlugins = $objQuery->get("dtb_plugin", "plugin_id", "plugin_name = ?",array($name));
83                require_once(DATA_PATH.'/'.$name.'/'.$name.'.php');
84                $plugin = new $name();
85                if(count($arrPlugins) == 0){
86                    //新規インストール
87                   
88                    $data = array(
89                      'plugin_name' => $objForm->getValue('plugin_name'),
90                      'path' => realpath(DATA_DIR.'/plugin/'.$objForm->getValue('plugin_name').'/'),
91                    'enable' => '1',
92                    'del_flg' => '0',
93                  'class_name' => $objForm->getValue('plugin_name'),
94                    'version' =>
95
96                    );
97                    $objQuery->insert("dtb_plugin", $data);
98                }else{
99                    //再インストール
100
101                }
102                break;
103            case 'uninstall':
104
105                break;
106            case 'enable':
107
108                break;
109            case 'disable':
110
111                break;
112            default:
113                $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
114                $this->plugins = array_merge($plugins,
115                $this->getPluginOnFilesystem($plugins));
116
117                var_dump($this->plugins);
118                break;
119        }
120
121        $this->arrSystemInfo = $this->getSystemInfo();
122
123        $objView->assignobj($this);
124        $objView->display(MAIN_FRAME);
125    }
126
127    /*
128     CREATE TABLE dtb_plugin (
129     plugin_id INT NOT NULL,
130     plugin_name VARCHAR(255) NOT NULL DEFAULT "",
131     enable INT NOT NULL DEFAULT 0,
132     del_flg INT NOT NULL DEFAULT 0,
133     class_name VARCHAR(255) NOT NULL DEFAULT NULL,
134     create_date DATETIME NOT NULL,
135     update_date DATETIME NOT NULL,
136     PRIMARY KEY (plugin_id)
137     ) TYPE=InnoDB;
138     */
139
140    function getPluginOnFilesystem($existsPlugins){
141
142        $dir = DATA_PATH."plugin/";
143        $arrPlugins = array();
144        if($dh =  opendir($dir)){
145            while(($file = readdir($dh)) !== false){
146                if(!preg_match('/^\\./', $file) && $file !='..' && filetype($dir.$file) == 'dir'){
147                    $arrPlugins[] = array('plugin_name'=>$file,'class_name'=>$file);
148
149                }
150            }
151        }
152        //        var_dump($arrPlugins);
153        return $arrPlugins;
154    }
155
156    /**
157     * デストラクタ.
158     *
159     * @return void
160     */
161    function destroy() {
162        parent::destroy();
163    }
164
165    /**
166     * システム情報を取得する
167     *
168     * @return array
169     */
170    function getSystemInfo() {
171        $objDB = SC_DB_DBFactory_Ex::getInstance();
172
173        $arrSystemInfo = array(
174        array('title' => 'EC-CUBE',  'value' => ECCUBE_VERSION),
175        array('title' => 'OS',       'value' => php_uname()),
176        array('title' => 'DBサーバ',  'value' => $objDB->sfGetDBVersion()),
177        array('title' => 'WEBサーバ', 'value' => $_SERVER['SERVER_SOFTWARE']),
178        array('title' => 'PHP',      'value' => phpversion()),
179        array('title' => 'GD',       'value' => extension_loaded('GD') ? 'Loaded' : '--'),
180        );
181
182        return $arrSystemInfo;
183    }
184}
Note: See TracBrowser for help on using the repository browser.