소스 파일명 : item_button.php
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php // (2017.2.5, 차재복, Cha Jae Bok, cjbword@gmailcom)


# 항목 관리 버튼들 

	// CSS style 
	echo "<link rel='stylesheet' type='text/css' href='item_button.css' />";

	// jquery 기능 구현 소스 불러오기
	echo "<script type='text/javascript' src='item_button.js' charset='UTF-8'></script>";

	// 항목관리 제목
	echo "<hr style='clear:both;'>";
		echo "<span style='display:block; float:left; font-size:14px;'> 항목 관리 :</span>"; 
			echo " &nbsp;&nbsp; ";

	// 개별 항목관리 버튼들
		if ( empty($id) ) {

			echo "<button id='last_add_btn' class='item_mng_btn'>분야 추가</button> ";

				if ( !isset($row) ) {
					$row[parent] = 0;
					$row[depth] = 1;
					$chap = 1;

				}
				item_deal_button ('last_add',$row,0,$chap);

		} else {

			echo "<button id='prev_add_btn' class='item_mng_btn'>직전 추가</button> ";
			echo "&nbsp; <button id='next_add_btn' class='item_mng_btn'>직후 추가</button> ";
			echo "&nbsp; <button id='child_add_btn' class='item_mng_btn'>자식 추가</button> ";
			if ($row[next_sub] <= 0)	
				echo "&nbsp; <button id='delete_btn' class='item_mng_btn'>삭 제</button> ";

			echo "&nbsp; <button id='move_item_btn' class='item_mng_btn'>항목 이동</button>";

				item_deal_button ('prev_add',$row,$max_id,$chap);
				item_deal_button ('next_add',$row,$max_id,$chap);
				item_deal_button ('child_add',$row,$max_id,$chap);
				if ($row[next_sub] <= 0)	
					item_deal_button ('delete',$row,$max_id,$chap);

				echo "<div id='move_item_div' style='clear:both;border-top:gray solid 1px; margin-bottom:0; padding:0; '>";
					echo "<div style='border:1px; border-style:dashed; margin:10px;'>";
						// 항목 이동 선택 표제부
						move_item ();
						echo "<hr style='margin:0;'>";
						// 목차 출력 형태로 항목 선택
						contents_display ($set, $id, 'dynamic', '#test_click');
					echo "</div>";	
				echo "</div>";
		}


