Example #1
0
/**
 *
 * convert plugins
 *
 */
function plugin_qform_convert()
{
    $qm = get_qm();
    $qt = get_qt();
    //--- キャッシュを無効に ---
    $qt->enable_cache = false;
    global $vars, $script, $editable;
    $page = $vars['page'];
    $editable = edit_auth($page, FALSE, FALSE);
    $args = func_get_args();
    $pstr = array_pop($args);
    $title = isset($args[0]) ? $args[0] : $qm->m['plg_qform']['title_none'];
    // $style は default, horizontal, vertical の 3 種類
    // bootstrap テンプレートでは default は horizontal のエイリアスとなる
    $style = isset($args[1]) && trim($args[1]) ? trim($args[1]) : 'horizontal';
    # default, horizontal, vertical
    $hor_aliases = array('bootstrap', 'table');
    if (is_bootstrap_skin()) {
        $hor_aliases[] = 'default';
    }
    if (in_array($style, $hor_aliases)) {
        $style = 'horizontal';
    }
    if (!in_array($style, array('default', 'horizontal', 'vertical'))) {
        $style = 'vertical';
    }
    $save = isset($args[2]) ? $args[2] : 'false';
    //フィッシング対策
    $url_sanitize = isset($args[3]) ? $args[3] : '0';
    //set design
    plugin_qform_set_css();
    $params = plugin_qform_parse($pstr);
    if (isset($vars['qform_condition'])) {
        //
        // send mail & ...
        //
        if (isset($vars['qform']['qform_finish'])) {
            if (!isset($_SESSION['qform'])) {
                header("Location: " . $script . '?' . urlencode($page));
                exit;
            }
            //転送する、postする、完了を出すなどなど
            if ($save === 'true') {
                plugin_qform_save_log($params, $page, $title);
            }
            return plugin_qform_do_finish($params, $url_sanitize);
        }
        //
        // 戻る
        //
        if (isset($vars['qform']['qform_back'])) {
            $_SESSION['qform']['enable_session_check'] = time();
            //セッション有効チェック用
            plugin_qform_unlink_attaches();
            //添付ファイル削除(あれば)
            force_output_message($qm->replace('plg_qform.title_confirm', $title), $page, '<h2>' . $title . '</h2>' . plugin_qform_mkform($params, $style));
        }
        //
        // 確認
        //
        if ($vars['qform_condition'] === 'confirm') {
            //sessionチェック
            if (!isset($_SESSION['qform']['enable_session_check'])) {
                $ss_error .= "<br />" . $qm->m['plg_qform']['err_enable_session'] . "\n";
            } else {
                $ss_error = '';
            }
            $_SESSION['qform'] = $vars['qform'];
            $error = plugin_qform_check($params);
            $error .= $ss_error;
            if ($error === '') {
                $body = plugin_qform_confirm($params, $style, $title);
                force_output_message($qm->m['plg_qform']['title_confirm2'], $page, $body);
            } else {
                $_SESSION['qform']['enable_session_check'] = time();
                //セッション有効チェック用
                force_output_message($qm->replace('plg_qform.title_confirm', $title), $page, '<h2>' . $title . '</h2><p class="' . (is_bootstrap_skin() ? 'text-danger' : 'qform-danger') . '">' . $error . '</p>' . plugin_qform_mkform($params, $style));
            }
        }
    } else {
        //デフォルトの動作(フォームの表示)
        plugin_qform_unlink_attaches();
        //添付ファイル削除
        $_SESSION['qform'] = null;
        //セッションクリア
        unset($_SESSION['qform']);
        $_SESSION['qform']['enable_session_check'] = time();
        $body = plugin_qform_mkform($params, $style);
        $error = plugin_qform_conf_check($params);
        $conf_page = ':config/plugin/qform/' . $page;
        $tail = '';
        if ($editable && is_page(':config/plugin/qform/' . $page)) {
            $tail = "\n" . '<p style="text-align:right"><a href="' . $script . '?' . rawurlencode($conf_page) . '" target="new">' . $qm->m['plg_qform']['link_log_chk'] . '</a></p>' . "\n";
        }
        return $error . $body . $tail;
    }
}
Example #2
0
function plugin_commu_qform_convert()
{
    $qm = get_qm();
    $qt = get_qt();
    //--- キャッシュを無効に ---
    $qt->enable_cache = false;
    global $vars, $script, $editable;
    $page = $vars['page'];
    $editable = edit_auth($page, FALSE, FALSE);
    $args = func_get_args();
    $pstr = array_pop($args);
    $title = isset($args[0]) ? $args[0] : $qm->m['plg_qform']['title_none'];
    $style = isset($args[1]) ? $args[1] : 'table';
    $save = isset($args[2]) ? $args[2] : 'false';
    //set design
    $addstyle = '
<style type="text/css">
.qform_table{
	width:85%;
	margin:1.5em auto;
}
.qform_table tr th{
	padding: 10px;
/* 	font-weight:normal;	 */
	border-bottom: 1px solid #ccc;
	white-space: nowrap;
}
.qform_table tr td{
	padding: 10px;
	font-weight:normal;	
	border-bottom: 1px solid #ccc;
}
.qform_form textarea,
.qform_form input[type=text]
{
	padding:3px 5px;
	width:97%;
	border:1px solid #ccc;
}
.qform_value{
	border:0;
}
.qform_table tr td.qform_value{
	padding: 10px 10px 20px 10px;
	font-weight:normal;	
	border-bottom: none;
}

</style>
	';
    $qt->appendv_once('plugin_qform', 'beforescript', $addstyle);
    $params = plugin_qform_parse($pstr);
    if (isset($vars['qform_condition'])) {
        //
        // send mail & ...
        //
        if (isset($vars['qform']['qform_finish'])) {
            if (!isset($_SESSION['qform'])) {
                header("Location: " . $script . '?' . urlencode($page));
                exit;
            }
            //転送する、postする、完了を出すなどなど
            if ($save === 'true') {
                plugin_qform_save_log($params, $page, $title);
            }
            return plugin_qform_do_finish($params);
        }
        //
        // 戻る
        //
        if (isset($vars['qform']['qform_back'])) {
            $_SESSION['qform']['enable_session_check'] = time();
            //セッション有効チェック用
            plugin_qform_unlink_attaches();
            //添付ファイル削除(あれば)
            force_output_message($qm->replace('plg_qform.title_confirm', $title), $page, '<h2>' . $title . '</h2>' . plugin_qform_mkform($params, $style));
        }
        //
        // 確認
        //
        if ($vars['qform_condition'] === 'confirm') {
            //sessionチェック
            if (!isset($_SESSION['qform']['enable_session_check'])) {
                $ss_error .= "<br />" . $qm->m['plg_qform']['err_enable_session'] . "\n";
            } else {
                $ss_error = '';
            }
            $_SESSION['qform'] = $vars['qform'];
            $error = plugin_qform_check($params);
            $error .= $ss_error;
            if ($error === '') {
                $body = plugin_qform_confirm($params, $style, $title);
                force_output_message($qm->m['plg_qform']['title_confirm2'], $page, $body);
            } else {
                $_SESSION['qform']['enable_session_check'] = time();
                //セッション有効チェック用
                force_output_message($qm->replace('plg_qform.title_confirm', $title), $page, '<h2>' . $title . '</h2><p style="color:red">' . $error . '</p>' . plugin_qform_mkform($params, $style));
            }
        }
    } else {
        //デフォルトの動作(フォームの表示)
        plugin_qform_unlink_attaches();
        //添付ファイル削除
        $_SESSION['qform'] = null;
        //セッションクリア
        unset($_SESSION['qform']);
        $_SESSION['qform']['enable_session_check'] = time();
        $body = plugin_qform_mkform($params, $style);
        $error = plugin_qform_conf_check($params);
        $conf_page = ':config/plugin/qform/' . $page;
        $tail = '';
        if ($editable && is_page(':config/plugin/qform/' . $page)) {
            $tail = "\n" . '<p style="text-align:right"><a href="' . $script . '?' . rawurlencode($conf_page) . '" target="new">' . $qm->m['plg_qform']['link_log_chk'] . '</a></p>' . "\n";
        }
        return $error . $body . $tail;
    }
}