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

Revision 19711, 3.1 KB checked in by nanasess, 13 years ago (diff)
  • #748(モバイルのデザイン管理機能)
    • dtb_pagelayout, dtb_bloc, dtb_blocposition のプライマリーキー変更, device_type_id 追加
    • 管理画面のメニュー修正
Line 
1<?php
2
3class SC_Helper_Plugin{
4
5    /**
6     * enableかどうかを判別する
7     * インスタンス化
8     */
9    function load(LC_Page &$lcpage){
10        //データベースからクラス名を読み込む
11        $objQuery = new SC_Query();
12        $col = "*";
13        $table = "dtb_plugin";
14        $where = "enable = 1 AND del_flg = 0";
15        $arrRet = $objQuery->select($col, $table, $where);
16        $class_name = get_class($lcpage);
17
18        // 実行されたぺーじ
19        // 現在のページで使用するプラグインが存在するかどうかを検証する
20        foreach ($arrRet as $plugins){
21            // プラグインを稼働させるクラス名のリストを取得する
22            // プラグインのディレクトリ内の設定ファイルを参照する
23            $plugin_name = $plugins['name'];
24            $plugin_class_name = $plugins['class_name'];
25            require_once DATA_PATH."plugin/{$plugin_name}/{$plugin_class_name}.php";
26
27            $code_str = "\$is_enable = {$plugin_class_name}::is_enable(\$class_name);";
28            eval($code_str);
29            if ($is_enable) {
30                $arrPluginList[] = $plugin_class_name;
31            }
32        }
33        return $arrPluginList;
34    }
35
36    function preProcess(LC_Page &$lcpage){
37        //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
38        $arrPluginList = SC_Helper_Plugin::load($lcpage);
39       if(count($arrPluginList) > 0){
40            foreach ($arrPluginList as $key => $value){
41                $instance = new $value;
42                $instance->preProcess($lcpage);
43            }
44        }
45        return $lcpage;
46    }
47
48    /* 読み込んだプラグインの実行用メソッド
49     *
50     */
51    function process(LC_Page &$lcpage){
52        //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
53        $arrPluginList = SC_Helper_Plugin::load($lcpage);
54        if(count($arrPluginList) > 0){
55            foreach ($arrPluginList as $key => $value){
56                $instance = new $value;
57                $instance->process($lcpage);
58            }
59        }
60        return $lcpage;
61    }
62
63    /**
64     * 稼働中のプラグインを取得する。
65     */
66    function getEnablePlugin(){
67        $objQuery = new SC_Query();
68        $col = '*';
69        $table = 'dtb_plugin';
70        $where = 'enable = 1 AND del_flg = 0';
71        $arrRet = $objQuery->select($col,$table,$where);
72        return $arrRet;
73    }
74
75    /**
76     * インストールされているプラグインを取得する。
77     */
78    function getAllPlugin(){
79        $objQuery = new SC_Query();
80        $col = '*';
81        $table = 'dtb_plugin';
82        $where = 'del_flg = 0';
83        $arrRet = $objQuery->select($col,$table,$where);
84        return $arrRet;
85    }
86
87    function getFilesystemPlugins(){
88        $plugin_dir = DATA_PATH."/plugin/";
89        if($dh = opendir($plugin_dir)){
90            while(($file = readdir($dh) !== false)){
91                if(is_dir($plugin_dir."/".$file)){
92                }
93            }
94        }
95    }
96}
Note: See TracBrowser for help on using the repository browser.