search.jsp 15.5 KB
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ page language="java"%>
<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>

<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>

<%@ page import="pt.keep.metarepository.core.configuration.*"%>
<%@ page import="pt.keep.metarepository.core.database.orm.interfaces.*"%>
<%@ page import="pt.keep.metarepository.core.database.orm.entities.*"%>
<%@ page import="pt.keep.metarepository.core.database.orm.entities.data.*"%>
<%@ page import="pt.keep.metarepository.core.database.sql.OrderType"%>
<%@ page import="pt.keep.metarepository.core.localization.*"%>
<%@ page import="pt.keep.metarepository.core.util.data.*"%>
<%@ page import="pt.keep.metarepository.core.solr.SolrClient"%>
<%@ page import="pt.keep.metarepository.core.web.io.*"%>
<%@ page import="pt.keep.metarepository.core.web.tags.Translate"%>
<%@ page import="pt.keep.metarepository.modules.webui.io.session.*"%>
<%@ page import="pt.keep.metarepository.modules.webui.servlets.SearchServlet"%>

<%@ taglib uri="keep/tags/KeepTags.tld" prefix="KEEP"%>

<% String lang = LocalizationFetcher.getLocaleString(request,response); %>

<html xmlns="http://www.w3.org/1999/xhtml" lang="<%=lang%>"	xml:lang="<%=lang%>">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<jsp:include page="./metatags.jsp"></jsp:include>

	<title><KEEP:lang lang='<%=lang %>'	key="webui.general.rcaap.title" /></title>
	<link rel="alternate" type="application/rss+xml" title="RCAAP RSS"
		href="<KEEP:url url='/rss.xml' />" />
	<link rel="icon" href="favicon.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
	<link rel="search" type="application/opensearchdescription+xml"
		href="opensearch.xml" title="RCAAP Search" />
	<link rel="stylesheet" href="_css/init.css" type="text/css"
		media="screen,projection" />
	<link rel="stylesheet" href="_css/results.css" type="text/css"
		media="screen,projection" />
	<link rel="stylesheet" href="_css/results_<%=lang%>.css" type="text/css"
		media="screen,projection" />

<!--[if IE]>
	<link rel="stylesheet" href="_css/results_ie.css" type="text/css" media="screen,projection" />
	<![endif]-->
	<script type="text/javascript" src="_js/utils.js"></script>
	<script type="text/javascript">
		var txtMoreOptions = '<KEEP:lang lang='<%=lang %>' key="webui.advanced.see.more.items" />';
		var txtHideOptions = '<KEEP:lang lang='<%=lang %>' key="webui.advanced.see.few.items" />';
		var txtSelect = '<KEEP:lang lang='<%=lang %>' key="webui.advanced.select" />';
		var txtSelRep = '<KEEP:lang lang='<%=lang %>' key="webui.advanced.choose" />';
		var txtClose = '<KEEP:lang lang='<%=lang %>' key="webui.advanced.close" />';
	</script>
</head>
<%
	SearchParameters searchParams = (SearchParameters) session.getAttribute(Constants.SESSION_SEARCH_PARAMS);
	String allRep = request.getParameter("allRep"); 
	if(allRep!=null){
		if(allRep.equals("yes")){
			allRep="no";
			if(searchParams!=null){
				searchParams.setIncludeAllRepositories(false);
			}else{
				searchParams = new SearchParameters();
				searchParams.setIncludeAllRepositories(false);
				session.setAttribute(Constants.SESSION_SEARCH_PARAMS,searchParams);
			}
		}else{
			allRep="yes";
			if(searchParams!=null){
				searchParams.setIncludeAllRepositories(true);
			}else{
				searchParams = new SearchParameters();
				searchParams.setIncludeAllRepositories(true);
				session.setAttribute(Constants.SESSION_SEARCH_PARAMS,searchParams);
			}
		}
	}else{
		if(searchParams!=null){
			allRep=searchParams.includeAllRepositories()?"yes":"no";
		}else{
			allRep="yes";
		}
	}
	ArchiveInterface arqInterface  = new ArchiveInterface(getServletContext());
	int firstYear,lastYear;
	List<Archive> archives = null, inactiveArchives=null;
	if(allRep.equals("yes")){
		archives = arqInterface.findAllActive();
		inactiveArchives = arqInterface.findAllInactive();
	}else{
		archives = arqInterface.findAllActive("portugal");
		inactiveArchives = arqInterface.findAllInactive("portugal");
	}
	HashMap<String,Integer> minMaxMap = SolrClient.getInstance().getMinMaxFromIndexDocuments(allRep.equals("yes"),inactiveArchives);
	firstYear = minMaxMap.get("min");
	lastYear = minMaxMap.get("max");
	arqInterface.closeConnection();
	List<String> dcTypes = ConfigurationManager.getKnownDocTypes();
	List<String> languages = ConfigurationManager.getKnownLanguages();
