dpillot     2005/11/23 17:17:44 CET

  Modified files:
    core/src/webapp/jsp/jahia/engines/importexport dispPickers.jsp 
  Log:
  layout finalisation
  
  Revision  Changes    Path
  1.5       +190 -21   
jahia/core/src/webapp/jsp/jahia/engines/importexport/dispPickers.jsp
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/webapp/jsp/jahia/engines/importexport/dispPickers.jsp.diff?r1=1.4&r2=1.5&f=h
  
  
  
  Index: dispPickers.jsp
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/webapp/jsp/jahia/engines/importexport/dispPickers.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- dispPickers.jsp   22 Nov 2005 16:01:54 -0000      1.4
  +++ dispPickers.jsp   23 Nov 2005 16:17:44 -0000      1.5
  @@ -8,7 +8,11 @@
   <%@ page import="org.jahia.services.pages.ContentPage" %>
   <%@ page import="org.jahia.services.version.EntryLoadRequest" %>
   <%@ page import="java.util.*" %>
  -<%@ taglib uri="JahiaLib" prefix="jahia" %>
  +<%@ page import="org.jahia.params.ParamBean"%>
  +<%@ page import="java.text.SimpleDateFormat"%>
  +
  +<[EMAIL PROTECTED] import = "org.jahia.bin.Jahia"%>
  +<[EMAIL PROTECTED] uri="JahiaLib" prefix="jahia" %>
   <%@ page contentType="text/html;charset=UTF-8" language="java" %>
   <%!
   
  @@ -16,7 +20,7 @@
        * yet another new window to display some infos about Pickers.
        *
        * @author joe pillot
  -     * @version $Id: dispPickers.jsp,v 1.4 2005/11/22 16:01:54 dpillot Exp $
  +     * @version $Id: dispPickers.jsp,v 1.5 2005/11/23 16:17:44 dpillot Exp $
        */
   
       private static final String bundle_prefix = 
"org.jahia.engines.importexport.contentpick";
  @@ -110,9 +114,9 @@
                       }
                   }
                   if (!isPage) {
  -                    r = "<a class=\"picklink \" href=\"" + 
Jahia.getContextPath() + Jahia.getServletPath() + "/pid/" + pageID + "\" 
target=\"_new\">" + t + "</a> (id:" + key + " on site" + siteID + ")";
  +                    r = "<a href=\"" + Jahia.getContextPath() + 
Jahia.getServletPath() + "/pid/" + pageID + "\" target=\"_new\">" + t + 
"</a><br>(id:" + key + " on site" + siteID + ")";
                   } else {
  -                    r = "<a class=\"picklink \" href=\"" + 
Jahia.getContextPath() + Jahia.getServletPath() + "/pid/" + pageID + "\" 
target=\"_new\">" + t + "</a> (id:" + key + " on site" + siteID + ")";
  +                    r = "<a href=\"" + Jahia.getContextPath() + 
Jahia.getServletPath() + "/pid/" + pageID + "\" target=\"_new\">" + t + 
"</a><br>(id:" + key + " on site" + siteID + ")";
                   }
   
               } catch (JahiaException e) {
  @@ -140,11 +144,115 @@
   
       }
   
  +    /**
  +     * internal method to render bundle resources
  +     * @param bundle
  +     * @param prefix
  +     * @param label
  +     * @return a string (empty if resource non existent)
  +     */
  +    private String getRessource(ResourceBundle bundle, String prefix, String 
label) {
  +
  +        try {
  +            return bundle.getString(prefix + label);
  +        } catch (Exception e) {
  +            return "";
  +        }
  +
  +    }
  +
  +    /**
  +     * to format a hit date in a friendly way
  +     *
  +     * @param date
  +     * @param l
  +     * @return a date string
  +     */
  +    public String printFriendlyDate(String date, 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 = date;
  +        if (val != null
  +                && !"".equals(val.trim())
  +                && !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)) {
  +                    //TODO ressource bundle
  +                    return "aujourd'hui&nbsp;a&nbsp;" + sd.format(new 
Date(d));
  +                } else if (c.after(hier) && c.before(now)) {
  +                    return "hier&nbsp;a&nbsp;" + sd.format(new Date(d));
  +                }
  +
  +                s = df.format(new Date(d));
  +            } catch (NumberFormatException e) {
  +                //defensive code!
  +                logger.debug(e);
  +
  +            }
  +
  +        }
  +        return s;
  +    }
  +
  +    private boolean isPageType(ContentObject o){
  +        boolean isPage = false;
  +
  +        if (o instanceof ContentContainer) {
  +
  +            try {
  +                List l = getChildFieldsOnly(o.getChilds(null, null, null));
  +
  +
  +
  +                //looping list of childs to check page type?
  +                for (Iterator iterator1 = l.iterator(); 
iterator1.hasNext();) {
  +
  +                    ContentField contentField = (ContentField) 
iterator1.next();
  +                    if (contentField instanceof ContentPageField) {
  +                        isPage = true;
  +
  +
  +
  +                        break;
  +                    }
  +                }
  +
  +
  +            } catch (JahiaException e) {
  +                logger.error("error", e);
   
  +            }
  +        }
  +        return isPage;
  +    }
   %>
   <%
  +
       // to bundle html labels
  -    ResourceBundle bundle = 
