dpillot 2005/10/11 11:51:38 CEST
Modified files:
core/src/webapp/jsp/jahia/engines/importexport contentpick.jsp
Log:
date display & selection enhancements
Revision Changes Path
1.25 +277 -207
jahia/core/src/webapp/jsp/jahia/engines/importexport/contentpick.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/engines/importexport/contentpick.jsp.diff?r1=1.24&r2=1.25&f=h
Index: contentpick.jsp
===================================================================
RCS file:
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/engines/importexport/contentpick.jsp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- contentpick.jsp 10 Oct 2005 08:44:12 -0000 1.24
+++ contentpick.jsp 11 Oct 2005 09:51:38 -0000 1.25
@@ -4,18 +4,77 @@
java.util.HashMap" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="org.jahia.services.sites.JahiaSite" %>
-<%@ page import="java.util.Date" %>
-<%@ page import="java.util.Vector" %>
<%@ page import="org.jahia.services.containers.ContentContainer" %>
-<%@ page import="org.apache.log4j.Logger"%>
-<%@ page import="org.jahia.exceptions.JahiaException"%>
-<%@ page import="java.text.SimpleDateFormat"%>
+<%@ page import="org.apache.log4j.Logger" %>
+<%@ page import="org.jahia.exceptions.JahiaException" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.DateFormat" %>
<%@ taglib uri="/WEB-INF/etc/taglibs/pager-taglib" prefix="pg" %>
<%@ taglib uri="JahiaLib" prefix="jahia" %>
+<%!
+
+
+ private static final org.apache.log4j.Logger logger =
+ org.apache.log4j.Logger.getLogger("jsp.jahia.engines.engine");
+
+ /**
+ * to format a date in a friendly way
+ * @param hit
+ * @param datekey
+ * @param l
+ * @return a date string
+ */
+ public String printFriendlyDate(JahiaSearchHit hit, String datekey,
Locale l) {
+ String s = "NA";
+ long d = 0;
+ //formatters
+ SimpleDateFormat df = new SimpleDateFormat("EEEE dd MMM yyyy -
HH:mm:ss", l);
+ SimpleDateFormat sd = new SimpleDateFormat("HH:mm", l);
+
+ //calendar points
+ GregorianCalendar now = new GregorianCalendar(l);
+ now.set(Calendar.HOUR_OF_DAY,
now.getActualMinimum(Calendar.HOUR_OF_DAY));
+ now.set(Calendar.MINUTE, now.getActualMinimum(Calendar.MINUTE));
+ now.set(Calendar.SECOND, now.getActualMinimum(Calendar.SECOND));
+ GregorianCalendar hier = new GregorianCalendar(l);
+ hier.roll(Calendar.DATE, false);
+ hier.set(Calendar.HOUR_OF_DAY,
hier.getActualMinimum(Calendar.HOUR_OF_DAY));
+ hier.set(Calendar.MINUTE, hier.getActualMinimum(Calendar.MINUTE));
+ hier.set(Calendar.SECOND, hier.getActualMinimum(Calendar.SECOND));
+
+ //date value of hit
+ String val = hit.getParsedObject().getValue(datekey).trim();
+ if (val != null
+ && !val.equalsIgnoreCase("")
+ && !val.equalsIgnoreCase("<text>")
+ && !val.equalsIgnoreCase("<empty>")) {
+ try {
+ d = Long.parseLong(val);
+ Calendar c = Calendar.getInstance(l);
+ c.setTime(new Date(d));
+ if (c.after(now)) {
+ return "today a " + sd.format(new Date(d));
+ } else if (c.after(hier) && c.before(now)) {
+ return "hier a " + sd.format(new Date(d));
+ }
+ logger.debug(c.getTime());
+ s = df.format(new Date(d));
+ } catch (NumberFormatException e) {
+ //defensive code!
+ logger.debug(e);
+
+ }
+
+ }
+ return s;
+ }
+
+%>
<%
/**
- * @version $Id: contentpick.jsp,v 1.24 2005/10/10 08:44:12 knguyen Exp $
+ * @version $Id: contentpick.jsp,v 1.25 2005/10/11 09:51:38 dpillot Exp $
*/
HashMap engineMap = (HashMap)
request.getAttribute("org.jahia.engines.EngineHashMap");
@@ -24,10 +83,11 @@
//parameter to order the results (def:score)
String orderBy = (String) engineMap.get("orderby");
// # of sites
- int sitecount=Integer.parseInt((String)engineMap.get("sitecount"));
+ int sitecount = Integer.parseInt((String) engineMap.get("sitecount"));
// server path
- String
serverpath="http://"+request.getServerName()+":"+request.getServerPort();
- String searchsite=(String) engineMap.get("searchSite");
+ String serverpath = "http://" + request.getServerName() + ":" +
request.getServerPort();
+ String searchsite = (String) engineMap.get("searchSite");
+
%>
<!-- css specific for contentpicker -->
@@ -94,7 +154,7 @@
if (keycode == 13)
{
//document.mainForm.screen.value = "contentPick";
- handleActionChange('contentPick');
+ goSearch();
//return false;
}
else
@@ -112,84 +172,125 @@
document.getElementById(cid).style.display = "none"
}
- // search function to preprocess and check validity of queries
+ // search function to preprocess queries
function goSearch() {
//alert("searching....");
+ //condition1
+ /*
+ var valquery=document.getElementById("mainForm").query.value;
+ var idx=document.getElementById("mainForm").cond1.selectedIndex;
+ var cond=document.mainForm.condition1.options[idx].value;
+ if(cond=="and"){
+
+ val valquery_array=valquery.split(" ");
+ valquery="";
+ for(n=0;n<valquery_array.length;n++) {
+ valquery=valquery+" AND "+valquery_array[n];
+ }
+ document.getElementById("mainForm").query.value=valquery
+ }
+ */
handleActionChange("contentPick");
}
//
- function viewDoc(path){
+ function viewDoc(path) {
//alert(path);
- opener.location=path;
+ opener.location = path;
}
</script>
<input type="hidden" name="orderby" value="score"/>
+<input type="hidden" name="bigquery" value=""/>
<table border=0><tr><td>
<div id="sc1" class="switchcontent1">
- <a href="javascript:expandcontent('sc2')"><img
src="/jahia/jsp/jahia/engines/images/adding.png" width="16"
- height="16"
border="0"></a>
- <!-- query -->
- <INPUT name="query" size=50
value="<%=engineMap.get("searchString")%>"
onkeypress="submitenter(this,window.event)"/>
+ <select name="condition1" id="cond1" onchange="goSearch()">
+ <option value="or" selected="selected">au moins un des
mots</option>
+ <option value="and">tous les mots</option>
+ <option value="exact">la phrase exacte</option>
+
+ </select>
+ <!-- query -->
+ <INPUT name="query" size=50
value="<%=engineMap.get("searchString")%>"
+ onkeypress="submitenter(this,window.event)"/>
- <%
- int count = 0;
- Enumeration enum = (Enumeration) engineMap.get("sites");
- if(sitecount>1){
+ <%
+ int count = 0;
+ Enumeration enum = (Enumeration) engineMap.get("sites");
+ if (sitecount > 1) {
// looping on all sites
- %>
+ %>
- <select name="searchSite">
+ <select name="searchSite" onchange="goSearch()">
<%
- String isSelected="";
+ String isSelected = "";
while (enum.hasMoreElements()) {
JahiaSite jahiaSite = (JahiaSite) enum.nextElement();
- String id=""+jahiaSite.getID();
- String key=""+jahiaSite.getSiteKey();
- if(searchsite.equalsIgnoreCase(id))
isSelected="selected=selected";
- else isSelected="";
+ String id = "" + jahiaSite.getID();
+ String key = "" + jahiaSite.getSiteKey();
+ if (searchsite.equalsIgnoreCase(id)) isSelected =
"selected=selected";
+ else
+ isSelected = "";
count++;
%>
<option value="<%=id%>" <%=isSelected%>><%=key%></option>
<%
}//end looping
- if(searchsite.equalsIgnoreCase("all"))
isSelected="selected=selected";
+ if (searchsite.equalsIgnoreCase("all")) isSelected =
"selected=selected";
%>
<option value="all" <%=isSelected%>>all</option>
- </select>
- <%
- } else {
- // one site only
- JahiaSite jahiaSite = (JahiaSite) enum.nextElement();
- %>
+ </select>
+ <%
+ } else {
+ // one site only
+ JahiaSite jahiaSite = (JahiaSite) enum.nextElement();
+ %>
on site <b><%=jahiaSite.getSiteKey() %></b>
- <input type="hidden" name="searchSite"
value="<%=jahiaSite.getID() %>"/>
- <% } %>
+ <input type="hidden" name="searchSite" value="<%=jahiaSite.getID()
%>"/>
+ <% } %>
+ <a href="javascript:expandcontent('sc2')"><img
src="/jahia/jsp/jahia/engines/images/adding.png" width="16"
+ height="16"
border="0"></a>
</div>
-
+ <!-- some other queries criteria -->
<div id="sc2" class="switchcontent">
+ <select name="condition2" onchange="goSearch()">
+ <option label="creator" value="creator"
selected="selected"></option>
+ <option label="keywords" value="keywords"></option>
+
+ </select>
+ <INPUT size=50 value="" name="query2"/>
<a href="javascript:expandcontent('sc3')"><img
src="/jahia/jsp/jahia/engines/images/adding.png" width="16"
height="16"
border="0"></a><a
href="javascript:contractcontent('sc2')"><img
src="/jahia/jsp/jahia/engines/images/deleting.png" width="16"
height="16"
border="0"></a>
- <INPUT size=50 value="" name="query2"/>
</div>
<div id="sc3" class="switchcontent">
+ <select name="condition3" onchange="goSearch()">
+ <option label="creator" value="creator"
selected="selected"></option>
+ <option label="keywords" value="keywords"></option>
+
+ </select>
+ <INPUT size=50 value="" name="query3"/>
<a href="javascript:expandcontent('sc4')"><img
src="/jahia/jsp/jahia/engines/images/adding.png" width="16"
height="16"
border="0"></a><a
href="javascript:contractcontent('sc3')"><img
src="/jahia/jsp/jahia/engines/images/deleting.png" width="16"
height="16"
border="0"></a>
- <INPUT size=50 value="" name="query3"/>
+
</div>
<div id="sc4" class="switchcontent">
+ <select name="condition4" onchange="goSearch()">
+ <option label="creator" value="creator"
selected="selected"></option>
+ <option label="keywords" value="keywords"></option>
+
+ </select>
+ <INPUT size=50 value="" name="query4"/>
<a href="javascript:expandcontent('sc5')"><img
src="/jahia/jsp/jahia/engines/images/adding.png" width="16"
height="16"
border="0"></a><a
href="javascript:contractcontent('sc4')"><img
src="/jahia/jsp/jahia/engines/images/deleting.png" width="16"
@@ -203,186 +304,155 @@
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
- <TBODY>
+<TBODY>
- <%
- if (sr != null) {
- int totalHits = sr.getHitCount();
- %>
+<%
+ if (sr != null) {
+ int totalHits = sr.getHitCount();
+%>
- <TR>
- <TD class="text">
- <fieldset>
- <legend>Results</legend>
- <table width="100%" border="0" cellspacing="0"
cellpadding="0">
- <tr>
- <td valign="top" width="100%"
class="maintable10">
- <%
- if (totalHits != 0) {
- %>
- <table border="0" cellspacing="0"
cellpadding="4" width="100%">
- <tr>
- <th class="text">
- <% if
(orderBy.equalsIgnoreCase("score")) { %>
- nom
- <% } else { %>
- <a
href="javascript:orderby('score');">nom</a>
- <% } %>
- </th>
- <th class="text">
- <% if
(orderBy.equalsIgnoreCase("creator")) { %>
- creator
- <% } else { %>
- <a
href="javascript:orderby('creator');">creator</a>
- <% } %>
- </th>
- <th class="text">
- <% if
(orderBy.equalsIgnoreCase("lastcontributor")) { %>
- last contributor
- <% } else { %>
- <a
href="javascript:orderby('lastcontributor');">last
- contributor</a>
- <% } %>
- </th>
- <th class="text">usage</th>
- <!--th class="text">score</th-->
- <th class="text">
- <% if
(orderBy.equalsIgnoreCase("creationdate")) { %>
- creation date
- <% } else { %>
- <a
href="javascript:orderby('creationdate');">creation date</a>
- <% } %>
- </th>
- <th class="text">
- <% if
(orderBy.equalsIgnoreCase("lastpublishdate")) { %>
- last publish
- date
- <% } else { %>
- <a
href="javascript:orderby('lastpublishdate');">last publish
- date</a>
- <% } %>
- </th>
- <th
class="text"><center>Copy</center></th>
- <th class="text"><center>Linked
Copy</center></th>
- </tr>
-
- <%
-
-
- for (int i = 0; i < totalHits; i++) {
- JahiaSearchHit thisHit =
(JahiaSearchHit) sr.results().get(i);
- String url="#";
- if(thisHit.getTeaser()!=null &&
!thisHit.getTeaser().equalsIgnoreCase("")){
- url=serverpath+thisHit.getURL();
- }
- String sitekey=null;
- int pickers=0;
- try {
- sitekey =
ServicesRegistry.getInstance().getJahiaSitesService().getSite(thisHit.getPage().getJahiaID()).getSiteKey();
- pickers =
ContentContainer.getContainer(Integer.parseInt(thisHit.getId())).getPickerObjects().size();
- } catch (JahiaException e) {
- e.printStackTrace(); //To
change body of catch statement use File | Settings | File Templates.
- }
- SimpleDateFormat df=new
SimpleDateFormat("",request.getLocale());
-
-
- %>
- <tr>
- <td class="text"><a
href="javascript:viewDoc('<%=url%>')" alt="<%=thisHit.getId()%> in
<%=sitekey%>"><b><%=thisHit.getTeaser()%></b></a>
- </td>
- <td
class="text"><%=thisHit.getParsedObject().getValue("creator")%></td>
- <td
class="text"><%=thisHit.getParsedObject().getValue("lastcontributor")%></td>
- <td class="text"><%=pickers%></td>
- <!--td class="text">score :
<%=thisHit.getScore()%></td-->
- <td class="text">
- <% if
(thisHit.getParsedObject().getValue("creationdate") != null
- &&
!thisHit.getParsedObject().getValue("creationdate").equalsIgnoreCase("")
- &&
!thisHit.getParsedObject().getValue("creationdate").equalsIgnoreCase("<text>")
- &&
!thisHit.getParsedObject().getValue("creationdate").equalsIgnoreCase("<empty>"))
{ %>
- <%=new
Date(Long.parseLong(thisHit.getParsedObject().getValue("creationdate"))).toString()%>
- <% } else { %>
- NA
- <% } %>
- </td>
- <td class="text">
- <% if
(thisHit.getParsedObject().getValue("lastpublishingdate") != null
- &&
!thisHit.getParsedObject().getValue("lastpublishingdate").equalsIgnoreCase("")
- &&
!thisHit.getParsedObject().getValue("creationdate").equalsIgnoreCase("<text>")
- &&
!thisHit.getParsedObject().getValue("lastpublishingdate").equalsIgnoreCase("<empty>"))
{ %>
- <%=new
Date(Long.parseLong(thisHit.getParsedObject().getValue("lastpublishingdate"))).toString()%>
- <% } else { %>
- NA
- <% } %>
- </td>
- <td class="text"><center><input
type="radio" name="contentPickOp"
-
value="copy_<%=thisHit.getId()%>"/></center>
- </td>
- <td class="text"><center><input
type="radio" name="contentPickOp"
-
value="link_<%=thisHit.getId()%>"/></center>
- </td>
- </tr>
- <%
- }
- %>
- </table>
- <%
- } else {
- %>
- <div class="text">No Match.</div>
- <%
- }
- %>
- </td>
- </tr>
- </table>
- </fieldset>
- </TD></tr>
+<TR>
+<TD class="text">
+<fieldset>
+<legend>Results</legend>
+<table width="100%" border="0" cellspacing="0" cellpadding="0">
+<tr>
+<td valign="top" width="100%" class="maintable10">
+<%
+ if (totalHits != 0) {
+%>
+<table border="0" cellspacing="0" cellpadding="4" width="100%">
+ <tr>
+ <th class="text">
+ <% if (orderBy.equalsIgnoreCase("score")) { %>
+ nom
+ <% } else { %>
+ <a href="javascript:orderby('score');">nom</a>
+ <% } %>
+ </th>
+ <th class="text">
+ <% if (orderBy.equalsIgnoreCase("creator")) { %>
+ creator
+ <% } else { %>
+ <a href="javascript:orderby('creator');">creator</a>
+ <% } %>
+ </th>
+ <th class="text">
+ <% if (orderBy.equalsIgnoreCase("lastcontributor")) { %>
+ last contributor
+ <% } else { %>
+ <a href="javascript:orderby('lastcontributor');">last
+ contributor</a>
+ <% } %>
+ </th>
+ <th class="text">usage</th>
+ <!--th class="text">score</th-->
+ <th class="text">
+ <% if (orderBy.equalsIgnoreCase("creationdate")) { %>
+ creation date
+ <% } else { %>
+ <a href="javascript:orderby('creationdate');">creation date</a>
+ <% } %>
+ </th>
+ <th class="text">
+ <% if (orderBy.equalsIgnoreCase("lastpublishdate")) { %>
+ last publish
+ date
+ <% } else { %>
+ <a href="javascript:orderby('lastpublishdate');">last publish
+ date</a>
+ <% } %>
+ </th>
+ <th class="text"><center>Copy</center></th>
+ <th class="text"><center>Linked Copy</center></th>
+ </tr>
+
+ <%
- <%
+ for (int i = 0; i < totalHits; i++) {
+ JahiaSearchHit thisHit = (JahiaSearchHit) sr.results().get(i);
+ String url = "#";
+ if (thisHit.getTeaser() != null &&
!thisHit.getTeaser().equalsIgnoreCase("")) {
+ url = serverpath + thisHit.getURL();
+ }
+ String sitekey = null;
+ int pickers = 0;
+ try {
+ sitekey =
ServicesRegistry.getInstance().getJahiaSitesService().getSite(thisHit.getPage().getJahiaID()).getSiteKey();
+ pickers =
ContentContainer.getContainer(Integer.parseInt(thisHit.getId())).getPickerObjects().size();
+ } catch (JahiaException e) {
+ e.printStackTrace(); //To change body of catch statement
use File | Settings | File Templates.
}
- %>
- </TBODY>
-</TABLE>
-</div><!-- end editor part -->
-</div><!-- end content part -->
+ String cdate = printFriendlyDate(thisHit, "creationdate",
request.getLocale());
+ String pdate = printFriendlyDate(thisHit, "lastpublishingdate",
request.getLocale());
+ %>
+ <tr>
+ <td class="text"><a href="<%=url%>" alt="<%=thisHit.getId()%> in
<%=sitekey%>"
+ target="new"><b><%=thisHit.getTeaser()%></b></a>
+ </td>
+ <td
class="text"><%=thisHit.getParsedObject().getValue("creator")%></td>
+ <td
class="text"><%=thisHit.getParsedObject().getValue("lastcontributor")%></td>
+ <td class="text"><%=pickers%></td>
+ <!--td class="text">score : <%=thisHit.getScore()%></td-->
+ <td class="text">
+ <%=cdate%>
+ </td>
+ <td class="text">
+ <%=pdate%>
+
+ </td>
+ <td class="text"><center><input type="radio" name="contentPickOp"
+
value="copy_<%=thisHit.getId()%>"/></center>
+ </td>
+ <td class="text"><center><input type="radio" name="contentPickOp"
+
value="link_<%=thisHit.getId()%>"/></center>
+ </td>
+ </tr>
+ <%
+ }
+ %>
+</table>
+<%
+} else {
+%>
+<div class="text">No Match.</div>
+<%
+ }
+%>
+</td>
+</tr>
+</table>
+</fieldset>
+</TD></tr>
+
+<%
+ }
+%>
+</TBODY>
+</TABLE>
+</div><!-- end editor part -->
+</div><!-- end content part -->
<div class="clearing"> <!--clearing--></div>
</div><!-- end menu wrapper part -->
<% /**
- * $Log: contentpick.jsp,v $
- * Revision 1.24 2005/10/10 08:44:12 knguyen
- * - remove unused JahiaSearchConstant
- *
- * Revision 1.23 2005/10/07 13:58:14 dpillot
- * removed prefix useless
- *
- * Revision 1.22 2005/10/07 12:45:34 knguyen
- * - synchro
- *
- * Revision 1.21 2005/10/07 11:23:35 tdraier
- * fixed metadata display
- *
- * Revision 1.20 2005/10/07 10:01:30 dpillot
- * cross-browser adaptation (ie,firefox,etc) changes related in css files
- *
- * Revision 1.19 2005/10/05 08:36:53 dpillot
- * order interface changes
- *
- * Revision 1.18 2005/10/04 09:24:12 dpillot
- * bug fix
- *
- * Revision 1.17 2005/10/03 16:25:07 dpillot
- * view page container
- *
- * Revision 1.16 2005/10/03 15:43:22 dpillot
- * bug fix
- *
- * Revision 1.15 2005/09/30 17:46:31 dpillot
- * bug fix
- *
- */
+ * $Log: contentpick.jsp,v $
+ * Revision 1.25 2005/10/11 09:51:38 dpillot
+ * date display & selection enhancements
+ *
+ * Revision 1.24 2005/10/10 08:44:12 knguyen
+ * - remove unused JahiaSearchConstant
+ *
+ * Revision 1.23 2005/10/07 13:58:14 dpillot
+ * removed prefix useless
+ *
+ * Revision 1.22 2005/10/07 12:45:34 knguyen
+ * - synchro
+ *
+ *
+ */
%>
\ No newline at end of file