<?php
/*
 *  메타태그 관리자
 */
include_once './_common.php';
include_once './index.php';

if (!defined('_GNUBOARD_')) {
    exit;
}

$sql = "select * from ask_plugin_config where pc_id = '{$plugin['id']}'";
$result = sql_fetch($sql);
$data = unserialize($result['pc_config']);


include_once G5_PLUGIN_PATH . "/asktheme/_admin/head.php";
add_stylesheet('<link rel="stylesheet" href="' . G5_PLUGIN_URL . '/asktheme/plugin/' . $plugin['id'] . '/plugin_style.css">', 0);
?>
<div id="container">
    <div class="row">
        <div class="small-12 medium-12 large-12 columns">
            <div class="panel panel-default">
                <div class="panel-header">
                    <h1><?php echo $plugin['name'], $plugin['version']; ?> 플러그인 설정</h1>
                </div>
                <div class="panel-body">
                    <?php
                    if ($w == 'u' && $mode) {
                        $refresh = "refresh=1";
                    }
                    ?>
                    <form class="setup_form" action="./setup_update.php?<?php echo $refresh ?>"  onsubmit="return form_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" >
                        <input type="hidden" name="pc_id" value="<?php echo $plugin['id'] ?>"/>
                        <input type="hidden" name="pc_name" value="<?php echo $plugin['name'] ?>"/>

                        <div class="responsetable write-table">
                            <div class="tb-body">
                                <div class="tb-row">
                                    <div class="tb-cell tb-text"><label for="pc_use">사용여부<strong class="sound-only">필수</strong></label></div>
                                    <div class="tb-cell">
                                        <?php
                                        if ($data['pc_use'] == '1') {
                                            $pc_use = "checked";
                                        } else {
                                            $pc_unuse = "checked";
                                        }
                                        ?>
                                        <label><input type="radio" name="pc_use" value="1" <?php echo $pc_use ?> class="plugin-start">사용하기</label>
                                        <label><input type="radio" name="pc_use" value="0" <?php echo $pc_unuse ?> class="plugin-stop">사용중지</label>
                                        <br><br>
                                        <div class='text text-default'>
                                            게시판 내용을 Open Graph Tag 로 생성합니다.
                                        </div>
                                    </div>
                                </div>
                                <div class="tb-row">
                                    <div class="tb-cell tb-text">

                                    </div>
                                    <div class="tb-cell">
                                        <div class="button-group float-left">
                                            <button type="submit" class="button primary submit"><i class="fa fa-check"></i> 확인</button>
                                            <button type="button" class="button danger cancel"><i class="fa fa-ban"></i> 취소</button>
                                        </div>

                                        <div class="button-group float-right">
                                            <a href="<?php echo G5_PLUGIN_URL ?>/asktheme/_admin/plugin/plugin_admin.php" class="button"><i class="fa fa-list"></i> 목록으로</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--responsetable-->
                    </form>
                </div>
                <div class="panel-footer">
                    &middot; OG metatag 참고 : <a href='http://ogp.me/' target="_blank">http://ogp.me/</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function form_submit(f) {
        //console.log(f);
        var form_radio = $('input[name=pc_use]:checked').val();
        if (form_radio === undefined) {
            alert('사용여부를 선택하세요');
            return false;
        }
<?php if ($w == 'u' && $mode == 'start') { ?>
            $('.plugin-start').attr('checked', true);
<?php } ?>
<?php if ($w == 'u' && $mode == 'stop') { ?>
            $('.plugin-stop').attr('checked', true);
<?php } ?>
        return true;
    }
    $(function () {
<?php if ($w == 'u' && $mode) { ?>
            $('.setup_form').submit();
<?php } ?>
        $('.cancel').click(function () {
            if (confirm('취소하시겠습니까?')) {
                location.href = history.go(-1);
            } else {
                return false;
            }
        });

    });
</script>
<?php
include_once G5_PLUGIN_PATH . "/asktheme/_admin/tail.php";

