ディレクトリ構成
ファイル内容
config.php
<?php
require_once PLUGIN_UPLOAD_REALDIR . 'PluginName/LC_Page_Plugin_PluginName_Config.php';
$objPage = new LC_Page_Plugin_PluginName_Config();
register_shutdown_function(array(
$objPage,
'destroy'
));
$objPage -> init();
$objPage -> process();
LC_Page_Plugin_PluginName_Config.php
<?php
require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
class LC_Page_Plugin_PluginName_Config extends LC_Page_Admin_Ex {
var $plugin_name = "PluginName";
var $arrForm = array();
function init() {
parent::init();
$this -> tpl_mainpage = PLUGIN_UPLOAD_REALDIR . $this -> plugin_name . "/templates/config/index.tpl";
$this -> tpl_subtitle = "設定画面";
$this -> tpl_field1 = "項目1";
$this -> tpl_field2 = "項目2";
$this -> tpl_field3 = "項目3";
$this -> tpl_field4 = "項目4";
$this -> btn_regist = "登録";
$this -> th_label = "項目名";
$this -> th_input = "設定値";
}
function process() {
$this -> action();
$this -> sendResponse();
}
function action() {
$objFormParam = new SC_FormParam_Ex();
$this -> lfInitParam($objFormParam);
$objFormParam -> setParam($_POST);
$objFormParam -> convParam();
$arrForm = array();
switch ($this->getMode()) {
case 'edit' :
$arrForm = $objFormParam -> getHashArray();
$this -> arrErr = $objFormParam -> checkError();
if (count($this -> arrErr) == 0) {
$this -> arrErr = $this -> updateData($arrForm);
if (count($this -> arrErr) == 0) {
$this -> tpl_onload = "";
$this -> tpl_onload .= "alert('登録が完了しました。');";
$this -> tpl_onload .= 'window.close();';
}
}
break;
default :
$plugin = SC_Plugin_Util_Ex::getPluginByPluginCode($this -> plugin_name);
$arrForm['free_field1'] = $plugin['free_field1'];
$arrForm['free_field2'] = $plugin['free_field2'];
$arrForm['free_field3'] = $plugin['free_field3'];
$arrForm['free_field4'] = $plugin['free_field4'];
break;
}
$this -> arrForm = $arrForm;
$this -> setTemplate($this -> tpl_mainpage);
}
function destroy() {
parent::destroy();
}
function lfInitParam(&$objFormParam) {
$objFormParam -> addParam('項目1', 'free_field1', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
$objFormParam -> addParam('項目2', 'free_field2', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
$objFormParam -> addParam('項目3', 'free_field3', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
$objFormParam -> addParam('項目4', 'free_field4', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
}
function updateData($arrData) {
$arrErr = array();
$objQuery = &SC_Query_Ex::getSingletonInstance();
$objQuery -> begin();
$sqlval = array();
$sqlval['free_field1'] = $arrData['free_field1'];
$sqlval['free_field2'] = $arrData['free_field2'];
$sqlval['free_field3'] = $arrData['free_field3'];
$sqlval['free_field4'] = $arrData['free_field4'];
$sqlval['update_date'] = 'CURRENT_TIMESTAMP';
$where = "plugin_code = ?";
$whereVal = array($this -> plugin_name);
$objQuery -> update('dtb_plugin', $sqlval, $where, $whereVal);
$objQuery -> commit();
return $arrErr;
}
}
PluginName.php
<?php
class OrderPoint extends SC_Plugin_Base {
public function __construct(array $arrSelfInfo) {
parent::__construct($arrSelfInfo);
}
function install(array $arrPlugin, SC_Plugin_Installer $installer) {
$installer -> copyDirectory("html/", "");
}
function uninstall(array $arrPlugin, SC_Plugin_Installer $installer) {
}
function prefilter(&$source, LC_Page_Ex $objPage, $filename) {
$objTransform = new SC_Helper_Transform($source);
$source = $objTransform -> getHTML();
}
function admin_products_product_after($objectPage) {
}
function admin_products_product_class_after($objectPage) {
}
function admin_home_after($objectPage) {
}
}
plugin_info.php
<?php
class plugin_info {
static $PLUGIN_CODE = "PluginName";
static $PLUGIN_NAME = "PluginName";
static $PLUGIN_VERSION = "0.1";
static $COMPLIANT_VERSION = "2.13.x";
static $AUTHOR = "MyName";
static $DESCRIPTION = "プラグインの説明";
static $PLUGIN_SITE_URL = "/#ダウンロードサイト";
static $AUTHOR_SITE_URL = "/#作成者のサイト";
static $CLASS_NAME = "PluginName";
static $HOOK_POINTS = array(
array(
"prefilterTransform",
"prefilter"
),
array(
"LC_Page_Admin_Products_Product_action_after",
"admin_products_product_action_after"
),
array(
"LC_Page_Admin_Products_ProductClass_action_after",
"admin_products_product_class_after"
),
array(
"LC_Page_Admin_Home_action_after",
"admin_home_after"
)
);
static $LICENSE = "LGPL";
}