Helper
[ class tree: Helper ] [ index: Helper ] [ all elements ]

Source for file SC_Helper_Plugin.php

Documentation is available at SC_Helper_Plugin.php

  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) 2000-2011 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: SC_Helper_Plugin.php 20870 2011-04-20 07:13:08Z nanasess $
  29.  */
  30.  
  31.     /**
  32.      * enableかどうかを判別する
  33.      * インスタンス化
  34.      */
  35.     function load(&$lcpage){
  36.         //データベースからクラス名を読み込む
  37.         $objQuery new SC_Query_Ex();
  38.         $col "*";
  39.         $table "dtb_plugin";
  40.         $where "enable = 1 AND del_flg = 0";
  41.         // XXX 2.11.0 互換のため
  42.         $arrCols $objQuery->listTableFields($table);
  43.         if (in_array('rank'$arrCols)) {
  44.             $objQuery->setOrder('rank');
  45.         }
  46.         $arrRet $objQuery->select($col$table$where);
  47.         $class_name get_class($lcpage);
  48.  
  49.         // 現在のページで使用するプラグインが存在するかどうかを検証する
  50.         foreach ($arrRet as $plugins){
  51.             // プラグインを稼働させるクラス名のリストを取得する
  52.             // プラグインのディレクトリ内の設定ファイルを参照する
  53.             $plugin_name $plugins['plugin_name'];
  54.             $plugin_class_name $plugins['class_name'];
  55.             $plugin_path DATA_REALDIR "plugin/{$plugin_name}/{$plugin_class_name}.php";
  56.  
  57.             if (file_exists($plugin_path)) {
  58.                 require_once $plugin_path;
  59.                 if (class_exists($class_name)) {
  60.                     $code_str "\$is_enable = {$plugin_class_name}::isEnable(\$class_name);";
  61.                     eval($code_str);
  62.                     if ($is_enable{
  63.                         $arrPluginList[$plugin_class_name;
  64.                         GC_Utils_Ex::gfDebugLog($class_name ' で、プラグイン ' $plugin_name ' をロードしました');
  65.                     else {
  66.                         GC_Utils_Ex::gfDebugLog($class_name ' で、プラグイン ' $plugin_name ' は無効になっています');
  67.                     }
  68.                 else {
  69.                     GC_Utils_Ex::gfDebugLog('プラグイン ' $plugin_name ' の ' $class_name ' が見つかりませんでした');
  70.                 }
  71.             else {
  72.                 GC_Utils_Ex::gfDebugLog('プラグイン ' $plugin_name " が読み込めませんでした。\n"
  73.                                         . 'Failed opening required ' $plugin_path);
  74.             }
  75.         }
  76.         return $arrPluginList;
  77.     }
  78.  
  79.     function preProcess(&$lcpage){
  80.         //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
  81.         $arrPluginList SC_Helper_Plugin_Ex::load($lcpage);
  82.        if(count($arrPluginList0){
  83.             foreach ($arrPluginList as $key => $value){
  84.                 $instance new $value;
  85.                 $instance->preProcess($lcpage);
  86.             }
  87.         }
  88.         return $lcpage;
  89.     }
  90.  
  91.     /* 読み込んだプラグインの実行用メソッド
  92.      *
  93.      */
  94.     function process(&$lcpage){
  95.         //プラグインの名前を判別してページ内で有効なプラグインがあれば実行する
  96.         $arrPluginList SC_Helper_Plugin_Ex::load($lcpage);
  97.         if(count($arrPluginList0){
  98.             foreach ($arrPluginList as $key => $value){
  99.                 $instance new $value;
  100.                 $instance->process($lcpage);
  101.             }
  102.         }
  103.         return $lcpage;
  104.     }
  105.  
  106.     /**
  107.      * 稼働中のプラグインを取得する。
  108.      */
  109.     function getEnablePlugin(){
  110.         $objQuery new SC_Query_Ex();
  111.         $col '*';
  112.         $table 'dtb_plugin';
  113.         $where 'enable = 1 AND del_flg = 0';
  114.         // XXX 2.11.0 互換のため
  115.         $arrCols $objQuery->listTableFields($table);
  116.         if (in_array('rank'$arrCols)) {
  117.             $objQuery->setOrder('rank DESC');
  118.         }
  119.         $arrRet $objQuery->select($col,$table,$where);
  120.         return $arrRet;
  121.     }
  122.  
  123.     /**
  124.      * インストールされているプラグインを取得する。
  125.      */
  126.     function getAllPlugin(){
  127.         $objQuery new SC_Query_Ex();
  128.         $col '*';
  129.         $table 'dtb_plugin';
  130.         $where 'del_flg = 0';
  131.         // XXX 2.11.0 互換のため
  132.         $arrCols $objQuery->listTableFields($table);
  133.         if (in_array('rank'$arrCols)) {
  134.             $objQuery->setOrder('rank DESC');
  135.         }
  136.         $arrRet $objQuery->select($col,$table,$where);
  137.         return $arrRet;
  138.     }
  139.  
  140.     function getFilesystemPlugins(){
  141.         $plugin_dir DATA_REALDIR."/plugin/";
  142.         if($dh opendir($plugin_dir)){
  143.             while(($file readdir($dh!== false)){
  144.                 if(is_dir($plugin_dir."/".$file)){
  145.                 }
  146.             }
  147.         }
  148.     }
  149. }

Documentation generated on Fri, 24 Feb 2012 14:02:46 +0900 by Seasoft