<% 
	import org.exoplatform.faq.service.Question;
	import org.exoplatform.faq.webui.FAQUtils;
%>
<div class="ResultSearchQuestion $uicomponent.id" style="padding:8px;">
		<% uiform.begin() %>
		<div class="UIForm">
					<div class="TitleMoveThreads"><%= _ctx.appRes("ResultSearchQuestion.title.resultQuestion"); %></div>
 					<div class="UIHorizontalLayout">
 							<div class="UIPermissionManager">
 								<div class="UIPermissionInfo">
 									<table class="UIGrid" cellspacing="0" border="0" cellpadding="0">
 										<thead>
 											<tr>
 												<th style="width:30px"><%= _ctx.appRes("ResultSearchQuestion.title.icon"); %></th>
 												<th><%= _ctx.appRes("ResultSearchQuestion.title.author"); %></th>
 												<th><%= _ctx.appRes("ResultSearchQuestion.title.email"); %></th>
 												<th><%= _ctx.appRes("ResultSearchQuestion.title.question"); %></th>
 												<th><%= _ctx.appRes("ResultSearchQuestion.title.create-date"); %></th>
 												<th style="width30px"><%= _ctx.appRes("ResultSearchQuestion.title.action"); %></th>
 											</tr>
 										</thead>
 										<tbody>
 										<% 
 										List questions = uicomponent.getListQuestion() ; 
 										if(questions.size()>0) {
										for(question in questions) {
											String questionId = question.getId();
											String author = question.getAuthor() ;
											String email = question.getEmail() ;
											String questionContent = question.getQuestion() ;
						 					String date = FAQUtils.getShortDateFormat(question.getCreatedDate());
											String view = uicomponent.event("View", questionId);
											String link = uicomponent.event("Link",questionId) ;
											String icon = "" ;
											if(question.getAnswers() != null && question.getAnswers().length > 0) {
												icon = "QuestionSearch" ;
											} else {
												icon = "NotResponseSearch" ;
											}
 										 %>
	 											<tr class="EvenRow">
	 												<td class="text" style="text-align:center;">
	 													<div class="$icon"><span></span></div>
 													</td>
	 												<td class="text" style="text-align:left"><%= author%></td>
	 												<td class="text" style="text-align:left"><%= (email != null) ? email: ""%></td>
	 												<%
													if(questionContent.length()>50) {
														String title = questionContent ;
														title = FAQUtils.getTitle(title) ; 
														questionContent = FAQUtils.getSubString(questionContent,50) ;
													%>
													<td class="text" style="text-align:left"><a href="$view" title="$title">$questionContent</a></td>
													<%
													} else {
													%>
													<td class="text" style="text-align:left"><a href="$view">$questionContent</a></td>
													<%}%>
	 												<td class="text" style="text-align:center"><%=date%></td>
	 												<td style="text-align:center; cursor:pointer">
 														<div onclick="$link"><div class="CheckIcon" style="margin:0px auto;"></div></div>
 													</td>
	 											</tr>
 												<% 
 												}
 											} else {
 										 %>
 										 <tr class="EvenRow">
												<td class="Tdbox" colspan="6" style="text-align:center">
													<div><%= _ctx.appRes("ResultSearch.title.no-matches"); %></div>
												</td>
			  							</tr>
										<% } %> 
 									</tbody>
 								</table>
 								<% 
 								long totalPages = uicomponent.getTotalpages("LIST_RESULT_SEARCH") ;
					      if(totalPages > 1) {
					      %>
 									<div style="overflow:auto;">
										<% uicomponent.renderChild(uicomponent.LIST_RESULT_SEARCH) ; %>
									</div>
								<% } %>
 						</div>
 					</div>
 				</div>
 		</div>
		<%uiform.end()%>
</div>