소스 파일 : /yoyak/yoyak_contents_right_ajax.php (2018-06-09)     소스 설명 : (분류요약관리) 요약관리 우측 navigation menu에서 '▷'를 클릭하면, Ajax에 의해, 이 스크립트가 수행됨
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php // (2018.6.9, 차재복, Cha Jae Bok, http://www.ktword.co.kr) 

# yoyak_contents_right_ajax.php
	// 우측 navigation menu에서 '▷'를 클릭하면, Ajax에 의해, 이 스크립트가 수행됨

# 세션 스타트 (매 웹페이지 마다 필요)
	session_start();

# db 접속
	include_once "../base_utils/db_conn.php";

# 전달 변수
	$id = $_REQUEST[id];
		if ( isset($_REQUEST[id]) and !empty($id) and !is_numeric($id) or $id<0 ) exit; // 해킹방지 (수치>0)
		$id = substr($id,0,10);  // 해킹 방지 (글자 수 제한)
		if(empty($id)) $id=0; // 디폴트

	$win = $_REQUEST[win];

# html 헤더부 ------------------------------------------------------------
	// html 및 utf-8 선언
	echo "<meta http-equiv='content-type' content='text/html; charset=utf-8'>";

# 쿼리문 (db 쿼리 -> php 배열)
	include_once "yoyak_contents_db_qry.php";
	$result_set = tbl_read($id, $dbi);
		$set = $result_set['set'];
		$cur_path = $result_set['cur_path'];

# 배열 목록 출력
contents_display_right($set, $cur_path, $id, $dbi);

/*
	// 우측 상단 닫기 버튼 
		echo "<button id='contents_right_off' style='width:100%;font-size:12px;padding:0px;margin-bottom:5px;color:red;'>우측 선택화면 닫기</button>";

	// 우측 상단 메뉴 창
		echo "<div id='contents_right_up' style='border:1px gray solid;'>";
			echo "<span id='source' data-no='' style='color:red;font-size:13px;'>";
			echo "</span>";
			echo " => ";
			echo "<span id='target' style='color:red;font-size:13px;'>\" \"</span>";
			right_button();
		echo "</div>";

	// 우측 하단 목록 창 
		echo "<div id='contents_right_down' data-win='right' style='border:1px gray solid;'>"; // data-win='right' 
			contents_display_right($set, $cur_path, $id, $dbi);
		echo "</div>";
*/


# 배열 목록 출력 함수
function contents_display_right($set, $cur_path, $id, $dbi) {

	echo "<ol>";
	foreach ($set as $key => $value) {

		// 항목 레벨 깊이 차이 계산
		$diff = ($set[$key+1][depth]-$set[$key][depth]); 

		echo "<li>";

			// show/hide (▷/▽) -------------------------------------
			if ( $diff > 0 or ($value[sub_cnt] == 0 and $value[linked_num]>0 and $value[id]==$id) ) {
				echo " &nbsp; <a href='".$value[id]."' class='lower_ol_hideshow' data-id='{$value[id]}' style='color:red;'>▽</a>";
			} else if ( $diff <= 0 or ($value[sub_cnt] == 0 and $value[linked_num]>0 and $value[id]!=$id) ) { 
				echo " &nbsp; <a href='".$value[id]."' class='ajax_page' data-id='{$value[id]}' style='color:red;'>▷</a>";
			} 

			echo " ";

			# 분류항목 명칭 출력 ------------------------------
			// 현 분류항목이 선택항목 path에 속하는지 여부에 따라 폰트 강조
			( strpos(','.$cur_path.',',','.$value[id].',')!==false ? $strong = 'font-weight:bold;' : $strong = '') ;
			// 분류항목 링크 표현
			$href = "../view/view.php?nav=2&id={$value[id]}";
			// 분류항목 명칭
			echo "<a href='{$href}' class='right_choice' data-id='{$value[id]}' data-title='{$value[name]}' style='{$strong}'>";
				echo $value[name];
			echo "</a>";

		if ( $diff > 0) echo "<ol>";	// 레벨 추가

			// 용어 항목 명칭 출력 
			if ( $value[linked_num]>0 and strpos(','.$cur_path.',',','.$value[id].',')!==false ) { 

				if ($value[sub_cnt] == 0 ) echo "<ol>";

						detail_items_display_right($value[id], $dbi);

				if ($value[sub_cnt] == 0 ) echo "</ol>";

			}

		if ( $diff == 0) echo "</li>";	// 동급 레벨

		if ( $diff < 0)					// 레벨 닫음
			echo str_repeat("</ol></li>", - $diff); 
	}
	echo "</ol>";

}


# 각 id별 세부 용어 항목명 보이기 함수 루틴
function detail_items_display_right($id, $dbi) {

		$query="select titlename,no,list_ord,tree_id as id,yoyak from book_idx where tree_id={$id} order by list_ord, titlename";
		$result = mysqli_query($dbi,$query);
		$cnt = mysqli_num_rows($result);
		$n=1;
		while ( $matched=mysqli_fetch_assoc($result) ) {
			echo "<li>";

			echo " &nbsp;&nbsp;&nbsp; ";
			echo " $n. ";

			# 용어항목 명칭 출력 -----------------------------
			echo $matched[titlename];

			echo "&nbsp;&nbsp;";

			echo "</li>";

			$n=$n+1;
		}

}


?>


Copyrightⓒ written by 차재복 (Cha Jae Bok)
"본 웹사이트 내 모든 저작물은 원출처를 밝히는 한 자유롭게 사용(상업화포함) 가능합니다"