source: branches/version-2_5-dev/data/class/helper/SC_Helper_Plugin.php @ 20484

Revision 20484, 4.0 KB checked in by shutta, 13 years ago (diff)

拡張クラス(/class_extends/)が存在するのに基底クラス(/class/)のメソッドを呼び出している部分を拡張クラスに書き換え。

  • 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/**
25 * プラグインのヘルパークラス.
26 *
27 * @package Helper
28 * @version $Id$
29 */
30class SC_Helper_Plugin{
31
32    /**
33     * enableかどうかを判別する
34     * インスタンス化
35     */
36    function load(&$lcpage){
37        //データベースからクラス名を読み込む
38        $objQuery = new SC_Query();
39        $col = "*";
40        $table = "dtb_plugin";
41        $where = "enable = 1 AND del_flg = 0";
42        $arrRet = $objQuery->select($col, $table, $where);
43        $class_name = get_class($lcpage);
44
45        // 実行されたぺーじ
46        // 現在のページで使用するプラグインが存在するかどうかを検証する
47        foreach ($arrRet as $plugins){
48            // プラグインを稼働させるクラス名のリストを取得する
49            // プラグインのディレクトリ内の設定ファイルを参照する
50            $plugin_name = $plugins['name'];
51            $plugin_class_name = $plugins['class_name'];
52            require_once DATA_REALDIR."plugin/{$plugin_name}/{$plugin_class_name}.php";
53
54            $code_str = "\$is_enable = {$plugin_class_name}::isEnable(\$class_name);";
55            eval($code_str);
56            if ($is_enable) {
57                $arrPluginList[] = $plugin_class_name;
58            }
59        }
60        return $arrPluginList;
61    }
62
63    function preProcess(&$lcpage){
64        //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
65        $arrPluginList = SC_Helper_Plugin_Ex::load($lcpage);
66       if(count($arrPluginList) > 0){
67            foreach ($arrPluginList as $key => $value){
68                $instance = new $value;
69                $instance->preProcess($lcpage);
70            }
71        }
72        return $lcpage;
73    }
74
75    /* 読み込んだプラグインの実行用メソッド
76     *
77     */
78    function process(&$lcpage){
79        //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
80        $arrPluginList = SC_Helper_Plugin_Ex::load($lcpage);
81        if(count($arrPluginList) > 0){
82            foreach ($arrPluginList as $key => $value){
83                $instance = new $value;
84                $instance->process($lcpage);
85            }
86        }
87        return $lcpage;
88    }
89
90    /**
91     * 稼働中のプラグインを取得する。
92     */
93    function getEnablePlugin(){
94        $objQuery = new SC_Query();
95        $col = '*';
96        $table = 'dtb_plugin';
97        $where = 'enable = 1 AND del_flg = 0';
98        $arrRet = $objQuery->select($col,$table,$where);
99        return $arrRet;
100    }
101
102    /**
103     * インストールされているプラグインを取得する。
104     */
105    function getAllPlugin(){
106        $objQuery = new SC_Query();
107        $col = '*';
108        $table = 'dtb_plugin';
109        $where = 'del_flg = 0';
110        $arrRet = $objQuery->select($col,$table,$where);
111        return $arrRet;
112    }
113
114    function getFilesystemPlugins(){
115        $plugin_dir = DATA_REALDIR."/plugin/";
116        if($dh = opendir($plugin_dir)){
117            while(($file = readdir($dh) !== false)){
118                if(is_dir($plugin_dir."/".$file)){
119                }
120            }
121        }
122    }
123}
Note: See TracBrowser for help on using the repository browser.