ResourceBundle.getBundle("JahiaEnginesResources", request.getLocale());
  +    ResourceBundle enginebundle = 
ResourceBundle.getBundle("JahiaEnginesResources", request.getLocale());
  +    ResourceBundle pickersbundle =  
ResourceBundle.getBundle("jahiatemplates.Corporate_portal_templates", 
request.getLocale());
   
       // flag to warn if some param miss or error ocurred
       boolean render = true;
  @@ -161,13 +269,13 @@
   
   
       Set pickers = null;
  -    List l = null;
       Iterator it;
  -    String disp = "";
  +    boolean isPage=false;
       try {
           ContentContainer cc = ContentContainer.getContainer(id); //our 
picked object
           if (cc != null) {
               pickers = cc.getPickerObjects();
  +            isPage=isPageType(cc);
               //l = getChildFieldsOnly(cc.getChilds(null, 
EntryLoadRequest.CURRENT, null));
           } else {
               render = false;
  @@ -179,7 +287,7 @@
   
   %>
   <html>
  -<head><title><%=getRessource(bundle, ".pickers.title")%></title>
  +<head><title><%=getRessource(pickersbundle, "pickers.","title")%></title>
   
   
       <style type="text/css">
  @@ -188,8 +296,9 @@
               font-size: 12px;
               font-style: normal;
               font-weight: normal;
  +            margin: 10px;
               color: #838383;
  -            background-color: #FFF;
  +            background-color: #336699;
           }
   
           #poweredby {
  @@ -205,14 +314,41 @@
               font-weight: bold;
               color: #1E2A33;
           }
  +        h3 {
  +        font-size: 16px;
  +
  +        }
  +
  +        h3, a {
  +    color: #398EC3;
  +    text-decoration: none;
  +    font-weight: bold;
  +
  +}
  +
  +.version {
  +    float: right;
  +    text-align: right;
  +    font-size: 9px;
  +    vertical-align: bottom;
  +}
  +
  +#copyright {
  +     font-family: Verdana,Arial,Helvetica,sans-serif;
  +     font-size: 12px;
  +     color: #838383;
  +
  +}
       </style>
   </head>
   <%
       if (render) {
   %>
   <body>
  -<img src="/jahia/jsp/jahia/engines/images/view_next.png" width="48" 
height="48" border="0"><br>
  -
  +<table cellspacing="0" cellpadding="10" width="100%" border="0" 
bgcolor="#FFFFFF">
  +<TR><td width="48px">
  +<img src="/jahia/jsp/jahia/engines/images/branch_view.gif" width="48" 
height="48" border="0"></td><td align="left"><h3>copies 
li&eacute;es</h3></td></tr>
  +<tr><td colspan="2">
   <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
       <TBODY>
   
  @@ -221,42 +357,65 @@
               <TD class="text">
                   <fieldset>
                       <legend>
  -                        <!--%=getRessource(bundle, 
".pickers.table.title")%--><%=getRessource(bundle, ".results.label")%></legend>
  +                        <%=getRessource(pickersbundle, 
"pickers.","table.title")%></legend>
                       <table width="100%" border="0" cellspacing="1" 
cellpadding="0">
                           <tr bgcolor="#eeeeee" valign="top">
  -                            <th><%=getRessource(bundle, 
".results.name.label")%></th>
  -                            <th><%=getRessource(bundle, 
".results.author.label")%></th>
  -                            <th><%=getRessource(bundle, 
".results.contributor.label")%></th>
  -                            <th><%=getRessource(bundle, 
".results.publishdate.label")%></th>
  +                            <th><%=getRessource(enginebundle, 
".results.name.label")%></th>
  +
  +                            <th><%=getRessource(enginebundle, 
".results.publishdate.label")%></th>
                           </tr>
                           <%
                               if (pickers != null) {
                                   it = pickers.iterator();
                                   int count = 0;
                           %>
  -                        ID liste des pickers pour le picked id:<%=id%><br>
  +
  +                        <!--ID liste des pickers pour le picked 
id:--><%=getRessource(pickersbundle, "pickers.","picked.message1")%>:<%=id%> 
<%=getRessource(pickersbundle, "pickers.","picked.message2")%>
  +                        <%
  +                            if(isPage) {
  +                        %>
  +                        page
  +                        <%
  +                            } else {
  +                        %>
  +                        <%=getRessource(pickersbundle, 
"pickers.","picked.type")%>
  +                        <%
  +                            }
  +                        %>
  +                        <br>
                           <%
                               while (it.hasNext()) {
                                   logger.debug("count=" + count);
                                   ContentObject co = (ContentObject) it.next();
   
                                   String info = getInfoDisplay(co);
  +
  +                                String author="";
  +                                String lastcontributor ="";
  +                                String lastpublishingdate ="";
  +                                try {
  +                                    author = 
co.getMetadata("creator").getValue(null, EntryLoadRequest.CURRENT);
  +                                    lastcontributor = 
co.getMetadata("lastcontributor").getValue(null, EntryLoadRequest.CURRENT);
  +                                    lastpublishingdate = 
co.getMetadata("lastPublishingDate").getValue(null, EntryLoadRequest.CURRENT);
  +
  +                                } catch (JahiaException e) {
  +                                    logger.error("error:",e);
  +                                }
                                   String color = "#FFFFFF";
                                   if (count % 2 > 0) color = "#EEFFFF";
   
                           %>
                           <tr style="background-color:<%=color%>" 
onMouseOver="this.style.backgroundColor='#FFFFEE'"
                               
onMouseOut="this.style.backgroundColor='<%=color%>'">
  -                            <td><%=info%></td>
  -                            <td colspan="3"></td>
  +                            
<td><%=info%></td><td><%=printFriendlyDate(lastpublishingdate,request.getLocale())%></td>
                           </tr>
                           <%
                                   count++;
                               }
                           } else {
  -                            // todo resource bundle
  +
                           %>
  -                        <tr><td>il n' ya pas de pickers....</td></tr>
  +                        <tr><td><%=getRessource(pickersbundle, 
"pickers.","error.message")%></td></tr>
                           <% }
                           %>
   
  @@ -268,7 +427,14 @@
   
       </TBODY>
   </TABLE>
  +</td></tr>
  +<tr><td colspan="2">
   
  +<table border="0" width="100%"><tr><td width="48"><img name="logo" 
src="../../images/logo-jahia.gif" border="0" width="45" 
height="34"></td><td><img src="../images/pix.gif" border="0" width="1" 
height="10">
  +<div id="copyright"><%=Jahia.COPYRIGHT%></div><span class="version">Jahia v. 
<%=Jahia.VERSION%></span>
  +</td></tr></table>
  +</td></tr>
  +</table>
   </body>
   </html>
   <%
  @@ -281,6 +447,9 @@
       }
       /**
        * $Log: dispPickers.jsp,v $
  +     * Revision 1.5  2005/11/23 16:17:44  dpillot
  +     * layout finalisation
  +     *
        * Revision 1.4  2005/11/22 16:01:54  dpillot
        * better layout
        *
  

Reply via email to