<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$search_skin_url.'/style.css">', 0);
?>

<form name="fsearch" onsubmit="return fsearch_submit(this);" method="get">
<input type="hidden" name="srows" value="<?php echo $srows ?>">
<fieldset id="sch_res_detail">
    <legend>상세검색</legend>
    <div class="sch_wr">
<!-- 기존 dslcub230428에서 수정한 코드{
        <?php echo $group_select ?>
        <script>document.getElementById("gr_id").value = "<?php echo $gr_id ?>";</script>
}기존코드끝-->

        <label for="sfl" class="sound_only" style="position: absolute;width: 0;height: 0;font-size: 0;line-height: 0;overflow: hidden;">검색조건</label>
        <select name="sfl" id="sfl" style="position: absolute;width: 0;height: 0;font-size: 0;line-height: 0;overflow: hidden;">
            <option value="wr_subject||wr_content||mb_id||wr_name||wr_datetime||wr_last||wr_ip"<?php echo get_selected($_GET['sfl'], "wr_subject||wr_content||mb_id||wr_name||wr_datetime||wr_last||wr_ip") ?>>통합검색</option>
            <option value="wr_subject"<?php echo get_selected($_GET['sfl'], "wr_subject") ?>>제목</option>
            <option value="wr_content"<?php echo get_selected($_GET['sfl'], "wr_content") ?>>내용</option>
            <option value="mb_id"<?php echo get_selected($_GET['sfl'], "mb_id") ?>>회원아이디</option>
            <option value="wr_name"<?php echo get_selected($_GET['sfl'], "wr_name") ?>>이름</option>
        </select>
        
        <label for="stx" class="sound_only">검색어<strong class="sound_only"> 필수</strong></label>
        <input type="text" name="stx" id="stx" value="<?php echo $text_stx ?>" class="frm_input" required  maxlength="20">
        <button type="submit" class="btn_submit" value="검색"><i class="fa fa-search" aria-hidden="true"></i></button>

        <script>
        function fsearch_submit(f)
        {
            if (f.stx.value.length < 2) {
                alert("검색어는 두글자 이상 입력하십시오.");
                f.stx.select();
                f.stx.focus();
                return false;
            }

            // 검색에 많은 부하가 걸리는 경우 이 주석을 제거하세요.
            var cnt = 0;
            for (var i=0; i<f.stx.value.length; i++) {
                if (f.stx.value.charAt(i) == ' ')
                    cnt++;
            }

            if (cnt > 1) {
                alert("빠른 검색을 위하여 공백은 한 개만 가능합니다.");
                f.stx.select();
                f.stx.focus();
                return false;
            }

            f.action = "";
            return true;
        }
        </script>
    </div>
<!-- 기존 dslcub230428에서 수정한 코드{
    <div class="switch_field chk_box">
        <input type="radio" value="or" <?php echo ($sop == "or") ? "checked" : ""; ?> id="sop_or" name="sop">
        <label for="sop_or"><span></span>OR</label>
        <input type="radio" value="and" <?php echo ($sop == "and") ? "checked" : ""; ?> id="sop_and" name="sop">
        <label for="sop_and"><span></span>AND</label>
    </div>
}기존코드 끝-->
</fieldset>
</form>

<!-- 검색어 기반 콘텐츠 추천{ -->
<center>
<?php include_once(G5_PLUGIN_PATH.'/recommend/core.php'); ?>
</center>
<!-- }콘텐츠 추천 끝 -->

<div id="sch_result">

    <?php
    if ($stx) {
        if ($board_count) {
     ?>
<!-- 기존 dslcub230428에서 수정한 코드{
    <ul id="sch_res_board">
        <li><a href="?<?php echo $search_query ?>&amp;gr_id=<?php echo $gr_id ?>" <?php echo $sch_all ?>>전체게시판</a></li>
        <?php echo $str_board_list; ?>
    </ul>
}기존 코드 끝-->
    <?php
        } else {
     ?>
    <div class="empty_list">검색된 자료가 하나도 없습니다.</div>
    <?php } }  ?>
    <hr>
    <div class="list_01">
    <?php if ($stx && $board_count) { ?><section class="sch_res_list"><?php }  ?>
    <?php
    $k=0;
    for ($idx=$table_index, $k=0; $idx<count($search_table) && $k<$rows; $idx++) {
     ?>
        <h2><a href="<?php echo get_pretty_url($search_table[$idx], '', $search_query); ?>"><?php echo $bo_subject[$idx] ?> 게시판 내 결과</a></h2>
        <ul>
        <?php
        for ($i=0; $i<count($list[$idx]) && $k<$rows; $i++, $k++) {
            if ($list[$idx][$i]['wr_is_comment'])
            {
                $comment_def = '<span class="cmt_def"><i class="fa fa-commenting-o" aria-hidden="true"></i><span class="sound_only">댓글</span></span> ';
                $comment_href = '#c_'.$list[$idx][$i]['wr_id'];
            }
            else
            {
                $comment_def = '';
                $comment_href = '';
            }
         ?>
            <li class="sch_ccontent">
                <div  class="sch_res_title">
                    <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>"><?php echo $comment_def ?><?php echo $list[$idx][$i]['subject'] ?></a>
                    <!-- <a href="<?php echo $list[$idx][$i]['href'] ?><?php echo $comment_href ?>" target="_blank" class="sch_res_new"><i class="fa fa-share-square-o" aria-hidden="true"></i><span class="sound_only">새창</span></a> -->
                </div>
                <!-- 0 : 본문 글자 중 어디서 부터 시작할 지, 0이 처음이라는 뜻, 100: 100자만큼 출력-->
                <p><?php echo mb_substr(strip_tags($list[$idx][$i]['content']), 0, 100); ?></p>
                <div class="sch_res_info">
                    <?php echo $list[$idx][$i]['name'] ?>
                    <span class="sch_datetime"><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $list[$idx][$i]['wr_datetime'] ?></span>
                </div>
            </li>
        <?php }  ?>
        </ul>
        <!--기존 코드{
        <div class="sch_more"><a href="<?php echo get_pretty_url($search_table[$idx], '', $search_query); ?>"><strong><?php echo $bo_subject[$idx] ?></strong> 결과 더보기</a></div>
        }기존코드-->
    <?php }  ?>

    <?php if ($stx && $board_count) {  ?></section><?php }  ?>
    </div>
    <?php echo $write_pages ?>
</div>
