<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
/*
 * http://www.g4mob.com
 * g4m board view.skin.php
 * 
 */
?>

<!-- 게시글 보기 시작 -->
<script type="text/javascript">
$(document).ready(function() {
    <?php if ($prev_href) { ?>
        $('#wr_prev').click(function(){
            location.href='<?php echo $prev_href?>';
        });
    <?php } ?>
    <?php if ($next_href) {?>
        $('#wr_next').click(function(){
            location.href='<?php echo $next_href?>';
        });
    <?php } ?>
});
</script>

<article class="g4board_basic">
    <header class="page-header">
        <h4>
            <?php
            if ($is_category) {
                echo ($category_name ? "[{$view['ca_name']}] " : "");
            }
            echo $view['wr_subject'];
            ?>
        </h4>
    </header>
    <div class="wr_inf">
        <div class=""><?php echo $view['name']?><?php // if ($is_ip_view) { echo "&nbsp;($ip)"; } ?></div>
        <div class="wr_stats">
            <ol class="breadcrumb">
                <li><?php echo date("y-m-d H:i", strtotime($view['wr_datetime']))?></li>
                <li>Hit : <?php echo number_format($view['wr_hit'])?></li>
            </ol> 
        </div>
    </div>

    <div class="btn-group btn-group-justified">
        <?php
        ob_start();
        ?>
                <a href="<?php echo $list_href?>"  class='btn btn-default btn-sm'>목록</a>
                <?php
                if ($copy_href) {
                    echo "<a href=\"{$copy_href}\" class='btn btn-info btn-sm'>복사</a> ";
                }
                if ($move_href) {
                    echo "<a href=\"{$move_href}\" class='btn btn-success btn-sm'>이동</a> ";
                }
                if ($update_href) {
                    echo "<a href=\"{$update_href}\" class='btn btn-default btn-sm'>수정</a> ";
                }
                if ($delete_href) {
                    echo "<a href=\"{$delete_href}\" class='btn btn-danger btn-sm'>삭제</a> ";
                }
                if ($search_href) {
                    echo "<a href=\"{$search_href}\" class='btn btn-info btn-sm'>검색목록</a> ";
                }

                if ($reply_href) {
                    echo "<a href=\"{$reply_href}\" class='btn btn-info btn-sm'>답변</a> ";
                }

                $link_button = ob_get_contents();
                ob_end_flush();
                ?>
        <!-- 링크 버튼 -->
    </div>
    <br class="clear"/>
    <div class="pull-right" style="padding: 5px">
            <?php
            // 가변 파일
            $file_count = count($view['file']);
            $files = "<ul style='padding:5px'>";
            for ($i = 0; $i < $file_count; $i++) {
                if ($view['file'][$i]['source'] && !$view['file'][$i]['view']) {
                    $files .= "<li>";
                    $files .= "<a href=\"javascript:file_download('{$view[file][$i][href]}', '" . urlencode($view[file][$i][source]) . "');\" title='{$view[file][$i][content]}'>";
                    $files .= "<span class='glyphicon glyphicon-floppy-save'></span>{$view['file'][$i]['source']} ({$view['file'][$i]['size']})";
                    $files .= "<span>[{$view[file][$i][download]}]</span>";
                    //echo "<span>Date : {$view[file][$i][datetime]}</span>";
                    $files .= "</a></li>";
                }
            }
            $files .='</ul>';
            // 링크
            $links = "<ul style='padding:5px'>";
            for ($i = 1; $i <= $g4['link_count']; $i++) {
                if ($i == 1)
                    $first = "first";
                if ($view['link'][$i]) {
                    $link = cut_str($view['link'][$i], 30);
                    $links .= "<li class='{$first}'>";
                    $links .= "<a href='{$view['link_href'][$i]}' target='_blank' style='color:#ff0000'>";
                    $links .= "<span class='glyphicon glyphicon-link'></span> {$link}";
                    $links .= "<span>[{$view['link_hit'][$i]}]</span>";
                    $links .= "</a></li>";
                }
                
            }
            $links .='</ul>';
            ?>
    </div>
    <div class="article well well-lg">
        <?php
        echo $files;
        echo $links;
        // 파일 출력
        $list_view_count =  count($view['file']);
        for ($i = 0; $i <= $list_view_count; $i++) {
            if ($view['file'][$i]['view']){
                $img = get_thumb($board['bo_table'],$view['file'][$i]['file'], 'view', $board['bo_m_image_width']);
                echo "<p>".$img."</p>";
            }
        }
        echo $view['content'];
        ?>
    </div>
    <footer>
        <div class="pull-right">
        <?php if ($nogood_href) {?>
            <a href="<?php echo $nogood_href?>" target="hiddenframe" class="btn btn-danger"><span class='glyphicon glyphicon-thumbs-down'></span>(<?php echo number_format($view['wr_nogood'])?>)</a>
        <?php } ?>

        <?php if ($good_href) {?>
            <a href="<?php echo $good_href?>" target="hiddenframe" class="btn btn-info"><span class='glyphicon glyphicon-thumbs-up'></span>(<?php echo number_format($view['wr_good'])?>)</a>
        <?php } ?>
        <?php //if ($is_signature) { echo "<div class='sign'>$signature</div>"; } // 서명 출력 ?>
        </div>
    </footer>

    <ul class="page-btn pager" style="margin-top: 30px">
        <?php if ($prev_href) { ?><li><a id="wr_prev" class="btn pull-left" type="button">이전글</a></li> <?php } ?>
        <?php if ($next_href) { ?><li><a id="wr_next" class="btn pull-right" type="button">다음글</a></li> <?php } ?>
    </ul>
    <br class="clear"/>
    <?php
    // 코멘트 입출력
    include_once "./view_comment.php";
    ?>
</article>

<script type="text/javascript">
function file_download(link, file) {
    <?php if ($board['bo_download_point'] < 0) { ?>
    if (confirm("'"+decodeURIComponent(file)+"' 파일을 다운로드 하시면 포인트가 차감(<?=number_format($board[bo_download_point])?>점)됩니다.\n\n포인트는 게시물당 한번만 차감되며 다음에 다시 다운로드 하셔도 중복하여 차감하지 않습니다.\n\n그래도 다운로드 하시겠습니까?"))
    <?php } ?> 
    document.location.href=link;
}
</script>

<!-- 게시글 보기 끝 -->