[Svn-src-all:2782] [version-2_12-dev 21681] #1692 SC_Helper_Pluginをエンジン部分とプラグイン用Util系クラスに分離
h_yoshimoto
admin @ mail.ec-cube.net
2012年 3月 26日 (月) 20:32:15 JST
Subversion committed to /home/svn/open 21681
http://svn.ec-cube.net/open_trac/changeset/21681
┌────────────────────────────┐
│更新者 : h_yoshimoto │
│更新日時: 2012-03-26 20:32:15 +0900 (月, 26 3月 2012)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#1692 SC_Helper_Pluginをエンジン部分とプラグイン用Util系クラスに分離
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php
U branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php
A branches/version-2_12-dev/data/class/plugin/
A branches/version-2_12-dev/data/class/plugin/SC_Plugin_Util.php
A branches/version-2_12-dev/data/class_extends/plugin_extends/
A branches/version-2_12-dev/data/class_extends/plugin_extends/SC_Plugin_Util_Ex.php
U branches/version-2_12-dev/html/admin/load_plugin_config.php
変更: branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php 2012-03-26 10:13:20 UTC (rev 21680)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Plugin.php 2012-03-26 11:32:15 UTC (rev 21681)
@@ -49,10 +49,9 @@
if (GC_Utils_Ex::isInstallFunction()) return; // インストール中
if ($plugin_activate_flg === false) return;
// 有効なプラグインを取得
- $arrPluginDataList = $this->getEnablePlugin();
+ $arrPluginDataList = SC_Plugin_Util_Ex::getEnablePlugin();
// pluginディレクトリを取得
- $arrPluginDirectory = $this->getPluginDirectory();
-
+ $arrPluginDirectory = SC_Plugin_Util_Ex::getPluginDirectory();
foreach ($arrPluginDataList as $arrPluginData) {
// プラグイン本体ファイル名が取得したプラグインディレクトリ一覧にある事を確認
if (array_search($arrPluginData['plugin_code'], $arrPluginDirectory) !== false) {
@@ -114,103 +113,6 @@
}
/**
- * 稼働中のプラグインを取得する。
- */
- function getEnablePlugin() {
- $objQuery = new SC_Query_Ex();
- $col = '*';
- $table = 'dtb_plugin';
- $where = 'enable = 1';
- // XXX 2.11.0 互換のため
- $arrCols = $objQuery->listTableFields($table);
- if (in_array('priority', $arrCols)) {
- $objQuery->setOrder('priority DESC, plugin_id ASC');
- }
- $arrRet = $objQuery->select($col,$table,$where);
- return $arrRet;
- }
-
- /**
- * インストールされているプラグインを取得する。
- *
- * @return array $arrRet インストールされているプラグイン.
- */
- function getAllPlugin() {
- $objQuery = new SC_Query_Ex();
- $col = '*';
- $table = 'dtb_plugin';
- // XXX 2.11.0 互換のため
- $arrCols = $objQuery->listTableFields($table);
- if (in_array('priority', $arrCols)) {
- $objQuery->setOrder('plugin_id ASC');
- }
- $arrRet = $objQuery->select($col,$table);
- return $arrRet;
- }
-
- /**
- * プラグインIDをキーにプラグインを取得する。
- *
- * @param int $plugin_id プラグインID.
- * @return array プラグインの基本情報.
- */
- function getPluginByPluginId($plugin_id) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $col = '*';
- $table = 'dtb_plugin';
- $where = 'plugin_id = ?';
- $plugin = $objQuery->getRow($col, $table, $where, array($plugin_id));
- return $plugin;
- }
-
- /**
- * プラグインコードをキーにプラグインを取得する。
- *
- * @param string $plugin_code プラグインコード.
- * @return array プラグインの基本情報.
- */
- function getPluginByPluginCode($plugin_code) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $col = '*';
- $table = 'dtb_plugin';
- $where = 'plugin_code = ?';
- $plugin = $objQuery->getRow($col, $table, $where, array($plugin_code));
- return $plugin;
- }
-
- /**
- * プラグインIDをキーにプラグインを削除する。
- *
- * @param string $plugin_id プラグインID.
- * @return array プラグインの基本情報.
- */
- function deletePluginByPluginId($plugin_id) {
- $objQuery =& SC_Query_Ex::getSingletonInstance();
- $objQuery->begin();
- $where = 'plugin_id = ?';
- $objQuery->delete('dtb_plugin', $where, array($plugin_id));
- $objQuery->delete('dtb_plugin_hookpoint', $where, array($plugin_id));
- }
-
- /**
- * プラグインディレクトリの取得
- *
- * @return array $arrPluginDirectory
- */
- function getPluginDirectory() {
- $arrPluginDirectory = array();
- if (is_dir(PLUGIN_UPLOAD_REALDIR)) {
- if ($dh = opendir(PLUGIN_UPLOAD_REALDIR)) {
- while (($pluginDirectory = readdir($dh)) !== false) {
- $arrPluginDirectory[] = $pluginDirectory;
- }
- closedir($dh);
- }
- }
- return $arrPluginDirectory;
- }
-
- /**
* スーパーフックポイントを登録します.
*
* @param Object $objPlugin プラグインのインスタンス
変更: branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php 2012-03-26 10:13:20 UTC (rev 21680)
+++ branches/version-2_12-dev/data/class/pages/admin/system/LC_Page_Admin_System_Plugin.php 2012-03-26 11:32:15 UTC (rev 21681)
@@ -98,7 +98,7 @@
$this->arrErr = $objFormParam->checkError();
if ($this->isError($this->arrErr) === false) {
$plugin_id = $objFormParam->getValue('plugin_id');
- $plugin = SC_Helper_Plugin_Ex::getPluginByPluginId($plugin_id);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id);
$this->arrErr = $this->uninstallPlugin($plugin);
if ($this->isError($this->arrErr) === false) {
// コンパイルファイルのクリア処理
@@ -115,7 +115,7 @@
if ($this->isError($this->arrErr) === false) {
$plugin_id = $objFormParam->getValue('plugin_id');
// プラグイン取得.
- $plugin = SC_Helper_Plugin_Ex::getPluginByPluginId($plugin_id);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id);
$this->arrErr = $this->enablePlugin($plugin);
if ($this->isError($this->arrErr) === false) {
// コンパイルファイルのクリア処理
@@ -131,8 +131,8 @@
if ($this->isError($this->arrErr) === false) {
$plugin_id = $objFormParam->getValue('plugin_id');
// プラグイン取得.
- $plugin = SC_Helper_Plugin_Ex::getPluginByPluginId($plugin_id);
- $this->arrErr = $this->disablePlugin($plugin);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id);
+ $this->arrErr = $this->disablePlugin($plugin);
if ($this->isError($this->arrErr) === false) {
// コンパイルファイルのクリア処理
SC_Utils_Ex::clearCompliedTemplate();
@@ -152,7 +152,7 @@
$update_plugin_file = $_FILES[$target_plugin_code];
$update_plugin_file_name = $update_plugin_file['name']; // アップデートファイルのファイル名.
// インストール処理.
- $target_plugin = SC_Helper_Plugin_Ex::getPluginByPluginCode($target_plugin_code);
+ $target_plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($target_plugin_code);
$this->arrErr = $this->updatePlugin($target_plugin, $update_plugin_file_name, $target_plugin_code);
if ($this->isError($this->arrErr) === false) {
// コンパイルファイルのクリア処理
@@ -182,9 +182,8 @@
default:
break;
}
-
// DBからプラグイン情報を取得
- $plugins = SC_Helper_Plugin_Ex::getAllPlugin();
+ $plugins = SC_Plugin_Util_Ex::getAllPlugin();
foreach ($plugins as $key => $plugin) {
// 設定ファイルがあるかを判定.
@@ -259,7 +258,7 @@
* @return boolean インストール済の場合true インストールされていない場合false
*/
function isInstalledPlugin($plugin_code) {
- $plugin = SC_Helper_Plugin_Ex::getPluginByPluginCode($plugin_code);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($plugin_code);
if (!empty($plugin)) {
return true;
}
@@ -373,7 +372,7 @@
SC_Utils_Ex::copyDirectory(DOWNLOADS_TEMP_PLUGIN_INSTALL_DIR, $plugin_dir_path);
// プラグイン情報を取得
- $plugin = SC_Helper_Plugin_Ex::getPluginByPluginCode($plugin_code);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($plugin_code);
// クラスファイルを読み込み.
$plugin_class_file_path = $plugin_dir_path . $plugin['class_name'] . '.php';
@@ -409,7 +408,7 @@
// 一時ディレクトリを削除.
SC_Utils_Ex::deleteFile($temp_dir, false);
// DBからプラグイン情報を削除
- if(empty($plugin_id) === false) SC_Helper_Plugin_Ex::deletePluginByPluginId($plugin_id);
+ if(empty($plugin_id) === false) SC_Plugin_Util_Ex::deletePluginByPluginId($plugin_id);
// htmlディレクトリを削除
if(empty($plugin_html_dir) === false) SC_Utils_Ex::deleteFile($plugin_html_dir, true);
}
コピーによる追加: branches/version-2_12-dev/data/class/plugin/SC_Plugin_Util.php (コピー元: リビジョン 21677, branches/version-2_12-dev/data/class/graph/SC_Graph_Bar.php)
===================================================================
--- branches/version-2_12-dev/data/class/plugin/SC_Plugin_Util.php (rev 0)
+++ branches/version-2_12-dev/data/class/plugin/SC_Plugin_Util.php 2012-03-26 11:32:15 UTC (rev 21681)
@@ -0,0 +1,126 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+// 棒グラフ生成クラス
+class SC_Plugin_Util {
+
+
+
+ /**
+ * 稼働中のプラグインを取得する。
+ */
+ function getEnablePlugin() {
+ $objQuery = new SC_Query_Ex();
+ $col = '*';
+ $table = 'dtb_plugin';
+ $where = 'enable = 1';
+ // XXX 2.11.0 互換のため
+ $arrCols = $objQuery->listTableFields($table);
+ if (in_array('priority', $arrCols)) {
+ $objQuery->setOrder('priority DESC, plugin_id ASC');
+ }
+ $arrRet = $objQuery->select($col,$table,$where);
+ return $arrRet;
+ }
+
+ /**
+ * インストールされているプラグインを取得する。
+ *
+ * @return array $arrRet インストールされているプラグイン.
+ */
+ function getAllPlugin() {
+ $objQuery = new SC_Query_Ex();
+ $col = '*';
+ $table = 'dtb_plugin';
+ // XXX 2.11.0 互換のため
+ $arrCols = $objQuery->listTableFields($table);
+ if (in_array('priority', $arrCols)) {
+ $objQuery->setOrder('plugin_id ASC');
+ }
+ $arrRet = $objQuery->select($col,$table);
+ return $arrRet;
+ }
+
+ /**
+ * プラグインIDをキーにプラグインを取得する。
+ *
+ * @param int $plugin_id プラグインID.
+ * @return array プラグインの基本情報.
+ */
+ function getPluginByPluginId($plugin_id) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $table = 'dtb_plugin';
+ $where = 'plugin_id = ?';
+ $plugin = $objQuery->getRow($col, $table, $where, array($plugin_id));
+ return $plugin;
+ }
+
+
+ /**
+ * プラグインコードをキーにプラグインを取得する。
+ *
+ * @param string $plugin_code プラグインコード.
+ * @return array プラグインの基本情報.
+ */
+ function getPluginByPluginCode($plugin_code) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $col = '*';
+ $table = 'dtb_plugin';
+ $where = 'plugin_code = ?';
+ $plugin = $objQuery->getRow($col, $table, $where, array($plugin_code));
+ return $plugin;
+ }
+
+ /**
+ * プラグインIDをキーにプラグインを削除する。
+ *
+ * @param string $plugin_id プラグインID.
+ * @return array プラグインの基本情報.
+ */
+ function deletePluginByPluginId($plugin_id) {
+ $objQuery =& SC_Query_Ex::getSingletonInstance();
+ $objQuery->begin();
+ $where = 'plugin_id = ?';
+ $objQuery->delete('dtb_plugin', $where, array($plugin_id));
+ $objQuery->delete('dtb_plugin_hookpoint', $where, array($plugin_id));
+ }
+
+ /**
+ * プラグインディレクトリの取得
+ *
+ * @return array $arrPluginDirectory
+ */
+ function getPluginDirectory() {
+ $arrPluginDirectory = array();
+ if (is_dir(PLUGIN_UPLOAD_REALDIR)) {
+ if ($dh = opendir(PLUGIN_UPLOAD_REALDIR)) {
+ while (($pluginDirectory = readdir($dh)) !== false) {
+ $arrPluginDirectory[] = $pluginDirectory;
+ }
+ closedir($dh);
+ }
+ }
+ return $arrPluginDirectory;
+ }
+}
コピーによる追加: branches/version-2_12-dev/data/class_extends/plugin_extends/SC_Plugin_Util_Ex.php (コピー元: リビジョン 21677, branches/version-2_12-dev/data/class_extends/SC_AdminView_Ex.php)
===================================================================
--- branches/version-2_12-dev/data/class_extends/plugin_extends/SC_Plugin_Util_Ex.php (rev 0)
+++ branches/version-2_12-dev/data/class_extends/plugin_extends/SC_Plugin_Util_Ex.php 2012-03-26 11:32:15 UTC (rev 21681)
@@ -0,0 +1,27 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
+ *
+ * http://www.lockon.co.jp/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+require_once CLASS_REALDIR . 'plugin/SC_Plugin_Util.php';
+
+class SC_Plugin_Util_Ex extends SC_Plugin_Util {
+}
変更: branches/version-2_12-dev/html/admin/load_plugin_config.php
===================================================================
--- branches/version-2_12-dev/html/admin/load_plugin_config.php 2012-03-26 10:13:20 UTC (rev 21680)
+++ branches/version-2_12-dev/html/admin/load_plugin_config.php 2012-03-26 11:32:15 UTC (rev 21681)
@@ -39,8 +39,7 @@
if (!empty($plugin_id) && is_numeric($plugin_id)) {
GC_Utils::gfPrintLog('loading plugin ====> plugin_id = ' . $plugin_id);
- $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance(false);
- $plugin = $objPlugin->getPluginByPluginId($plugin_id);
+ $plugin = SC_Plugin_Util_Ex::getPluginByPluginId($plugin_id);
if (isset($plugin['plugin_code'])) {
$config_path = PLUGIN_UPLOAD_REALDIR . $plugin['plugin_code'] . '/config.php';
Svn-src-all メーリングリストの案内