%>
<body>
	<div id="siteBox">
		<div id="container">
			<jsp:include page="header.jsp" />
			<div id="searchIntro">
				<h1>
					<KEEP:lang lang='<%=lang %>' key='webui.advanced.legend' />
				</h1>
				<p>
					<KEEP:lang lang='<%=lang %>' key='webui.advanced.description' />
				</p>
			</div>
			<form action="<KEEP:url url='/search' />" id="frmAdvSearch"
				method="post">
				<input type="hidden" name="<%=Constants.REQUEST_FORMNAME %>"
					value="<%=SearchType.ADVANCED.toString() %>" /> <input
					type="hidden" name="<%=Constants.INCLUDE_ALL_REPOSITORIES%>"
					value="<%=allRep%>" />
				<div class="box1">
					<div class="floatBox">
						<div id="searchTxt" class="floatLeft">
							<h2>
								<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.terms' />
							</h2>
							<label for="fldName1" id="fldName1Box" class="txtOn"> <span><KEEP:lang
										lang='<%=lang %>' key='webui.advanced.search.type' />
							</span> <select name="<%=Constants.REQUEST_TERM_NAME %>1" id="fldName1"
								class="medium">
									<option value="<%=Document.COLUMN_TITLES %>"
										selected="selected">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.title' />
									</option>
									<option value="<%=Document.COLUMN_CREATORS %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.author' />
									</option>
									<option value="<%=Document.COLUMN_SUBJECTS %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.subject' />
									</option>
									<option value="<%=Document.COLUMN_DESCRIPTIONS %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.description' />
									</option>
									<option value="<%=Document.COLUMN_ALLTEXT %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.alltext' />
									</option>
							</select> </label> <label for="fld1" class="txtOn"> <span><KEEP:lang
										lang='<%=lang %>' key="webui.advanced.search.for" />
							</span> <input type="text" name="<%=Constants.REQUEST_TERM_VALUE %>1"
								id="fld1"
								value="<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.terms' />" />
							</label> <br />
							<% 
							int indice; 
							for (int n=0;n<2;n++) { 
								indice = n+2;
								String s1 = ""; 
								String s2 = ""; 
								if (indice == 2) s1 = " selected=\"selected\" ";
								if (indice == 3) s2 = " selected=\"selected\" ";
						%>
							<label for="join<%=indice %>"> <span><KEEP:lang
										lang='<%=lang %>' key="webui.advanced.search.compositors" />
							</span> <select name="<%=Constants.REQUEST_TERM_OP %><%=indice %>"
								id="join<%=indice %>" class="small">
									<option value="<%=OperationType.AND.toString() %>"
										selected="selected">
										<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.and' />
									</option>
									<option value="<%=OperationType.OR.toString() %>">
										<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.or' />
									</option>
									<option value="<%=OperationType.NOT.toString() %>">
										<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.not' />
									</option>
							</select> </label> <label for="fldName<%=indice %>"> <span>Tipo</span> <select
								name="<%=Constants.REQUEST_TERM_NAME %><%=indice %>"
								id="fldName<%=indice %>" class="medium">
									<option value="<%=Document.COLUMN_TITLES %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.title' />
									</option>
									<option value="<%=Document.COLUMN_CREATORS %>" <%=s1 %>>
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.author' />
									</option>
									<option value="<%=Document.COLUMN_SUBJECTS %>" <%=s2 %>>
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.subject' />
									</option>
									<option value="<%=Document.COLUMN_DESCRIPTIONS %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.description' />
									</option>
									<option value="<%=Document.COLUMN_ALLTEXT %>">
										<KEEP:lang lang='<%=lang %>'
											key='webui.advanced.search.type.alltext' />
									</option>
							</select> </label> <label for="fld<%=indice %>"> <span><KEEP:lang
										lang='<%=lang %>' key="webui.advanced.search.for" />
							</span> <input type="text"
								name="<%=Constants.REQUEST_TERM_VALUE %><%=indice %>"
								id="fld<%=indice %>"
								value="<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.terms' />" />
							</label> <br />
							<% } %>
							<div class="btnBox floatRight">
								<input type="submit" name="btnSearch"
									value="<KEEP:lang lang='<%=lang %>' key='webui.advanced.search.label' />" />
							</div>
							<br />
							<p class="floatRight">
								<KEEP:formatQuickStatisticsIndexExpression
									includeAll="<%=allRep%>" lang='<%=lang %>' />
							</p>
						</div>
						<div id="searchOrder" class="floatRight">
							<h2>
								<KEEP:lang lang='<%=lang %>'
									key='webui.advanced.presentation.options' />
							</h2>
							<label for="orderFld"><KEEP:lang lang='<%=lang %>'
									key='webui.advanced.presentation.order.by' />
							</label> <select name="<%=Constants.REQUEST_ORDER_COLUMN %>"
								id="orderFld">
								<option value="<%=ColumnOrder.RELEVANCE.toString()%>"
									selected="selected">
									<KEEP:lang lang='<%=lang %>'
										key='webui.advanced.presentation.order.relevance' />
								</option>
								<option value="<%=ColumnOrder.ISSUE_DATE.toString() %>">
									<KEEP:lang lang='<%=lang %>'
										key='webui.advanced.presentation.order.date' />
								</option>
							</select> <br /> <label for="order"><KEEP:lang lang='<%=lang %>'
									key='webui.advanced.presentation.order.label' />
							</label> <select name="<%=Constants.REQUEST_ORDER_TYPE %>" id="order">
								<option value="<%=OrderType.DESC.toString() %>"
									selected="selected">
									<KEEP:lang lang='<%=lang %>'
										key='webui.advanced.presentation.order.desc' />
								</option>
								<option value="<%=OrderType.ASC.toString() %>">
									<KEEP:lang lang='<%=lang %>'
										key='webui.advanced.presentation.order.asc' />
								</option>
							</select>
						</div>
					</div>
				</div>
				<div id="box2" class="box2">
					<div class="floatBox">
						<h2>
							<KEEP:lang lang='<%=lang %>' key='webui.advanced.filters.label' />
						</h2>
						<!--	DATE FILTER 	-->
						<div id="searchDate" class="floatLeft">
							<h3>
								<KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.date.label' />
							</h3>
							<label for="date1"><KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.date.since' />
							</label> <select name="<%=Constants.REQUEST_SINCE%>" id="date1">
								<option value="<%=firstYear %>" selected="selected"><%=firstYear %></option>
								<% 
							for (int i=firstYear+1;i<=lastYear;i++) { %>
								<option value="<%=i %>"><%=i %></option>
								<% } %>
							</select> <br /> <label for="date2"><KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.date.until' />
							</label> <select name="<%=Constants.REQUEST_UNTIL %>" id="date2">
								<%
							for (int i=firstYear;i<lastYear;i++) { %>
								<option value="<%=i %>"><%=i %></option>
								<% } %>
								<option value="<%=lastYear %>" selected="selected"><%=lastYear %></option>
							</select>
						</div>
						<div id="searchDocType" class="floatLeft">
							<h3>
								<KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.document.type' />
							</h3>
							<% 
						int i = 1;
						for (String type : dcTypes) {
							String name = LocalizationManager.getMessage("webui.doctype."+type,lang);
							String vis = (i>ConfigurationManager.getProperty("webui.advanced.doctypes.mini",5)) ? " class=\"off\" " : "";
						%>
							<label for="doc<%=i%>" <%=vis%>><input type="checkbox"
								value="<%=type %>" name="<%=Constants.REQUEST_DOCTYPE %>"
								id="doc<%=i++%>" /><%=name %></label><br />
							<% } %>
						</div>

						<!--	LANGUAGE 	-->
						<div id="searchLang" class="floatLeft">
							<h3>
								<KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.document.language' />
							</h3>
							<% 
						i = 1;
						for (String type : languages) {
							String name = LocalizationManager.getMessage("webui.language."+type,lang);
							String vis = (i>ConfigurationManager.getProperty("webui.advanced.languages.mini",5)) ? " class=\"off\" " : "";
						%>
							<label for="lang<%=i%>" <%=vis%>><input type="checkbox"
								value="<%=type %>" name="<%=Constants.REQUEST_LANGUAGE %>"
								id="lang<%=i++%>" /><%=name %></label><br />
							<% } %>
						</div>

						<!--	REPOSITORY 	-->
						<div id="searchRep" class="floatLeft">
							<h3>
								<KEEP:lang lang='<%=lang %>'
									key='webui.advanced.filters.repository.label' />
							</h3>

							<div id="fldGrpRep">
								<div class="fldGrp">
									<% 
								i = 1; 
								for (Archive item : archives) { %>
									<label for="rep<%=i %>"><input type="checkbox"
										value="<%=item.getId() %>"
										name="<%=Constants.REQUEST_REPOSITORY%>" id="rep<%=i++ %>" /><span><%=item.getName() %></span>
									</label><br />
									<% } %>
								</div>
							</div>

						</div>
					</div>
				</div>
			</form>
			<div id="changeSearchCountries">
				<form action="" method="post">
					<input type="hidden" name="allRep" value="<%=allRep%>" />
					<%
					if(allRep.equals("yes")){
				%>
					<input id="leftComponent" type="image"
						src="_img/pt_<%=allRep%>.png"
						title="<KEEP:lang lang='<%=lang %>' key='webui.index.changecountrysearch.portugal' />"
						alt="portugal logo" /> <img src="_img/pt_br_<%=allRep%>.png"
						title="<KEEP:lang lang='<%=lang %>' key='webui.index.changecountrysearch.all' />"
						alt="all logo" />
					<%
					}else{
				%>
					<img id="leftComponent" src="_img/pt_<%=allRep%>.png"
						title="<KEEP:lang lang='<%=lang %>' key='webui.index.changecountrysearch.portugal' />"
						alt="portugal logo" /> <input type="image"
						src="_img/pt_br_<%=allRep%>.png"
						title="<KEEP:lang lang='<%=lang %>' key='webui.index.changecountrysearch.all' />"
						alt="all logo" />

					<%
					}
				%>
				</form>
			</div>
			<jsp:include page="footer.jsp" />
		</div>
	</div>
	<script type="text/javascript" src="_js/search_init.js"></script>
	<noscript>JS usado serve para formatar elementos, não tem
		conteúdos dinãmicos</noscript>
	<script type="text/javascript">
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	<noscript>Para o Google Analytics</noscript>
	<script type="text/javascript">
		try {
			var pageTracker = _gat._getTracker("UA-6710497-1");
			pageTracker._trackPageview();
		} catch(err) {}
	</script>
	<noscript>Para o Google Analytics</noscript>
</body>
</html>