開発メモ

開発用のメモです。

新規登録簡略化プラグイン

プラグインコード

HOOK POINT METHOD
prefilterTransform prefilter
SC_FormParam_construct lfInitParam
LC_Page_Entry_action_before entryActionBefore
LC_Page_Entry_action_after entryActionAfter
LC_Page_Entry_Kiyaku_action_before entryKiyakuActionBefore
LC_Page_Entry_Kiyaku_action_after entryKiyakuActionAfter
<?php

class EntryCustomize extends SC_Plugin_Base {
    public $fields = array(
    // @formatter:off
    // @formatter:on
    );
    public $label = array(
    // @formatter:off
    // @formatter:on
    );

    /**
     * コンストラクター.
     * @param $arrSelfInfo array (auto set)
     */
    public function __construct(array $arrSelfInfo) {
        parent::__construct($arrSelfInfo);
    }

    /**
     * インストール処理.
     * @param $arrPlugin array (auto set)
     */
    function install(array $arrPlugin, SC_Plugin_Installer $installer) {
        $objQuery = &SC_Query::getSingletonInstance();
        $plugin_code = basename(__FILE__, ".php");
    }

    /**
     * アンインストール処理.
     * @param $arrPlugin array (auto set)
     */
    function uninstall(array $arrPlugin, SC_Plugin_Installer $installer) {
        $objQuery = &SC_Query::getSingletonInstance();
        $plugin_code = basename(__FILE__, ".php");
    }

    /**
     * 有効化処理.
     * @param $arrPlugin array (auto set)
     */
    function enable(array $arrPlugin, SC_Plugin_Installer $installer) {
    }

    /**
     * 無効化処理.
     * @param $arrPlugin array (auto set)
     */
    function disable(array $arrPlugin, SC_Plugin_Installer $installer) {
    }

    /**
     * 解析前処理.
     * @param &$source
     * @param $objPage LC_Page_Ex
     * @param $filename
     */
    function prefilter(&$source, LC_Page_Ex $objPage, $filename) {
        $objTransform = new SC_Helper_Transform($source);

        $template_dir = PLUGIN_UPLOAD_REALDIR . basename(__FILE__, ".php");
        try {
            switch($objPage->arrPageLayout['device_type_id']) {
                case  DEVICE_TYPE_MOBILE :
                    $template_dir = $template_dir . '/templates/mobile/';
                    switch($filename) {
                        default :
                            break;
                    }
                    break;
                case DEVICE_TYPE_SMARTPHONE :
                    $template_dir = $template_dir . '/templates/sphone/';
                    switch($filename) {
                        default :
                            break;
                    }
                    break;
                case DEVICE_TYPE_PC :
                    $template_dir = $template_dir . '/templates/default/';

                    switch($filename) {
                        case SMARTY_TEMPLATES_REALDIR . 'default/entry/index.tpl' :
                        case 'entry/index.tpl' :
                            $arKiyaku = $this -> lfGetKiyakuData();
                            $textKiyaku = $this -> lfMakeKiyakuText($arKiyaku, 0, count($arKiyaku));

                            $html = <<<EOL
<tr>
    <th>利用規約</th>
    <td>
        <textarea cols="80" rows="40">$textKiyaku</textarea>
    </td>
</tr>
EOL;
                            $objTransform -> select('table') -> appendChild($html);
                            break;
                        default :
                            break;
                    }
                    break;
                default :
                case DEVICE_TYPE_ADMIN :
                    $template_dir = $template_dir . '/templates/admin/';
                    switch($filename) {
                        default :
                            break;
                    }
                    break;
            }
        } catch (Exception $e) {
            error_log(var_export($e));
        }
        $source = $objTransform -> getHTML();
    }

    /**
     * お問い合わせ入力時のパラメーター情報の初期化を行う.
     *
     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
     * @return void
     */
    public function lfInitParam($className = "", &$objFormParam = null) {
        if (isset($objFormParam)) {
            switch ($className) {
                case "LC_Page_Entry" :
                case "LC_Page_Entry_Kiyaku" :
                    $this -> LC_Page_Entry($objFormParam);
            }
        }
    }

    public function LC_Page_Entry(&$objFormParam) {
    }

    public function entryActionBefore(&$objPage) {
        $objFormParam = new SC_FormParam_Ex();
        $objFormParam -> setParam($_POST);
        $objFormParam -> convParam();

        switch ($objPage->getMode()) {
            default :
                $_SERVER['HTTP_REFERER'] = ROOT_URLPATH . 'entry/kiyaku.php';
                break;
        }
    }

    public function entryActionAfter(&$objPage) {
        $objFormParam = new SC_FormParam_Ex();
        $objFormParam -> setParam($_POST);
        $objFormParam -> convParam();

        switch ($objPage->getMode()) {
            default :
                break;
        }
    }

    public function entryKiyakuActionBefore(&$objPage) {
        $objFormParam = new SC_FormParam_Ex();
        $objFormParam -> setParam($_POST);
        $objFormParam -> convParam();

        switch ($objPage->getMode()) {
            default :
                switch($objPage->arrPageLayout['device_type_id']) {
                    case  DEVICE_TYPE_MOBILE :
                        break;
                    case DEVICE_TYPE_SMARTPHONE :
                        break;
                    case DEVICE_TYPE_PC :
                        break;
                    default :
                    case DEVICE_TYPE_ADMIN :
                        break;
                }
                break;
        }
    }

    public function entryKiyakuActionAfter(&$objPage) {
        $objFormParam = new SC_FormParam_Ex();
        $objFormParam -> setParam($_POST);
        $objFormParam -> convParam();

        switch ($objPage->getMode()) {
            default :
                switch($objPage->arrPageLayout['device_type_id']) {
                    case  DEVICE_TYPE_MOBILE :
                        break;
                    case DEVICE_TYPE_SMARTPHONE :
                        break;
                    case DEVICE_TYPE_PC :
                        SC_Response_Ex::sendRedirect(ENTRY_URL);
                        break;
                    default :
                    case DEVICE_TYPE_ADMIN :
                        break;
                }
                break;
        }
    }

    /**
     * 規約文の作成
     *
     * @param mixed $arrKiyaku
     * @param mixed $max
     * @param mixed $offset
     * @access public
     * @return string 規約の内容をテキストエリアで表示するように整形したデータ
     */
    public function lfMakeKiyakuText($arrKiyaku) {
        $this -> tpl_kiyaku_text = '';
        foreach ($arrKiyaku as $key => $value) {
            $tpl_kiyaku_text .= $value['kiyaku_title'] . "\n\n";
            $tpl_kiyaku_text .= $value['kiyaku_text'] . "\n\n";
        }

        return $tpl_kiyaku_text;
    }

    /**
     * 規約内容の取得
     *
     * @access private
     * @return array $arrKiyaku 規約の配列
     */
    public function lfGetKiyakuData() {
        $objKiyaku = new SC_Helper_Kiyaku_Ex();
        $arrKiyaku = $objKiyaku -> getList();

        return $arrKiyaku;
    }

}
Twitter: @asahina_alice