Author: cmailleux
Date: Wed Aug 16 14:43:21 2006
New Revision: 14908
URL: https://svndev.jahia.net/websvn/listing.php?sc=1&rev=14908&repname=jahia
Log:
Resolve issue JAHIA-1269
Modified:
trunk/core/src/java/org/jahia/engines/containerlistproperties/ContainerListProperties_Engine.java
trunk/core/src/webapp/jsp/jahia/engines/containerlistproperties/containerlistproperties.jsp
Modified:
trunk/core/src/java/org/jahia/engines/containerlistproperties/ContainerListProperties_Engine.java
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/java/org/jahia/engines/containerlistproperties/ContainerListProperties_Engine.java&rev=14908&repname=jahia
==============================================================================
---
trunk/core/src/java/org/jahia/engines/containerlistproperties/ContainerListProperties_Engine.java
(original)
+++
trunk/core/src/java/org/jahia/engines/containerlistproperties/ContainerListProperties_Engine.java
Wed Aug 16 14:43:21 2006
@@ -685,119 +685,11 @@
theScreen = "edit";
// init engine map
engineMap = new HashMap ();
- theContainerList = ServicesRegistry.getInstance ().
- getJahiaContainersService ().loadContainerList (
- cListID, LoadFlags.NOTHING, jParams);
- engineMap.put ("theContainerList", theContainerList);
-
- // print out container list properties
- Properties props = theContainerList.getProperties ();
- Enumeration propNameEnum = props.propertyNames ();
- String p = EMPTY_STRING;
- while (propNameEnum.hasMoreElements ()) {
- p = (String) propNameEnum.nextElement ();
- logger.debug ("Properties : " + props.getProperty (p));
- }
-
- // the ordered list of containers
- Vector containers = new Vector ();
- Enumeration containerList = theContainerList.getContainers ();
- JahiaContainer theContainer = null;
- // the info displayed to make the difference between containers
- Vector fieldInfoToDisplay = new Vector ();
- String fieldInfo = EMPTY_STRING;
- int cnt = 0;
-
- while (containerList.hasMoreElements ()) {
- cnt++;
- theContainer = (JahiaContainer) containerList.nextElement ();
- // let's order the container fields in the exact order in
which they are decrared in the template
- // ( not as in the order in which they are stored in db )
- theContainer.setLanguageCode (jParams.getEntryLoadRequest ().
- getFirstLocale (true).toString ());
- theContainer.fieldsStructureCheck (jParams);
- containers.add (theContainer);
- fieldInfo = getFieldInfoToDisplay (0, theContainer, jParams);
- if (fieldInfo != null) {
- if (fieldInfo.equals (EMPTY_STRING)) {
- fieldInfo = "-- Item " + cnt + " --";
- }
- } else {
- fieldInfo = "-- Item " + cnt + " --";
- }
- fieldInfoToDisplay.add (fieldInfo);
- getSortInfo4Date (0, theContainer, jParams);
- }
-
- JahiaField theField = null;
- Enumeration fieldsList = null;
- Vector fields = null;
- Vector fieldsAndMetadata = null;
-
- if (theContainer == null) {
- // no containers in the container list
- // create an empty container facade
- ContentPage contentPage =
- ContentPage.getPage (theContainerList.getPageID (),
false);
- JahiaContentContainerFacade contentContainerFacade =
- new JahiaContentContainerFacade (0,
- contentPage.getJahiaID (),
- theContainerList.getPageID (),
- theContainerList.getID (),
- theContainerList.getctndefid (),
- //contentPage.getAclID(),
- 0,
- jParams,
- jParams.getSite
().getLanguageSettingsAsLocales (false));
- if (contentContainerFacade.getContainers ().hasMoreElements
()) {
- theContainer = (JahiaContainer)
- contentContainerFacade.getContainers ().
- nextElement ();
- if (theContainer != null) {
- theContainerList.addContainer (theContainer);
- }
- }
- }
-
- if (theContainer != null) {
- fieldsList = theContainer.getFields ();
-
- fields = new Vector ();
-
- while (fieldsList.hasMoreElements ()) {
- theField = (JahiaField) fieldsList.nextElement ();
- fields.add (theField);
- }
-
- fieldsAndMetadata = new Vector(fields);
-
- List metadatas =
theContainer.getContentContainer().getMetadatas();
- for (int i = 0; i < metadatas.size(); i++) {
- ContentField contentField = (ContentField)
metadatas.get(i);
-
fieldsAndMetadata.add(contentField.getJahiaField(jParams.getEntryLoadRequest()));
- }
- }
-
- engineMap.put ("containers", containers);
- engineMap.put ("fields_metadata", fieldsAndMetadata);
- engineMap.put ("fields_nometadata", fields);
+ theContainerList = fillEngineMap(cListID, jParams, engineMap,0);
engineMap.put ("cursorField", new Integer (0));
- engineMap.put ("fieldInfoToDisplay", fieldInfoToDisplay);
engineMap.put ("containerSelected", new Integer (0));
-
- // build container list field acl
- HashMap fieldAcls = buildFieldDefAcls (theContainerList, jParams,
- engineMap);
- engineMap.put ("fieldAcls", fieldAcls);
}
- if (theScreen.equals("edit")) {
- engineMap.put ("fields", engineMap.get("fields_metadata"));
- } else if (theScreen.equals("ctneditview_rights")) {
- engineMap.put ("fields", engineMap.get("fields_nometadata"));
- }
-
-
if (theContainerList == null) {
throw new JahiaException ("ContainerList not found",
"ContainerListProperties_Engine : ContainerList not found",
@@ -813,6 +705,18 @@
engineMap.put(JahiaEngine.ENGINE_LANGUAGE_HELPER,elh);
}
elh.update(jParams);
+
if(!elh.getCurrentLanguageCode().equals(elh.getPreviousLanguageCode())) {
+ EntryLoadRequest entryLoadRequest = jParams.getEntryLoadRequest();
+ jParams.setEntryLoadRequest(elh.getCurrentEntryLoadRequest());
+ fillEngineMap(cListID, jParams,
engineMap,((Integer)engineMap.get("cursorField")).intValue());
+ jParams.setEntryLoadRequest(entryLoadRequest);
+ }
+
+ if (theScreen.equals("edit")) {
+ engineMap.put ("fields", engineMap.get("fields_metadata"));
+ } else if (theScreen.equals("ctneditview_rights")) {
+ engineMap.put ("fields", engineMap.get("fields_nometadata"));
+ }
Properties extraParams = new Properties ();
String containerListName = theContainerList.getDefinition ().getName
();
@@ -875,6 +779,115 @@
return engineMap;
}
+ private JahiaContainerList fillEngineMap(int cListID, ProcessingContext
jParams, HashMap engineMap, int cursorField) throws JahiaException {
+ JahiaContainerList theContainerList;
+ theContainerList = ServicesRegistry.getInstance ().
+ getJahiaContainersService ().loadContainerList (
+ cListID, LoadFlags.NOTHING, jParams);
+ engineMap.put ("theContainerList", theContainerList);
+
+ // print out container list properties
+ Properties props = theContainerList.getProperties ();
+ Enumeration propNameEnum = props.propertyNames ();
+ String p = EMPTY_STRING;
+ while (propNameEnum.hasMoreElements ()) {
+ p = (String) propNameEnum.nextElement ();
+ logger.debug ("Properties : " + props.getProperty (p));
+ }
+
+ // the ordered list of containers
+ Vector containers = new Vector ();
+ Enumeration containerList = theContainerList.getContainers ();
+ JahiaContainer theContainer = null;
+ // the info displayed to make the difference between containers
+ Vector fieldInfoToDisplay = new Vector ();
+ String fieldInfo = EMPTY_STRING;
+ int cnt = 0;
+
+ while (containerList.hasMoreElements ()) {
+ cnt++;
+ theContainer = (JahiaContainer) containerList.nextElement ();
+ // let's order the container fields in the exact order in which
they are decrared in the template
+ // ( not as in the order in which they are stored in db )
+ theContainer.setLanguageCode (jParams.getEntryLoadRequest ().
+ getFirstLocale (true).toString ());
+ theContainer.fieldsStructureCheck (jParams);
+ containers.add (theContainer);
+ fieldInfo = getFieldInfoToDisplay (cursorField, theContainer,
jParams);
+ if (fieldInfo != null) {
+ if (fieldInfo.equals (EMPTY_STRING)) {
+ fieldInfo = "-- Item " + cnt + " --";
+ }
+ } else {
+ fieldInfo = "-- Item " + cnt + " --";
+ }
+ fieldInfoToDisplay.add (fieldInfo);
+ getSortInfo4Date (0, theContainer, jParams);
+ }
+
+ JahiaField theField = null;
+ Enumeration fieldsList = null;
+ Vector fields = null;
+ Vector fieldsAndMetadata = null;
+
+ if (theContainer == null) {
+ // no containers in the container list
+ // create an empty container facade
+ ContentPage contentPage =
+ ContentPage.getPage (theContainerList.getPageID (), false);
+ JahiaContentContainerFacade contentContainerFacade =
+ new JahiaContentContainerFacade (0,
+ contentPage.getJahiaID (),
+
theContainerList.getPageID (),
+ theContainerList.getID (),
+
theContainerList.getctndefid (),
+ //contentPage.getAclID(),
+ 0,
+ jParams,
+ jParams.getSite
().getLanguageSettingsAsLocales (false));
+ if (contentContainerFacade.getContainers ().hasMoreElements ()) {
+ theContainer = (JahiaContainer)
+ contentContainerFacade.getContainers ().
+ nextElement ();
+ if (theContainer != null) {
+ theContainerList.addContainer (theContainer);
+ }
+ }
+ }
+
+ if (theContainer != null) {
+ fieldsList = theContainer.getFields ();
+
+ fields = new Vector ();
+
+ while (fieldsList.hasMoreElements ()) {
+ theField = (JahiaField) fieldsList.nextElement ();
+ fields.add (theField);
+ }
+
+ fieldsAndMetadata = new Vector(fields);
+
+ List metadatas = theContainer.getContentContainer().getMetadatas();
+ for (int i = 0; i < metadatas.size(); i++) {
+ ContentField contentField = (ContentField) metadatas.get(i);
+ JahiaField jahiaField =
contentField.getJahiaField(jParams.getEntryLoadRequest());
+ if(jahiaField!=null)
+ fieldsAndMetadata.add(jahiaField);
+ }
+ }
+
+ engineMap.put ("containers", containers);
+ engineMap.put ("fields_metadata", fieldsAndMetadata);
+ engineMap.put ("fields_nometadata", fields);
+ engineMap.put ("fieldInfoToDisplay", fieldInfoToDisplay);
+
+ // build container list field acl
+ HashMap fieldAcls = buildFieldDefAcls (theContainerList, jParams,
+ engineMap);
+ engineMap.put ("fieldAcls", fieldAcls);
+ return theContainerList;
+ }
+
/**
* loads container list data for the JSP file
*
@@ -1025,6 +1038,9 @@
engineMap.put ("automatic", containerSort);
shell_sort (jParams, engineMap, containerSort);
}
+ else if(engineMap.get("automatic")!=null){
+ shell_sort (jParams, engineMap, (String)
engineMap.get("automatic"));
+ }
// ****end automatic ranking ****
}
Modified:
trunk/core/src/webapp/jsp/jahia/engines/containerlistproperties/containerlistproperties.jsp
URL:
https://svndev.jahia.net/websvn/diff.php?path=/trunk/core/src/webapp/jsp/jahia/engines/containerlistproperties/containerlistproperties.jsp&rev=14908&repname=jahia
==============================================================================
---
trunk/core/src/webapp/jsp/jahia/engines/containerlistproperties/containerlistproperties.jsp
(original)
+++
trunk/core/src/webapp/jsp/jahia/engines/containerlistproperties/containerlistproperties.jsp
Wed Aug 16 14:43:21 2006
@@ -22,6 +22,8 @@
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="org.jahia.data.fields.JahiaDateFieldUtil"%>
<%@ page import="java.text.DateFormat"%>
+<%@ page import="org.jahia.engines.JahiaEngine"%>
+<%@ page import="org.jahia.engines.EngineLanguageHelper"%>
<%@ taglib uri="JahiaLib" prefix="jahia" %>
<jsp:useBean id="jspSource" class="java.lang.String" scope="request"/>
@@ -72,7 +74,7 @@
theScreen.equals("rightsMgmt") ||
theScreen.equals("timeBasedPublishing") ||
theScreen.equals("ctneditview_rights"));
request.setAttribute("showEditMenu", new
Boolean(showEditMenu));
-
+ final EngineLanguageHelper elh = (EngineLanguageHelper)
engineMap.get(JahiaEngine.ENGINE_LANGUAGE_HELPER);
%>
@@ -210,7 +212,7 @@
<!--
<jahia:engineResourceBundle
resourceName="org.jahia.engines.title.label"/>:
- <%=theContainerList.getDefinition().getTitle(pageDefID,
jParams.getLocale())%> <br/>
+ <%=theContainerList.getDefinition().getTitle(pageDefID,
elh.getCurrentLocale())%> <br/>
<jahia:engineResourceBundle
resourceName="org.jahia.engines.name.label"/>;
<%=theContainerList.getDefinition().getName()%>
-->
@@ -244,7 +246,7 @@
<h4 class="small_type_big">
<jahia:engineResourceBundle
resourceName="org.jahia.engines.containerlistproperties.ContainerListProperties_Engine.containerListTitle.label"/>:
- <%=theContainerList.getDefinition().getTitle(pageDefID,
jParams.getLocale())%>
+ <%=theContainerList.getDefinition().getTitle(pageDefID,
elh.getCurrentLocale())%>
</h4>
<table>
@@ -259,7 +261,7 @@
for (int i = 0; i < fields.size(); i++) { %>
<option value="<%=i%>"
<% if(cursorFieldInt == i ){%> selected="selected" <% } %>>
-
<%=((JahiaField)fields.get(i)).getDefinition().getTitle(pageDefID,jParams.getLocale())%>
+
<%=((JahiaField)fields.get(i)).getDefinition().getTitle(pageDefID,elh.getCurrentLocale())%>
<% } %>
</select>
</td>
@@ -310,7 +312,7 @@
calendar.setTime(new Date(aLong.longValue()));
Locale locale = null;
try {
- locale = jParams.getLocale();
+ locale = elh.getCurrentLocale();
} catch ( Throwable t) {
}