Source for file LC_Page_Admin_System_Plugin.php
Documentation is available at LC_Page_Admin_System_Plugin.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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
require_once CLASS_EX_REALDIR . 'helper_extends/SC_Helper_FileManager_Ex.php';
* @author LOCKON CO.,LTD.
* @version $Id: LC_Page_Admin_System_Plugin.php 21185 2011-08-11 10:37:10Z shutta $
$this->tpl_mainpage = 'system/plugin.tpl';
$this->tpl_subno = 'plugin';
$this->tpl_mainno = 'system';
$this->tpl_maintitle = 'システム設定';
$this->tpl_subtitle = 'プラグイン管理';
$objFormParam = new SC_FormParam_Ex();
$objFormParam->setParam($_POST);
$mode = $this->getMode();
$this->arrErr = $objFormParam->checkError();
if(count($this->arrErr) == 0) {
$plugin_id = $objFormParam->getValue('plugin_id');
$plugin_code = $objFormParam->getValue('plugin_code');
// プラグインファイルを読み込み、modeで指定されたメソッドを実行
$this->arrErr = $this->lfExecPlugin($plugin_id, $plugin_code, $mode);
$objUpFile = new SC_UploadFile_Ex(TEMPLATE_TEMP_REALDIR, $plugin_dir);
if(count($this->arrErr) == 0) {
$this->arrErr['plugin_file'] = $objUpFile->makeTempFile('plugin_file', false);
if($this->arrErr['plugin_file'] == "") {
$this->arrErr = $this->lfUploadPlugin($objUpFile, $plugin_dir, $plugin_code, $_FILES['plugin_file']['name']);
if(count($this->arrErr) == 0) {
$this->tpl_onload = "alert('プラグインをアップロードしました。');";
$this->arrErr = $objFormParam->checkError();
if(count($this->arrErr) == 0) {
$plugin_id = $objFormParam->getValue('plugin_id');
SC_Helper_DB_Ex::sfRankUp("dtb_plugin", "plugin_id", $plugin_id);
SC_Response_Ex::reload();
$this->arrErr = $objFormParam->checkError();
if(count($this->arrErr) == 0) {
$plugin_id = $objFormParam->getValue('plugin_id');
SC_Helper_DB_Ex::sfRankDown("dtb_plugin", "plugin_id", $plugin_id);
SC_Response_Ex::reload();
$this->plugins = SC_Helper_Plugin_Ex::getAllPlugin();
* @param object $objFormParam
$objFormParam->addParam('mode', 'mode', INT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
$objFormParam->addParam('plugin_id', 'plugin_id', INT_LEN, '', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
$objFormParam->addParam('plugin_code', 'plugin_code', MTEXT_LEN, '', array('ALPHA_CHECK', 'MAX_LENGTH_CHECK'));
* @param object $objUpFile SC_UploadFileのインスタンス.
$objUpFile->addFile("プラグイン", 'plugin_file', array('tar', 'tar.gz'), TEMPLATE_SIZE, true, 0, 0, false);
* @param string $plugin_code
* @param string $plugin_dir
* @return array エラー情報を格納した連想配列.
$plugins = SC_Helper_Plugin_Ex::getAllPlugin();
foreach($plugins as $val) {
if($val['plugin_code'] == $plugin_code) {
$arrErr['plugin_file'] = "※ 同名のプラグインがすでに登録されています。<br/>";
* (アップロードされたファイル名をプラグイン名(物理名)とする).
* @param string $upload_file_name
* @return string プラグイン名(物理名).
$array_ext = explode(".", $upload_file_name);
* @param string $plugin_code
* @return string プラグイン保存ディレクトリ.
$plugin_dir = DATA_REALDIR . 'plugin/' . $plugin_code . '/';
* @param string $plugin_code
* @return string プラグインファイルパス.
$plugin_file_path = $this->lfGetPluginDir($plugin_code) . $plugin_code . '.php';
return $plugin_file_path;
* @param object $objUpFile
* @param string $plugin_dir
* @param string $plugin_code
* @param string $plugin_file_name
* @return array エラー情報を格納した連想配列.
function lfUploadPlugin(&$objUpFile, $plugin_dir, $plugin_code, $plugin_file_name) {
$arrErr = $objUpFile->checkEXISTS('plugin_file');
if(count($arrErr) == 0) {
$arrErr['plugin_file'] = "※ 同名のディレクトリがすでに存在します。<br/>";
if(count($arrErr) == 0) {
// 一時ディレクトリからプラグイン保存ディレクトリへ移動
$objUpFile->moveTempFile();
SC_Helper_FileManager_Ex::unpackFile($plugin_dir . $plugin_file_name);
* @param string $plugin_dir
* @param string $plugin_code
$objQuery = & SC_Query_Ex::getSingletonInstance();
$sqlval['plugin_id'] = $objQuery->nextVal('dtb_plugin_plugin_id');
$sqlval['plugin_code'] = $plugin_code;
$sqlval['rank'] = 1 + $objQuery->max('rank', 'dtb_plugin');
$sqlval['status'] = PLUGIN_STATUS_UPLOADED;
$sqlval['enable'] = PLUGIN_ENABLE_FALSE;
$sqlval['update_date'] = 'CURRENT_TIMESTAMP';
$objQuery->insert('dtb_plugin', $sqlval);
* @param string $plugin_code
* @return array エラー情報を格納した連想配列.
require_once $plugin_file_path;
$arrErr['plugin_error'] = "※ " . $plugin_code . ".phpが存在しないため実行できません。<br/>";
* プラグインファイルを読み込み、指定されたメソッドを実行する.
* @param integer $plugin_id
* @param string $plugin_code
* @param string $exec_mode プラグイン実行メソッド名.
* @return array エラー情報を格納した連想配列.
function lfExecPlugin($plugin_id, $plugin_code, $exec_mode) {
if(count($arrErr) == 0) {
$plugin = new $plugin_code();
$arrErr = $plugin->$exec_mode($plugin_id);
Documentation generated on Fri, 24 Feb 2012 14:01:51 +0900 by Seasoft
|