Ignore:
Timestamp:
2012/03/26 20:32:15 (12 years ago)
Author:
h_yoshimoto
Message:

#1692 SC_Helper_Pluginをエンジン部分とプラグイン用Util系クラスに分離

Location:
branches/version-2_12-dev/data/class/plugin
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • branches/version-2_12-dev/data/class/plugin/SC_Plugin_Util.php

    r21490 r21681  
    2323 
    2424// 棒グラフ生成クラス 
    25 class SC_Graph_Bar extends SC_Graph_Line{ 
    26     // コンストラクタ 
    27     function SC_Graph_Line( 
    28         $bgw = BG_WIDTH, $bgh = BG_HEIGHT, $left = LINE_LEFT, $top = LINE_TOP, 
    29         $area_width = LINE_AREA_WIDTH, $area_height = LINE_AREA_HEIGHT) { 
    30         parent::SC_Graph_Line($bgw, $bgh, $left, $top, $area_width, $area_height); 
     25class SC_Plugin_Util { 
     26     
     27     
     28     
     29    /** 
     30     * 稼働中のプラグインを取得する。 
     31     */ 
     32    function getEnablePlugin() { 
     33        $objQuery = new SC_Query_Ex(); 
     34        $col = '*'; 
     35        $table = 'dtb_plugin'; 
     36        $where = 'enable = 1'; 
     37        // XXX 2.11.0 互換のため 
     38        $arrCols = $objQuery->listTableFields($table); 
     39        if (in_array('priority', $arrCols)) { 
     40            $objQuery->setOrder('priority DESC, plugin_id ASC'); 
     41        } 
     42        $arrRet = $objQuery->select($col,$table,$where); 
     43        return $arrRet; 
    3144    } 
    3245 
    33     // グラフの描画 
    34     function drawGraph() { 
    35         $this->drawYLine(); 
    36         $this->drawXLine(true); 
    37  
    38         // 棒グラフの描画 
    39         for ($i = 0; $i < $this->line_max; $i++) { 
    40             $this->drawBar($i); 
     46    /** 
     47     * インストールされているプラグインを取得する。 
     48     *  
     49     * @return array $arrRet インストールされているプラグイン. 
     50     */ 
     51    function getAllPlugin() { 
     52        $objQuery = new SC_Query_Ex(); 
     53        $col = '*'; 
     54        $table = 'dtb_plugin'; 
     55        // XXX 2.11.0 互換のため 
     56        $arrCols = $objQuery->listTableFields($table); 
     57        if (in_array('priority', $arrCols)) { 
     58            $objQuery->setOrder('plugin_id ASC'); 
    4159        } 
    42  
    43         // ラベルの描画 
    44         for ($i = 0; $i < $this->line_max; $i++) { 
    45             $this->drawLabel($i); 
    46         } 
    47  
    48         // 凡例の描画 
    49         $this->drawLegend(); 
     60        $arrRet = $objQuery->select($col,$table); 
     61        return $arrRet; 
    5062    } 
    5163 
    52     // 棒グラフの描画 
    53     function drawBar($line_no) { 
    54         $arrPointList = $this->arrPointList[$line_no]; 
    55         // データ数を数える 
    56         $count = count($arrPointList); 
    57         // 半目盛りの幅を求める 
    58         $half_scale = intval($this->area_width / ($count + 1) / 2); 
    59         // 目盛りの幅を求める 
    60         $scale_width = intval($this->area_width / ($count + 1)); 
    61         // 棒グラフのサイズを求める 
    62         $bar_width = intval(($scale_width - (BAR_PAD * 2)) / $this->line_max); 
    63         // 色数の取得 
    64         $c_max = count($this->arrColor); 
    65         for ($i = 0; $i < $count; $i++) { 
    66             $left = $arrPointList[$i][0] - $half_scale + BAR_PAD + ($bar_width * $line_no); 
    67             $top = $arrPointList[$i][1]; 
    68             $right = $left + $bar_width; 
    69             $bottom = $this->top + $this->area_height; 
    70  
    71             // 影の描画 
    72             if ($this->shade_on) { 
    73                 imagefilledrectangle($this->image, $left + 2, $top + 2, $right + 2, $bottom, $this->shade_color); 
    74             } 
    75             //imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[($i % $c_max)]); 
    76             imagefilledrectangle($this->image, $left, $top, $right, $bottom, $this->arrColor[$line_no]); 
    77             imagerectangle($this->image, $left, $top, $right, $bottom, $this->flame_color); 
    78         } 
     64    /** 
     65     * プラグインIDをキーにプラグインを取得する。 
     66     *  
     67     * @param int $plugin_id プラグインID. 
     68     * @return array プラグインの基本情報. 
     69     */ 
     70    function getPluginByPluginId($plugin_id) { 
     71        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     72        $col = '*'; 
     73        $table = 'dtb_plugin'; 
     74        $where = 'plugin_id = ?'; 
     75        $plugin = $objQuery->getRow($col, $table, $where, array($plugin_id)); 
     76        return $plugin; 
     77    } 
     78     
     79     
     80    /** 
     81     * プラグインコードをキーにプラグインを取得する。 
     82     *  
     83     * @param string $plugin_code プラグインコード. 
     84     * @return array プラグインの基本情報. 
     85     */ 
     86    function getPluginByPluginCode($plugin_code) { 
     87        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     88        $col = '*'; 
     89        $table = 'dtb_plugin'; 
     90        $where = 'plugin_code = ?'; 
     91        $plugin = $objQuery->getRow($col, $table, $where, array($plugin_code)); 
     92        return $plugin; 
    7993    } 
    8094 
    81     // ラベルを描画する 
    82     function drawLabel($line_no) { 
    83         $arrData = $this->arrDataList[$line_no]; 
    84         $arrPointList = $this->arrPointList[$line_no]; 
    85         $count = count($arrPointList); 
    86         for ($i = 0; $i < $count; $i++) { 
    87             $x = $arrPointList[$i][0]; 
    88             $y = $arrPointList[$i][1]; 
    89             $text_width = $this->getTextWidth(number_format($arrData[$i]), FONT_SIZE); 
    90             $y_pos = $y - FONT_SIZE - 5; 
    91             $x_pos = $x - $text_width / 2; 
    92             $this->setText(FONT_SIZE, $x_pos, $y_pos, number_format($arrData[$i])); 
    93         } 
     95    /** 
     96     * プラグインIDをキーにプラグインを削除する。 
     97     *  
     98     * @param string $plugin_id プラグインID. 
     99     * @return array プラグインの基本情報. 
     100     */ 
     101    function deletePluginByPluginId($plugin_id) { 
     102        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
     103        $objQuery->begin(); 
     104        $where = 'plugin_id = ?'; 
     105        $objQuery->delete('dtb_plugin', $where, array($plugin_id)); 
     106        $objQuery->delete('dtb_plugin_hookpoint', $where, array($plugin_id)); 
    94107    } 
    95108 
     109    /** 
     110     * プラグインディレクトリの取得 
     111     * 
     112     * @return array $arrPluginDirectory 
     113     */ 
     114    function getPluginDirectory() { 
     115        $arrPluginDirectory = array(); 
     116        if (is_dir(PLUGIN_UPLOAD_REALDIR)) { 
     117            if ($dh = opendir(PLUGIN_UPLOAD_REALDIR)) { 
     118                while (($pluginDirectory = readdir($dh)) !== false) { 
     119                    $arrPluginDirectory[] = $pluginDirectory; 
     120                } 
     121                closedir($dh); 
     122            } 
     123        } 
     124        return $arrPluginDirectory; 
     125    } 
    96126} 
Note: See TracChangeset for help on using the changeset viewer.