<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
		<div class="clear"></div>
		<div class="content-box">
			<div class="content-box-header">
				<h3><?php echo $this->crumb['last']['name']; ?></h3>
				<ul class="content-box-tabs">
					<li><a href="#tab1" class="default-tab current">Topic List</a></li>
					<li><a href="#tab2" class="">Search</a></li>
				</ul>
				<div class="clear"></div>
			</div>
			<div class="content-box-content" style="width:800px;">
				<div class="tab-content default-tab" id="tab1">
					<?php if($_GET['action'] == 'search'){ ?>
						<div style="margin:6px;">There are <?php echo intval($this->topic_num); ?> qualifying content.</div>
					<?php } ?>
					
					<?php if($this->list){ ?>
					<form id="batchs_form" action="admin/topic/topic_batch/" method="post" style="margin-top:8px;">
					<input type="hidden" name='action_type' value="">
										
					<table class="list">
						<thead>
							<tr>
								<th style="width:40px;" align="center"><input type="checkbox" class="check-all"></th>
								<th>Topic title</th>
								<th style="width:50px; text-align:center;">Related topic</th>
								<th style="width:60px; text-align:center;"><a href="<?php echo $this->search_url; ?>__sort_key-discuss_count__order-<?php if($_GET['sort_key'] == 'discuss_count' && $_GET['order'] == 'DESC'){ ?>ASC<?php }else{ ?>DESC<?php } ?>">Questions<?php if($_GET['sort_key'] == 'discuss_count'){ ?><?php if($_GET['order'] == 'ASC'){ ?><em class="listup">&uarr;</em><?php }else{ ?><em class="listdown">&darr;</em><?php } ?><?php } ?></a></th>
								<th style="width:50px; text-align:center;">Status</th>
								<th style="width:100px; text-align:center;">Operation</th>
							</tr>
						</thead>
						<tfoot>
							<tr>
								<td colspan="7">
									<div class="bulk-actions align-left">
										<a class="button" onClick="$('#batchs_form > input[name=action_type]').val('remove');ajax_post($('#batchs_form'), _ajax_post_alert_processer); return false;" href="javascript:;">Delete selected</a>&nbsp;
										<a class="button" onClick="$('#batchs_form > input[name=action_type]').val('lock');ajax_post($('#batchs_form'), _ajax_post_alert_processer); return false;" href="javascript:;">Lock selected</a>
									</div>
									<div class="pagination">
										<?php echo $this->pagination; ?>
									</div>
									<div class="clear"></div>
								</td>
							</tr>
						</tfoot>
						<tbody style="border-bottom: 1px solid #ddd;">
<?php foreach ($this->list AS $key => $val) { ?>
							<tr>
								<td align="center"><input type="checkbox" name="topic_ids[]" value="<?php echo $val['topic_id']; ?>"></td>
								<td><a href="topic/<?php echo $val['url_token']; ?>" target="_blank"><?php echo $val['topic_title']; ?></a></td>
								<td style="width:50px; text-align:center;">
										<?php if($val['related_topics']){ ?><?php foreach($val['related_topics'] as $topic){ ?><a href="topic/<?php echo $topic['url_token']?>" target="_blank"><?php echo $topic['topic_title']; ?></a>&nbsp;<?php } ?><?php } ?>
								</td>
								<td style="text-align:center;">
									<a href="admin/question/question_list/action-search__topic-<?php echo rawurlencode($val['topic_title']); ?>"><?php echo $val['discuss_count']; ?></a>
								</td>
								<td style="text-align:center;">
								<?php if($val['topic_lock'] == 1){ ?>
									<a href="javascript:;" onClick="topic_lock(<?php echo $val['topic_id']; ?>, 0)" title="Unlock selected"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/lock.png"/></a>
								<?php }else{ ?>
									<a href="javascript:;" onClick="topic_lock(<?php echo $val['topic_id']; ?>, 1)" title="Lock topic"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/unlock.png"/></a>
								<?php } ?>
								</td>
								<td style="width:100px; text-align:center;">
									<a href="admin/topic/edit/topic_id-<?php echo $val['topic_id']; ?>" title="Edit question"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/pencil.png"/></a>
								</td>
							</tr>
<?php } ?>
						</tbody>
					</table>
					</form>
					<?php } ?>
				</div>
				
				<div class="tab-content" id="tab2" style="display:none;">
				<form method="post" action="admin/topic/list/" onsubmit="return false;" id="search_form">
				<input name="action" type="hidden" value="search"/>
				<p>
					<label> Keyword:</label>
					<input type="text" value="<?php echo rawurldecode($_GET['keyword']); ?>" name="keyword" class="text-input small-input">
				</p>
				<p>
					<label> Questions included:</label>
					<input type="text" name="question_count_min" value="<?php echo $_GET['question_count_min']; ?>" class="text-input" style="width:40px;"> - <input type="text" name="question_count_max" value="<?php echo $_GET['question_count_max']; ?>" class="text-input" style="width:40px;">
				</p>
				<p>
					<label> Whether there is picture:</label>
					<label style="float:left;"><input type="radio" value="1" name="topic_pic"<?php if($_GET['topic_pic'] == '1'){ ?> checked="true"<?php } ?>> Have</label>
					<label style="margin-left:10px; float:left;"><input type="radio" value="2" name="topic_pic"<?php if($_GET['topic_pic'] == '2'){ ?> checked="true"<?php } ?>> Not have</label>
					<label style="margin-left:10px; float:left;"><input type="radio" value="0" name="topic_pic"<?php if(!$_GET['topic_pic']){ ?> checked="true"<?php } ?>> Unlimited</label>
				</p>
				<p style="clear:both;">
					<label> Whether there is descriptive content:</label>
					<label style="float:left;"><input type="radio" value="1" name="topic_description"<?php if($_GET['topic_description'] == '1'){ ?> checked="true"<?php } ?>> Have</label>
					<label style="margin-left:10px; float:left;"><input type="radio" value="2" name="topic_description"<?php if($_GET['topic_description'] == '2'){ ?> checked="true"<?php } ?>> Not have</label>
					<label style="margin-left:10px; float:left;"><input type="radio" value="0" name="topic_description"<?php if(!$_GET['topic_description']){ ?> checked="true"<?php } ?>> Unlimited</label>
				</p>
				<p style="clear:both;">
					<input type="button" onclick="ajax_post($('#search_form'), _form_process);" value="Search" class="button">
				</p>
				</form>
			</div>
			
			
		</div>
		
		
		<div class="clear"></div>
		<div id="notf_tip" style="display:none;" class="notification png_bg"> <a href="javascript:;" class="close"><img src="<?php echo GET_STATIC_URL;?>/admin/images/icons/cross_grey_small.png" alt="Close" /></a>
			<div id="notf_cont"></div>
		</div>
		
	</div>
	
<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

</body>
</html>