// 항목 관리(추가,삭제) 폼 버튼 메뉴 함수 *************************************************************
function item_deal_button ($choice,$row,$max_id,$chap) {

		$alert = ( !empty($_SESSION['user_name']) ? " " : " class='alert' " ) ;

		// current level prev add (이전 추가)
		if ($choice == 'prev_add') {
			echo "<div id='prev_add_div'>";
			echo "<form action='knowhow.php#".$row[id]."' method=post $alert style='float:left;margin:0 5px 0 0;padding:0;' >";
				if (!empty($_SESSION['user_name'])) {
					echo "<input type=text size=10 name='para[title]'>"; // 타이틀
					echo "<input type='hidden' name=action value='$choice'>"; // prev_add
					echo "<input type='hidden' name=id value='$row[id]'>"; // 
					echo "<input type='hidden' name='para[parent]' value=$row[parent]>";
					echo "<input type='hidden' name='para[chap]' value=$row[chap]>"; 
				} else {
					echo "<input type=text size=10 name='temp'>"; // 타이틀
				}
				echo "<input type=submit value='이전 추가'>";
			echo "</form>";
			echo "</div>";
		}

		// current level nex add (다음 추가)
		if ($choice == 'next_add') {
			echo "<div id='next_add_div'>";
			echo "<form action='knowhow.php#".$row[id]."' method=post $alert style='float:left;margin:0 5px 0 0;padding:0;' >";
				if (!empty($_SESSION['user_name'])) {
					echo "<input type=text size=10 name='para[title]'>"; // 타이틀
					echo "<input type='hidden' name=id value='$row[id]'>"; // 
					echo "<input type='hidden' name=action value='$choice'>"; // next_add
					echo "<input type='hidden' name='para[parent]' value=$row[parent]>";
					echo "<input type='hidden' name='para[chap]' value=$row[chap]>"; 
				} else {
					echo "<input type=text size=10 name='temp'>"; // 타이틀
				}
				echo "<input type=submit value='다음 추가'>";
			echo "</form>";
			echo "</div>";
		}

		// delete (삭제)
		if ($choice == 'delete') {
			echo "<div id='delete_div'>";
			echo "<form action='knowhow.php?id=".$row[id]."' method=post $alert  style='float:left;margin:0 5px 0 0;pading:0;' >";
				echo "<input type=submit value='항목 삭제'>";
				if (!empty($_SESSION['user_name'])) {
					echo "<input type='hidden' name=action value='$choice'>"; // delete
					echo "<input type='hidden' name=id value='$row[id]'>"; // delete node id
				}
			echo "</form>";
			echo "</div>";
		}

		// child add (자식 추가)
		if ($choice == 'child_add') {
			echo  "<div id='child_add_div'>";
			echo "<form action='knowhow.php#".$row[id]."' method=post $alert style='float:left;margin:0 5px 0 0;pading:0;' >";
				if (!empty($_SESSION['user_name'])) {
					echo "<input type=text size=10 name='m_title'>"; // 타이틀
					echo "<input type='hidden' name=id value=$row[id]>"; // parent
					echo "<input type='hidden' name=depth value=".($row[depth]+1).">"; // depth
					echo "<input type='hidden' name=action value='$choice'>";
				} else {
					echo "<input type=text size=10 name='temp'>"; // 타이틀
				}
				echo "<input type=submit value='자식 추가'>";
			echo "</form>";
			echo "</div>";
		}

		// current level last add (신규/형제/마지막 추가)
		if ($choice == 'last_add') {
			echo  "<div id='last_add_div'>";
				echo "<form action='knowhow.php#".$row[id]."' method=post $alert style='float:left; margin:0 5px 0 0;padding:0;' >";

					echo "<input type=text size=10 name='m_title'>"; // 타이틀
					echo "<input type='hidden' name=id value=$row[parent]>"; // parent
					echo "<input type='hidden' name=max_id value=".($max_id+1).">"; // max_id + 1
					echo "<input type='hidden' name=depth value=".$row[depth].">"; // depth
					echo "<input type='hidden' name=chap value=$chap>"; // chap
					echo "<input type='hidden' name=action value='$choice'>";

					echo "<input type=submit>";
				echo "</form>";
			echo "</div>";
		}

}


// 항목 이동 버튼 ******************************************************************
function move_item () {

//			$alert = ( $m_edit_level==$editor ? " " : " class='alert' " ) ;

			echo "<div style='display:inline-block; border:gray solid 1px; margin:0'>";
				echo "이동 대상 : ";
				echo "<input type='radio' id='source' name='src_tgt' value='source'>";
				echo "<div id='source_1' style='display:inline-block; border:black dotted 1px;'>";
					echo " 이동 대상 선택 !!! ";
				echo "</div>";
			echo "</div>";

			echo " ==> ";
			
			echo "<div style='display:inline-block; border:gray solid 1px; margin:0;'>";
				echo "이동 위치 : "				;
				echo "<input type='radio' id='target' name='src_tgt' value='target'>";
				echo "<div id='target_1' style='display:inline-block; border:black dotted 1px;'>";
					echo " 이동 위치 선택 !!! ";
				echo "</div>";
				echo " 의 ";

				if (!empty($_SESSION['user_name'])) {
					echo "<form action='knowhow.php' method='POST' id='move_form_editor' style='display:inline;'>";
				} else {
					echo "<form action='knowhow.php' method='POST' id='move_form' class='alert'	 style='display:inline;'>";
				}
						echo "<button id='before' class='move_button'>직전</button>"; 
						echo "<button id='after' class='move_button'>직후</button>";
						echo "<button id='child' class='move_button'>자식</button>";

					if (!empty($_SESSION['user_name'])) {
						echo "<input type='hidden' id='source_id' name='id' value=''>";
						echo "<input type='hidden' id='target_id' name='para[target]' value=''>";
						echo "<input type='hidden' id='target_choiced' name=action value=''>";

						echo "<script type='text/javascript' src='jq_editor.js' charset='UTF-8'></script>";
					} 

				echo "</form>";

				echo " 으로 이동";
			echo "</div>";

}


?>