r1128 - in xwiki/trunk/src/main: java/com/xpn/xwiki java/com/xpn/xwiki/api java/com/xpn/xwiki/objects/classes java/com/xpn/xwiki/plugin/image java/com/xpn/xwiki/render/filter java/com/xpn/xwiki/render/macro java/com/xpn/xwiki/user/impl/xwiki java/com/xpn/xwiki/util java/com/xpn/xwiki/web web/WEB-INF web/templates

Ludovic Dubost ludovic at users.forge.objectweb.org
Thu Aug 10 11:41:52 CEST 2006


Author: ludovic
Date: 2006-08-10 11:41:51 +0200 (Thu, 10 Aug 2006)
New Revision: 1128

Added:
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/AdminAction.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/RedirectAction.java
Modified:
   xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/plugin/image/ImagePlugin.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/render/filter/XWikiHeadingFilter.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/render/filter/XWikiLinkFilter.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/render/macro/ImageMacro.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/user/impl/xwiki/XWikiRightServiceImpl.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/util/TOCGenerator.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/DeleteAction.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/EditAction.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackAction.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/RollbackForm.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/SkinAction.java
   xwiki/trunk/src/main/java/com/xpn/xwiki/web/Utils.java
   xwiki/trunk/src/main/web/WEB-INF/struts-config.xml
   xwiki/trunk/src/main/web/templates/history.vm
Log:
Many patches needed for the development of the new skin in the Google Summer of Code program
Includes new admin and redirect actions
Includes radio displayer for the List and Boolean classes


Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWiki.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1297,6 +1297,8 @@
     }
 
     public String getLanguagePreference(XWikiContext context) {
+    	return getDocLanguagePreference(context);
+        /*
         // First we get the language from the request
         String language;
 
@@ -1378,8 +1380,188 @@
 
         context.setLanguage("");
         return "";
+        */
     }
 
+    public String getDocLanguagePreference(XWikiContext context) {
+        String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", cookieLanguage = "", contextLanguage = "";
+        boolean setCookie = false;
+
+        if (!context.getWiki().isMultiLingual(context)) {
+            language = context.getWiki().getXWikiPreference("language", "", context);
+            context.setLanguage(language);
+            return language;
+        }
+
+        // Get request language
+        try{
+        	requestLanguage = context.getRequest().getParameter("language");
+        }
+        catch (Exception ex){
+        }
+
+        // Get context language
+       	contextLanguage = context.getLanguage();
+
+        // Get user preference
+        try {
+            String user = context.getUser();
+            XWikiDocument userdoc = getDocument(user, context);
+            if (userdoc != null) {
+                userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_language");
+            }
+        } catch (XWikiException e) {
+        }
+
+        // Get navigator language setting
+        if (context.getRequest() != null) {
+            String accept = context.getRequest().getHeader("Accept-Language");
+            if ((accept != null) && (!accept.equals(""))) {
+	            String[] alist = StringUtils.split(accept, ",;-");
+	            if ((alist != null) && !(alist.length == 0)) {
+	                context.setLanguage(alist[0]);
+	                navigatorLanguage = alist[0];
+	            }
+            }
+        }
+
+        // Get language from cookie
+        try {
+            cookieLanguage = getUserPreferenceFromCookie("language", context);
+        } catch (Exception e) {
+        }
+
+        // Determine which language to use
+        // First we get the language from the request
+        if ((requestLanguage != null) && (!requestLanguage.equals(""))) {
+            if (requestLanguage.equals("default")) {
+                setCookie = true;
+            } else {
+                language = requestLanguage;
+                context.setLanguage(language);
+            	Cookie cookie = new Cookie("language", language);
+                cookie.setMaxAge(60 * 60 * 24 * 365 * 10);
+                cookie.setPath("/");
+                context.getResponse().addCookie(cookie);
+                return language;
+            }
+        }
+        // Next we get the language from the context
+        if(contextLanguage != null && contextLanguage != ""){
+        	language = contextLanguage;
+        }
+        // Next we get the language from the cookie
+        else if(cookieLanguage != null && cookieLanguage != ""){
+        	language = cookieLanguage;
+        }
+        // Next from the default user preference
+        else if(userPreferenceLanguage != null && userPreferenceLanguage != ""){
+        	language = userPreferenceLanguage;
+        }
+        // Then from the navigator language setting
+        else if(navigatorLanguage != null && navigatorLanguage != ""){
+        	language = navigatorLanguage;
+        }
+        context.setLanguage(language);
+        if(setCookie){
+        	Cookie cookie = new Cookie("language", language);
+            cookie.setMaxAge(60 * 60 * 24 * 365 * 10);
+            cookie.setPath("/");
+            context.getResponse().addCookie(cookie);
+        }
+        return language;
+    }
+
+    public String getInterfaceLanguagePreference(XWikiContext context) {
+        String language = "", requestLanguage = "", userPreferenceLanguage = "", navigatorLanguage = "", cookieLanguage = "", contextLanguage = "";
+        boolean setCookie = false;
+
+        if (!context.getWiki().isMultiLingual(context)) {
+            language = context.getWiki().getXWikiPreference("language", "", context);
+            context.setInterfaceLanguage(language);
+            return language;
+        }
+
+        // Get request language
+        try{
+        	requestLanguage = context.getRequest().getParameter("interfacelanguage");
+        }
+        catch (Exception ex){
+        }
+
+        // Get context language
+       	contextLanguage = context.getInterfaceLanguage();
+
+        // Get user preference
+        try {
+            String user = context.getUser();
+            XWikiDocument userdoc = null;
+            userdoc = getDocument(user, context);
+            if (userdoc != null) {
+                userPreferenceLanguage = userdoc.getStringValue("XWiki.XWikiUsers", "default_interface_language");
+            }
+        } catch (XWikiException e) {
+        }
+
+        // Get navigator language setting
+        if (context.getRequest() != null) {
+            String accept = context.getRequest().getHeader("Accept-Language");
+            if ((accept != null) && (!accept.equals(""))) {
+	            String[] alist = StringUtils.split(accept, ",;-");
+	            if ((alist != null) && !(alist.length == 0)) {
+	                context.setLanguage(alist[0]);
+	                navigatorLanguage = alist[0];
+	            }
+            }
+        }
+
+        // Get language from cookie
+        try {
+            cookieLanguage = getUserPreferenceFromCookie("interfacelanguage", context);
+        } catch (Exception e) {
+        }
+
+        // Determine which language to use
+        // First we get the language from the request
+        if ((requestLanguage != null) && (!requestLanguage.equals(""))) {
+            if (requestLanguage.equals("default")) {
+                setCookie = true;
+            } else {
+                language = requestLanguage;
+                context.setLanguage(language);
+            	Cookie cookie = new Cookie("interfacelanguage", language);
+                cookie.setMaxAge(60 * 60 * 24 * 365 * 10);
+                cookie.setPath("/");
+                context.getResponse().addCookie(cookie);
+                return language;
+            }
+        }
+        // Next we get the language from the context
+        if(contextLanguage != null && contextLanguage != ""){
+        	language = contextLanguage;
+        }
+        // Next we get the language from the cookie
+        else if(cookieLanguage != null && cookieLanguage != ""){
+        	language = cookieLanguage;
+        }
+        // Next from the default user preference
+       else if(userPreferenceLanguage != null && userPreferenceLanguage != ""){
+        	language = userPreferenceLanguage;
+       }
+        // Then from the navigator language setting
+        else if(navigatorLanguage != null && navigatorLanguage != ""){
+        	language = navigatorLanguage;
+        }
+        context.setLanguage(language);
+        if(setCookie){
+        	Cookie cookie = new Cookie("interfacelanguage", language);
+            cookie.setMaxAge(60 * 60 * 24 * 365 * 10);
+            cookie.setPath("/");
+            context.getResponse().addCookie(cookie);
+        }
+        return language;
+    }
+
     public long getXWikiPreferenceAsLong(String prefname, XWikiContext context) {
         return Long.parseLong(getXWikiPreference(prefname, context));
     }
@@ -2089,7 +2271,7 @@
 
     public void prepareResources(XWikiContext context) {
         if (context.get("msg") == null) {
-            String language = getLanguagePreference(context);
+            String language = getInterfaceLanguagePreference(context);
             if (context.getResponse() != null)
                 context.getResponse().setLocale(new Locale(language));
             ResourceBundle bundle = ResourceBundle.getBundle("ApplicationResources", new Locale(language));
@@ -2627,7 +2809,7 @@
     }
 
     public String getEncoding() {
-        return Param("xwiki.encoding", "ISO-8859-1");
+        return Param("xwiki.encoding", "UTF-8");
     }
 
 
@@ -3585,6 +3767,9 @@
 
     public String getEditorPreference(XWikiContext context) {
         String pref = getUserPreference("editor", context);
+        if (pref.equals("---")){
+        	pref = getWebPreference("editor", context);
+        }
         if (pref.equals(""))
             pref = Param("xwiki.editor", "");
         return pref.toLowerCase();

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiContext.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,296 +1,305 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author wr0ngway
- * @author sdumitriu
- */
-
-package com.xpn.xwiki;
-
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.apache.xmlrpc.XmlRpcServer;
-
-import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.doc.XWikiDocumentArchive;
-import com.xpn.xwiki.user.api.XWikiUser;
-import com.xpn.xwiki.util.Util;
-import com.xpn.xwiki.web.XWikiEngineContext;
-import com.xpn.xwiki.web.XWikiForm;
-import com.xpn.xwiki.web.XWikiRequest;
-import com.xpn.xwiki.web.XWikiResponse;
-import com.xpn.xwiki.web.XWikiURLFactory;
-import com.xpn.xwiki.objects.classes.BaseClass;
-
-public class XWikiContext extends Hashtable {
-
-   public static final int MODE_SERVLET = 0;
-   public static final int MODE_PORTLET = 1;
-   public static final int MODE_XMLRPC = 2;
-   public static final int MODE_ATOM = 3;
-   public static final int MODE_PDF = 4;
-
-   private boolean finished = false;
-   private XWiki wiki;
-   private XWikiEngineContext engine_context;
-   private XWikiRequest request;
-   private XWikiResponse response;
-   private XWikiForm form;
-   private String action;
-   private String orig_database;
-   private String database;
-   private boolean virtual;
-   private XWikiUser user;
-   private String language;
-   private int mode;
-   private URL url;
-   private XWikiURLFactory URLFactory;
-   private XmlRpcServer xmlRpcServer;
-   private String wikiOwner;
-   private XWikiDocument wikiServer;
-   private int cacheDuration = 0;
-
-   // Used to avoid recursive loading of documents if there are recursives usage of classes
-   private Map classCache = new HashMap();
-   // Used to avoir reloading archives in the same request
-   private Map archiveCache = new HashMap();
-
-   public XWikiContext() {
-   }
-
-   public XWiki getWiki() {
-       return wiki;
-   }
-
-   public Util getUtil() {
-       Util util = (Util) this.get("util");
-       if (util==null) {
-           util = new Util();
-           this.put("util", util);
-       }
-       return util;
-    }
-
-    public void setWiki(XWiki wiki) {
-        this.wiki = wiki;
-    }
-
-    public XWikiEngineContext getEngineContext() {
-        return engine_context;
-    }
-
-    public void setEngineContext(XWikiEngineContext engine_context) {
-        this.engine_context = engine_context;
-    }
-
-    public XWikiRequest getRequest() {
-        return request;
-    }
-
-    public void setRequest(XWikiRequest request) {
-        this.request = request;
-    }
-
-    public String getAction() {
-        return action;
-    }
-
-    public void setAction(String action) {
-        this.action = action;
-    }
-
-    public XWikiResponse getResponse() {
-        return response;
-    }
-
-    public void setResponse(XWikiResponse response) {
-        this.response = response;
-    }
-
-    public String getDatabase() {
-        return database;
-    }
-
-    public void setDatabase(String database) {
-        this.database = database;
-        if (orig_database==null)
-            orig_database = database;
-    }
-
-    public String getOriginalDatabase() {
-        return orig_database;
-    }
-
-    public void setOriginalDatabase(String database) {
-        this.orig_database = database;
-    }
-
-    public boolean isVirtual() {
-        return virtual;
-    }
-
-    public void setVirtual(boolean virtual) {
-        this.virtual = virtual;
-    }
-
-    public XWikiDocument getDoc() {
-        return (XWikiDocument) get("doc");
-    }
-
-    public void setDoc(XWikiDocument doc) {
-        put("doc", doc);
-    }
-
-    public void setUser(String user, boolean main) {
-        this.user = new XWikiUser(user, main);
-    }
-
-    public void setUser(String user) {
-        this.user = new XWikiUser(user);
-    }
-
-    public String getUser() {
-        if (user!=null)
-         return user.getUser();
-        else
-         return "XWiki.XWikiGuest";
-    }
-
-    public String getLocalUser() {
-        String username = getUser();
-        return username.substring(username.indexOf(":") + 1);
-    }
-
-    public XWikiUser getXWikiUser() {
-        return user;
-    }
-
-    public String getLanguage() {
-        return language;
-    }
-
-    public void setLanguage(String language) {
-        this.language = language;
-    }
-
-    public int getMode() {
-        return mode;
-    }
-
-    public void setMode(int mode) {
-        this.mode = mode;
-    }
-
-    public URL getURL() {
-        return url;
-    }
-
-    public void setURL(URL url) {
-        this.url = url;
-    }
-
-    public XWikiURLFactory getURLFactory() {
-        return URLFactory;
-    }
-
-    public void setURLFactory(XWikiURLFactory URLFactory) {
-        this.URLFactory = URLFactory;
-    }
-
-    public XWikiForm getForm() {
-        return form;
-    }
-
-    public void setForm(XWikiForm form) {
-        this.form = form;
-    }
-
-    public boolean isFinished() {
-        return this.finished;
-    }
-
-    public void setFinished(boolean finished) {
-        this.finished = finished;
-    }
-
-    public XmlRpcServer getXMLRPCServer() {
-        return xmlRpcServer;
-    }
-
-    public void setXMLRPCServer(XmlRpcServer xmlRpcServer) {
-        this.xmlRpcServer = xmlRpcServer;
-    }
-
-    public void setWikiOwner(String wikiOwner) {
-        this.wikiOwner = wikiOwner;
-    }
-
-    public String getWikiOwner() {
-        return wikiOwner;
-    }
-
-    public void setWikiServer(XWikiDocument doc) {
-        wikiServer = doc;
-    }
-
-    public XWikiDocument getWikiServer() {
-        return wikiServer;
-    }
-
-    public int getCacheDuration() {
-        return cacheDuration;
-    }
-
-    public void setCacheDuration(int cacheDuration) {
-        this.cacheDuration = cacheDuration;
-    }
-
-    public String getMainXWiki() {
-        return (String ) get("mainxwiki");
-    }
-
-    public void setMainXWiki(String str) {
-        put("mainxwiki", str);
-    }
-
-    // Used to avoid recursive loading of documents if there are recursives usage of classes
-    public void addBaseClass(BaseClass bclass) {
-        classCache.put(bclass.getName(), bclass);
-    }
-
-    // Used to avoid recursive loading of documents if there are recursives usage of classes
-    public BaseClass getBaseClass(String name) {
-        return (BaseClass) classCache.get(name);
-    }
-
-    // Used to avoid recursive loading of documents if there are recursives usage of classes
-    public void addDocumentArchive(String  key, Object obj) {
-        classCache.put(key, obj);
-    }
-
-    // Used to avoid recursive loading of documents if there are recursives usage of classes
-    public Object getDocumentArchive(String key) {
-        return classCache.get(key);
-    }
-
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author wr0ngway
+ * @author sdumitriu
+ */
+
+package com.xpn.xwiki;
+
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.HashMap;
+
+import org.apache.xmlrpc.XmlRpcServer;
+
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.doc.XWikiDocumentArchive;
+import com.xpn.xwiki.user.api.XWikiUser;
+import com.xpn.xwiki.util.Util;
+import com.xpn.xwiki.web.XWikiEngineContext;
+import com.xpn.xwiki.web.XWikiForm;
+import com.xpn.xwiki.web.XWikiRequest;
+import com.xpn.xwiki.web.XWikiResponse;
+import com.xpn.xwiki.web.XWikiURLFactory;
+import com.xpn.xwiki.objects.classes.BaseClass;
+
+public class XWikiContext extends Hashtable {
+
+   public static final int MODE_SERVLET = 0;
+   public static final int MODE_PORTLET = 1;
+   public static final int MODE_XMLRPC = 2;
+   public static final int MODE_ATOM = 3;
+   public static final int MODE_PDF = 4;
+
+   private boolean finished = false;
+   private XWiki wiki;
+   private XWikiEngineContext engine_context;
+   private XWikiRequest request;
+   private XWikiResponse response;
+   private XWikiForm form;
+   private String action;
+   private String orig_database;
+   private String database;
+   private boolean virtual;
+   private XWikiUser user;
+   private String language;
+   private String interfaceLanguage;
+   private int mode;
+   private URL url;
+   private XWikiURLFactory URLFactory;
+   private XmlRpcServer xmlRpcServer;
+   private String wikiOwner;
+   private XWikiDocument wikiServer;
+   private int cacheDuration = 0;
+
+   // Used to avoid recursive loading of documents if there are recursives usage of classes
+   private Map classCache = new HashMap();
+   // Used to avoir reloading archives in the same request
+   private Map archiveCache = new HashMap();
+
+   public XWikiContext() {
+   }
+
+   public XWiki getWiki() {
+       return wiki;
+   }
+
+   public Util getUtil() {
+       Util util = (Util) this.get("util");
+       if (util==null) {
+           util = new Util();
+           this.put("util", util);
+       }
+       return util;
+    }
+
+    public void setWiki(XWiki wiki) {
+        this.wiki = wiki;
+    }
+
+    public XWikiEngineContext getEngineContext() {
+        return engine_context;
+    }
+
+    public void setEngineContext(XWikiEngineContext engine_context) {
+        this.engine_context = engine_context;
+    }
+
+    public XWikiRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(XWikiRequest request) {
+        this.request = request;
+    }
+
+    public String getAction() {
+        return action;
+    }
+
+    public void setAction(String action) {
+        this.action = action;
+    }
+
+    public XWikiResponse getResponse() {
+        return response;
+    }
+
+    public void setResponse(XWikiResponse response) {
+        this.response = response;
+    }
+
+    public String getDatabase() {
+        return database;
+    }
+
+    public void setDatabase(String database) {
+        this.database = database;
+        if (orig_database==null)
+            orig_database = database;
+    }
+
+    public String getOriginalDatabase() {
+        return orig_database;
+    }
+
+    public void setOriginalDatabase(String database) {
+        this.orig_database = database;
+    }
+
+    public boolean isVirtual() {
+        return virtual;
+    }
+
+    public void setVirtual(boolean virtual) {
+        this.virtual = virtual;
+    }
+
+    public XWikiDocument getDoc() {
+        return (XWikiDocument) get("doc");
+    }
+
+    public void setDoc(XWikiDocument doc) {
+        put("doc", doc);
+    }
+
+    public void setUser(String user, boolean main) {
+        this.user = new XWikiUser(user, main);
+    }
+
+    public void setUser(String user) {
+        this.user = new XWikiUser(user);
+    }
+
+    public String getUser() {
+        if (user!=null)
+         return user.getUser();
+        else
+         return "XWiki.XWikiGuest";
+    }
+
+    public String getLocalUser() {
+        String username = getUser();
+        return username.substring(username.indexOf(":") + 1);
+    }
+
+    public XWikiUser getXWikiUser() {
+        return user;
+    }
+
+    public String getLanguage() {
+        return language;
+    }
+
+    public void setLanguage(String language) {
+        this.language = language;
+    }
+
+    public String getInterfaceLanguage() {
+        return interfaceLanguage;
+    }
+
+    public void setInterfaceLanguage(String interfaceLanguage) {
+        this.interfaceLanguage = interfaceLanguage;
+    }
+
+    public int getMode() {
+        return mode;
+    }
+
+    public void setMode(int mode) {
+        this.mode = mode;
+    }
+
+    public URL getURL() {
+        return url;
+    }
+
+    public void setURL(URL url) {
+        this.url = url;
+    }
+
+    public XWikiURLFactory getURLFactory() {
+        return URLFactory;
+    }
+
+    public void setURLFactory(XWikiURLFactory URLFactory) {
+        this.URLFactory = URLFactory;
+    }
+
+    public XWikiForm getForm() {
+        return form;
+    }
+
+    public void setForm(XWikiForm form) {
+        this.form = form;
+    }
+
+    public boolean isFinished() {
+        return this.finished;
+    }
+
+    public void setFinished(boolean finished) {
+        this.finished = finished;
+    }
+
+    public XmlRpcServer getXMLRPCServer() {
+        return xmlRpcServer;
+    }
+
+    public void setXMLRPCServer(XmlRpcServer xmlRpcServer) {
+        this.xmlRpcServer = xmlRpcServer;
+    }
+
+    public void setWikiOwner(String wikiOwner) {
+        this.wikiOwner = wikiOwner;
+    }
+
+    public String getWikiOwner() {
+        return wikiOwner;
+    }
+
+    public void setWikiServer(XWikiDocument doc) {
+        wikiServer = doc;
+    }
+
+    public XWikiDocument getWikiServer() {
+        return wikiServer;
+    }
+
+    public int getCacheDuration() {
+        return cacheDuration;
+    }
+
+    public void setCacheDuration(int cacheDuration) {
+        this.cacheDuration = cacheDuration;
+    }
+
+    public String getMainXWiki() {
+        return (String ) get("mainxwiki");
+    }
+
+    public void setMainXWiki(String str) {
+        put("mainxwiki", str);
+    }
+
+    // Used to avoid recursive loading of documents if there are recursives usage of classes
+    public void addBaseClass(BaseClass bclass) {
+        classCache.put(bclass.getName(), bclass);
+    }
+
+    // Used to avoid recursive loading of documents if there are recursives usage of classes
+    public BaseClass getBaseClass(String name) {
+        return (BaseClass) classCache.get(name);
+    }
+
+    // Used to avoid recursive loading of documents if there are recursives usage of classes
+    public void addDocumentArchive(String  key, Object obj) {
+        classCache.put(key, obj);
+    }
+
+    // Used to avoid recursive loading of documents if there are recursives usage of classes
+    public Object getDocumentArchive(String key) {
+        return classCache.get(key);
+    }
+
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/XWikiInterface.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,296 +1,300 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author vmassol
- * @author sdumitriu
- */
-
-package com.xpn.xwiki;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.velocity.VelocityContext;
-import org.hibernate.HibernateException;
-import org.securityfilter.filter.URLPatternMatcher;
-
-import com.xpn.xwiki.api.User;
-import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.notify.XWikiNotificationManager;
-import com.xpn.xwiki.notify.XWikiNotificationRule;
-import com.xpn.xwiki.objects.classes.BaseClass;
-import com.xpn.xwiki.objects.meta.MetaClass;
-import com.xpn.xwiki.plugin.XWikiPluginManager;
-import com.xpn.xwiki.render.XWikiRenderingEngine;
-import com.xpn.xwiki.store.XWikiStoreInterface;
-import com.xpn.xwiki.user.api.XWikiAuthService;
-import com.xpn.xwiki.user.api.XWikiGroupService;
-import com.xpn.xwiki.user.api.XWikiRightService;
-import com.xpn.xwiki.user.api.XWikiUser;
-import com.xpn.xwiki.web.XWikiEngineContext;
-import com.xpn.xwiki.web.XWikiRequest;
-
-public interface XWikiInterface {
-    void updateDatabase(String appname, XWikiContext context) throws HibernateException, XWikiException;
-
-    List getVirtualWikiList();
-
-    void initXWiki(XWikiConfig config, XWikiContext context, XWikiEngineContext engine_context, boolean noupdate) throws XWikiException;
-
-    String getVersion();
-
-    URL getResource(String s) throws MalformedURLException;
-
-    InputStream getResourceAsStream(String s) throws MalformedURLException;
-
-    String getResourceContent(String name) throws IOException;
-
-    boolean resourceExists(String name);
-
-    XWikiConfig getConfig();
-
-    String getRealPath(String path);
-
-    String Param(String key);
-
-    String ParamAsRealPath(String key);
-
-    String ParamAsRealPath(String key, XWikiContext context);
-
-    String ParamAsRealPathVerified(String param);
-
-    String Param(String key, String default_value);
-
-    long ParamAsLong(String key);
-
-    long ParamAsLong(String key, long default_value);
-
-    XWikiStoreInterface getStore();
-
-    void saveDocument(XWikiDocument doc, XWikiContext context) throws XWikiException;
-
-    void saveDocument(XWikiDocument doc, XWikiDocument olddoc, XWikiContext context) throws XWikiException;
-
-    XWikiDocument getDocument(XWikiDocument doc, String revision, XWikiContext context) throws XWikiException;
-
-    XWikiDocument getDocument(String fullname, XWikiContext context) throws XWikiException;
-
-    XWikiDocument getDocument(String web, String fullname, XWikiContext context) throws XWikiException;
-
-    XWikiDocument getDocumentFromPath(String path, XWikiContext context) throws XWikiException;
-
-    XWikiRenderingEngine getRenderingEngine();
-
-    void setRenderingEngine(XWikiRenderingEngine renderingEngine);
-
-    MetaClass getMetaclass();
-
-    void setMetaclass(MetaClass metaclass);
-
-    List getClassList(XWikiContext context) throws XWikiException;
-
-    List search(String wheresql, XWikiContext context) throws XWikiException;
-
-    List search(String wheresql, int nb, int start, XWikiContext context) throws XWikiException;
-
-    boolean isTest();
-
-    void setTest(boolean test);
-
-    String parseContent(String content, XWikiContext context);
-
-    String parseTemplate(String template, XWikiContext context);
-
-    String getSkinFile(String filename, XWikiContext context);
-
-    String getSkin(XWikiContext context);
-
-    String getWebCopyright(XWikiContext context);
-
-    String getXWikiPreference(String prefname, XWikiContext context);
-
-    String getXWikiPreference(String prefname, String default_value, XWikiContext context);
-
-    String getWebPreference(String prefname, XWikiContext context);
-
-    String getWebPreference(String prefname, String default_value, XWikiContext context);
-
-    String getUserPreference(String prefname, XWikiContext context);
-
-    String getUserPreferenceFromCookie(String prefname, XWikiContext context);
-
-    String getUserPreference(String prefname, boolean useCookie, XWikiContext context);
-
-    String getLanguagePreference(XWikiContext context);
-
-    long getXWikiPreferenceAsLong(String prefname, XWikiContext context);
-
-    long getWebPreferenceAsLong(String prefname, XWikiContext context);
-
-    long getXWikiPreferenceAsLong(String prefname, long default_value, XWikiContext context);
-
-    long getWebPreferenceAsLong(String prefname, long default_value, XWikiContext context);
-
-    int getXWikiPreferenceAsInt(String prefname, XWikiContext context);
-
-    int getWebPreferenceAsInt(String prefname, XWikiContext context);
-
-    int getXWikiPreferenceAsInt(String prefname, int default_value, XWikiContext context);
-
-    int getWebPreferenceAsInt(String prefname, int default_value, XWikiContext context);
-
-    void flushCache();
-
-    XWikiPluginManager getPluginManager();
-
-    void setPluginManager(XWikiPluginManager pluginManager);
-
-    void setConfig(XWikiConfig config);
-
-    void setStore(XWikiStoreInterface store);
-
-    void setVersion(String version);
-
-    XWikiNotificationManager getNotificationManager();
-
-    void setNotificationManager(XWikiNotificationManager notificationManager);
-
-    void notify(XWikiNotificationRule rule, XWikiDocument newdoc, XWikiDocument olddoc, int event, XWikiContext context);
-
-    BaseClass getUserClass(XWikiContext context) throws XWikiException;
-
-    BaseClass getGroupClass(XWikiContext context) throws XWikiException;
-
-    BaseClass getRightsClass(String pagename,XWikiContext context) throws XWikiException;
-
-    BaseClass getRightsClass(XWikiContext context) throws XWikiException;
-
-    BaseClass getGlobalRightsClass(XWikiContext context) throws XWikiException;
-
-    int createUser(XWikiContext context) throws XWikiException;
-
-    int validateUser(boolean withConfirmEmail, XWikiContext context) throws XWikiException;
-
-    int createUser(boolean withValidation, String userRights, XWikiContext context) throws XWikiException;
-
-    void sendValidationEmail(String xwikiname, String password, String email, String validkey, String contentfield, XWikiContext context) throws XWikiException;
-
-    void sendMessage(String sender, String[] recipient, String message, XWikiContext context) throws XWikiException;
-
-    void sendMessage(String sender, String recipient, String message, XWikiContext context) throws XWikiException;
-
-    String generateValidationKey(int size);
-
-    int createUser(String xwikiname, Map map, String parent, String content, String userRights, XWikiContext context) throws XWikiException;
-
-    User getUser(XWikiContext context);
-
-    void prepareResources(XWikiContext context);
-
-    XWikiUser checkAuth(XWikiContext context) throws XWikiException;
-
-    boolean checkAccess(String action, XWikiDocument doc, XWikiContext context)
-            throws XWikiException;
-
-    String include(String topic, XWikiContext context, boolean isForm) throws XWikiException;
-
-    void deleteDocument(XWikiDocument doc, XWikiContext context) throws XWikiException;
-
-    String getDatabase();
-
-    void setDatabase(String database);
-
-    void gc();
-
-    long freeMemory();
-
-    long totalMemory();
-
-    long maxMemory();
-
-    String[] split(String str, String sep);
-
-    String printStrackTrace(Throwable e);
-
-    boolean copyDocument(String docname, String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
-
-    int copyWikiWeb(String web, String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
-
-    int copyWiki(String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
-
-    int createNewWiki(String wikiName, String wikiUrl, String wikiAdmin,
-                      String baseWikiName, String description, String language, boolean failOnExist, XWikiContext context) throws XWikiException;
-
-    String getEncoding();
-
-    URL getServerURL(String database, XWikiContext context) throws MalformedURLException;
-
-    String getURL(String fullname, String action, XWikiContext context) throws XWikiException;
-
-    String getURL(String fullname, String action, String querystring, XWikiContext context) throws XWikiException;
-
-    // Usefull date functions
-    Date getCurrentDate();
-
-    int getTimeDelta(long time);
-
-    Date getDate(long time);
-
-    boolean isMultiLingual(XWikiContext context);
-
-    boolean isVirtual();
-
-    boolean isExo();
-
-    int checkActive(XWikiContext context) throws XWikiException;
-
-    boolean prepareDocuments(XWikiRequest request, XWikiContext context, VelocityContext vcontext) throws XWikiException, IOException;
-
-    XWikiEngineContext getEngineContext();
-
-    void setEngineContext(XWikiEngineContext engine_context);
-
-    URLPatternMatcher getUrlPatternMatcher();
-
-    void setUrlPatternMatcher(URLPatternMatcher urlPatternMatcher);
-
-    void setAuthService(XWikiAuthService authService);
-
-    void setRightService(XWikiRightService rightService);
-
-    XWikiGroupService getGroupService(XWikiContext context) throws XWikiException;
-
-    void setGroupService(XWikiGroupService groupService);
-
-    XWikiAuthService getAuthService();
-
-    XWikiRightService getRightService();
-
-    Object getService(String className) throws XWikiException;
-
-    String getUserName(String user, XWikiContext context);
-
-    String getUserName(String user, String format, XWikiContext context);
-
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author vmassol
+ * @author sdumitriu
+ */
+
+package com.xpn.xwiki;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.velocity.VelocityContext;
+import org.hibernate.HibernateException;
+import org.securityfilter.filter.URLPatternMatcher;
+
+import com.xpn.xwiki.api.User;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.notify.XWikiNotificationManager;
+import com.xpn.xwiki.notify.XWikiNotificationRule;
+import com.xpn.xwiki.objects.classes.BaseClass;
+import com.xpn.xwiki.objects.meta.MetaClass;
+import com.xpn.xwiki.plugin.XWikiPluginManager;
+import com.xpn.xwiki.render.XWikiRenderingEngine;
+import com.xpn.xwiki.store.XWikiStoreInterface;
+import com.xpn.xwiki.user.api.XWikiAuthService;
+import com.xpn.xwiki.user.api.XWikiGroupService;
+import com.xpn.xwiki.user.api.XWikiRightService;
+import com.xpn.xwiki.user.api.XWikiUser;
+import com.xpn.xwiki.web.XWikiEngineContext;
+import com.xpn.xwiki.web.XWikiRequest;
+
+public interface XWikiInterface {
+    void updateDatabase(String appname, XWikiContext context) throws HibernateException, XWikiException;
+
+    List getVirtualWikiList();
+
+    void initXWiki(XWikiConfig config, XWikiContext context, XWikiEngineContext engine_context, boolean noupdate) throws XWikiException;
+
+    String getVersion();
+
+    URL getResource(String s) throws MalformedURLException;
+
+    InputStream getResourceAsStream(String s) throws MalformedURLException;
+
+    String getResourceContent(String name) throws IOException;
+
+    boolean resourceExists(String name);
+
+    XWikiConfig getConfig();
+
+    String getRealPath(String path);
+
+    String Param(String key);
+
+    String ParamAsRealPath(String key);
+
+    String ParamAsRealPath(String key, XWikiContext context);
+
+    String ParamAsRealPathVerified(String param);
+
+    String Param(String key, String default_value);
+
+    long ParamAsLong(String key);
+
+    long ParamAsLong(String key, long default_value);
+
+    XWikiStoreInterface getStore();
+
+    void saveDocument(XWikiDocument doc, XWikiContext context) throws XWikiException;
+
+    void saveDocument(XWikiDocument doc, XWikiDocument olddoc, XWikiContext context) throws XWikiException;
+
+    XWikiDocument getDocument(XWikiDocument doc, String revision, XWikiContext context) throws XWikiException;
+
+    XWikiDocument getDocument(String fullname, XWikiContext context) throws XWikiException;
+
+    XWikiDocument getDocument(String web, String fullname, XWikiContext context) throws XWikiException;
+
+    XWikiDocument getDocumentFromPath(String path, XWikiContext context) throws XWikiException;
+
+    XWikiRenderingEngine getRenderingEngine();
+
+    void setRenderingEngine(XWikiRenderingEngine renderingEngine);
+
+    MetaClass getMetaclass();
+
+    void setMetaclass(MetaClass metaclass);
+
+    List getClassList(XWikiContext context) throws XWikiException;
+
+    List search(String wheresql, XWikiContext context) throws XWikiException;
+
+    List search(String wheresql, int nb, int start, XWikiContext context) throws XWikiException;
+
+    boolean isTest();
+
+    void setTest(boolean test);
+
+    String parseContent(String content, XWikiContext context);
+
+    String parseTemplate(String template, XWikiContext context);
+
+    String getSkinFile(String filename, XWikiContext context);
+
+    String getSkin(XWikiContext context);
+
+    String getWebCopyright(XWikiContext context);
+
+    String getXWikiPreference(String prefname, XWikiContext context);
+
+    String getXWikiPreference(String prefname, String default_value, XWikiContext context);
+
+    String getWebPreference(String prefname, XWikiContext context);
+
+    String getWebPreference(String prefname, String default_value, XWikiContext context);
+
+    String getUserPreference(String prefname, XWikiContext context);
+
+    String getUserPreferenceFromCookie(String prefname, XWikiContext context);
+
+    String getUserPreference(String prefname, boolean useCookie, XWikiContext context);
+
+    String getLanguagePreference(XWikiContext context);
+
+    String getDocLanguagePreference(XWikiContext context);
+
+    String getInterfaceLanguagePreference(XWikiContext context);
+
+    long getXWikiPreferenceAsLong(String prefname, XWikiContext context);
+
+    long getWebPreferenceAsLong(String prefname, XWikiContext context);
+
+    long getXWikiPreferenceAsLong(String prefname, long default_value, XWikiContext context);
+
+    long getWebPreferenceAsLong(String prefname, long default_value, XWikiContext context);
+
+    int getXWikiPreferenceAsInt(String prefname, XWikiContext context);
+
+    int getWebPreferenceAsInt(String prefname, XWikiContext context);
+
+    int getXWikiPreferenceAsInt(String prefname, int default_value, XWikiContext context);
+
+    int getWebPreferenceAsInt(String prefname, int default_value, XWikiContext context);
+
+    void flushCache();
+
+    XWikiPluginManager getPluginManager();
+
+    void setPluginManager(XWikiPluginManager pluginManager);
+
+    void setConfig(XWikiConfig config);
+
+    void setStore(XWikiStoreInterface store);
+
+    void setVersion(String version);
+
+    XWikiNotificationManager getNotificationManager();
+
+    void setNotificationManager(XWikiNotificationManager notificationManager);
+
+    void notify(XWikiNotificationRule rule, XWikiDocument newdoc, XWikiDocument olddoc, int event, XWikiContext context);
+
+    BaseClass getUserClass(XWikiContext context) throws XWikiException;
+
+    BaseClass getGroupClass(XWikiContext context) throws XWikiException;
+
+    BaseClass getRightsClass(String pagename,XWikiContext context) throws XWikiException;
+
+    BaseClass getRightsClass(XWikiContext context) throws XWikiException;
+
+    BaseClass getGlobalRightsClass(XWikiContext context) throws XWikiException;
+
+    int createUser(XWikiContext context) throws XWikiException;
+
+    int validateUser(boolean withConfirmEmail, XWikiContext context) throws XWikiException;
+
+    int createUser(boolean withValidation, String userRights, XWikiContext context) throws XWikiException;
+
+    void sendValidationEmail(String xwikiname, String password, String email, String validkey, String contentfield, XWikiContext context) throws XWikiException;
+
+    void sendMessage(String sender, String[] recipient, String message, XWikiContext context) throws XWikiException;
+
+    void sendMessage(String sender, String recipient, String message, XWikiContext context) throws XWikiException;
+
+    String generateValidationKey(int size);
+
+    int createUser(String xwikiname, Map map, String parent, String content, String userRights, XWikiContext context) throws XWikiException;
+
+    User getUser(XWikiContext context);
+
+    void prepareResources(XWikiContext context);
+
+    XWikiUser checkAuth(XWikiContext context) throws XWikiException;
+
+    boolean checkAccess(String action, XWikiDocument doc, XWikiContext context)
+            throws XWikiException;
+
+    String include(String topic, XWikiContext context, boolean isForm) throws XWikiException;
+
+    void deleteDocument(XWikiDocument doc, XWikiContext context) throws XWikiException;
+
+    String getDatabase();
+
+    void setDatabase(String database);
+
+    void gc();
+
+    long freeMemory();
+
+    long totalMemory();
+
+    long maxMemory();
+
+    String[] split(String str, String sep);
+
+    String printStrackTrace(Throwable e);
+
+    boolean copyDocument(String docname, String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
+
+    int copyWikiWeb(String web, String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
+
+    int copyWiki(String sourceWiki, String targetWiki, String language, XWikiContext context) throws XWikiException;
+
+    int createNewWiki(String wikiName, String wikiUrl, String wikiAdmin,
+                      String baseWikiName, String description, String language, boolean failOnExist, XWikiContext context) throws XWikiException;
+
+    String getEncoding();
+
+    URL getServerURL(String database, XWikiContext context) throws MalformedURLException;
+
+    String getURL(String fullname, String action, XWikiContext context) throws XWikiException;
+
+    String getURL(String fullname, String action, String querystring, XWikiContext context) throws XWikiException;
+
+    // Usefull date functions
+    Date getCurrentDate();
+
+    int getTimeDelta(long time);
+
+    Date getDate(long time);
+
+    boolean isMultiLingual(XWikiContext context);
+
+    boolean isVirtual();
+
+    boolean isExo();
+
+    int checkActive(XWikiContext context) throws XWikiException;
+
+    boolean prepareDocuments(XWikiRequest request, XWikiContext context, VelocityContext vcontext) throws XWikiException, IOException;
+
+    XWikiEngineContext getEngineContext();
+
+    void setEngineContext(XWikiEngineContext engine_context);
+
+    URLPatternMatcher getUrlPatternMatcher();
+
+    void setUrlPatternMatcher(URLPatternMatcher urlPatternMatcher);
+
+    void setAuthService(XWikiAuthService authService);
+
+    void setRightService(XWikiRightService rightService);
+
+    XWikiGroupService getGroupService(XWikiContext context) throws XWikiException;
+
+    void setGroupService(XWikiGroupService groupService);
+
+    XWikiAuthService getAuthService();
+
+    XWikiRightService getRightService();
+
+    Object getService(String className) throws XWikiException;
+
+    String getUserName(String user, XWikiContext context);
+
+    String getUserName(String user, String format, XWikiContext context);
+
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Class.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,93 +1,104 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author erwan
- * @author sdumitriu
- */
-
-
-package com.xpn.xwiki.api;
-
-import java.util.Iterator;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.objects.BaseObject;
-import com.xpn.xwiki.objects.classes.BaseClass;
-
-public class Class extends Collection {
-
-    public Class(BaseClass obj, XWikiContext context) {
-        super(obj, context);
-    }
-
-    protected BaseClass getBaseClass() {
-        return (BaseClass) getCollection();
-    }
-
-    /**
-     *
-     * @return an array with the properties of the class
-     */
-    public Element[] getProperties() {
-        java.util.Collection coll = getCollection().getFieldList();
-        if (coll==null)
-         return null;
-        PropertyClass[] properties = new PropertyClass[coll.size()];
-        int i=0;
-        for (Iterator it = coll.iterator(); it.hasNext();i++) {
-            properties[i] = new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) it.next(), context);
-        }
-        return properties;
-    }
-
-    /**
-     *
-     * @param name the name of the element
-     * @return the PropertyClass for the given name
-     * @see PropertyClass
-     * @see Element
-     */
-    public Element get(String name) {
-       return new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) getCollection().safeget(name), context);
-    }
-
-    /**
-     *
-     * @return the BaseClass (without the wrapping) if you have the programming right.
-     */
-    public BaseClass getXWikiClass() {
-        if (checkProgrammingRights())
-         return (BaseClass) getCollection();
-        else
-         return null;
-    }
-
-    /**
-     *
-     * @return a new object from this class
-     * @throws XWikiException
-     */
-    public Object newObject() throws XWikiException {
-        BaseObject obj = (BaseObject)getBaseClass().newObject(context);
-        return obj.newObjectApi(obj, context);
-    }
-
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author erwan
+ * @author sdumitriu
+ */
+
+
+package com.xpn.xwiki.api;
+
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.Comparator;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.XWikiException;
+import com.xpn.xwiki.objects.BaseObject;
+import com.xpn.xwiki.objects.classes.BaseClass;
+
+public class Class extends Collection {
+
+    public Class(BaseClass obj, XWikiContext context) {
+        super(obj, context);
+    }
+
+    protected BaseClass getBaseClass() {
+        return (BaseClass) getCollection();
+    }
+
+    /**
+     *
+     * @return an array with the properties of the class
+     */
+    public Element[] getProperties() {
+        java.util.Collection coll = getCollection().getFieldList();
+        if (coll==null)
+         return null;
+        PropertyClass[] properties = new PropertyClass[coll.size()];
+        int i=0;
+        for (Iterator it = coll.iterator(); it.hasNext();i++) {
+            properties[i] = new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) it.next(), context);
+        }
+        Arrays.sort(properties, new PropertyComparator());
+        return properties;
+    }
+
+    /**
+     *
+     * @param name the name of the element
+     * @return the PropertyClass for the given name
+     * @see PropertyClass
+     * @see Element
+     */
+    public Element get(String name) {
+       return new PropertyClass((com.xpn.xwiki.objects.classes.PropertyClass) getCollection().safeget(name), context);
+    }
+
+    /**
+     *
+     * @return the BaseClass (without the wrapping) if you have the programming right.
+     */
+    public BaseClass getXWikiClass() {
+        if (checkProgrammingRights())
+         return (BaseClass) getCollection();
+        else
+         return null;
+    }
+
+    /**
+     *
+     * @return a new object from this class
+     * @throws XWikiException
+     */
+    public Object newObject() throws XWikiException {
+        BaseObject obj = (BaseObject)getBaseClass().newObject(context);
+        return obj.newObjectApi(obj, context);
+    }
+}
+class PropertyComparator implements Comparator {
+	public int compare(java.lang.Object o1, java.lang.Object o2) {
+		PropertyClass po1 = (PropertyClass)o1;
+		PropertyClass po2 = (PropertyClass)o2;
+		if(po1.getNumber() < po2.getNumber()) return -1;
+		if(po1.getNumber() > po2.getNumber()) return 1;
+		return 0;
+	}
 }
\ No newline at end of file

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/Context.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,209 +1,217 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- */
-
-
-package com.xpn.xwiki.api;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.doc.XWikiDocument;
-import com.xpn.xwiki.web.XWikiRequest;
-import com.xpn.xwiki.web.XWikiResponse;
-import com.xpn.xwiki.web.XWikiURLFactory;
-
-
-public class Context extends Api {
-
-    public Context(XWikiContext context) {
-        super(context);
-    }
-
-    /**
-     *
-     * @return an object which contains the Request context
-     */
-    public XWikiRequest getRequest() {
-       return context.getRequest();
-    }
-
-    /**
-     *
-     * @return an object which contains the response object
-     */
-    public XWikiResponse getResponse() {
-       return context.getResponse();
-    }
-
-    public int getMode() {
-        return context.getMode();
-    }
-
-    /**
-     *
-     * @return the current database name
-     */
-    public String getDatabase() {
-        return context.getDatabase();
-    }
-
-    /**
-     *
-     * @return the original database
-     */
-    public String getOriginalDatabase() {
-        return context.getOriginalDatabase();
-    }
-
-    /**
-     * set the database if you have the programming right
-     * @param database the data name
-     */
-    public void setDatabase(String database) {
-        if (checkProgrammingRights())
-          context.setDatabase(database);
-    }
-
-    /**
-     *
-     * @return the url Factory
-     */
-    public XWikiURLFactory getURLFactory() {
-        return context.getURLFactory();
-    }
-
-    /**
-     *
-     * @return true if the server is in virtual mode (ie host more than one wiki)
-     */
-    public boolean isVirtual() {
-        return context.isVirtual();
-    }
-
-    /**
-     *
-     * @return the requested action
-     */
-    public String getAction() {
-         return context.getAction();
-    }
-
-    /**
-     *
-     * @return the language of the current user
-     */
-    public String getLanguage() {
-         return context.getLanguage();
-    }
-
-    /**
-     *
-     * @return the XWiki object if you have the programming right
-     */
-    public com.xpn.xwiki.XWiki getXWiki() {
-        if (checkProgrammingRights())
-         return context.getWiki();
-        else
-         return null;
-    }
-
-    /**
-     *
-     * @return the current requested document
-     */
-    public XWikiDocument getDoc() {
-        if (checkProgrammingRights())
-         return context.getDoc();
-        else
-         return null;
-    }
-
-    /**
-     *
-     * @return the current user which made the request
-     */
-    public String getUser() {
-         return context.getUser();
-    }
-
-    /**
-     *
-     * @return the local username of the current user which made the request
-     */
-    public String getLocalUser() {
-        return context.getLocalUser();
-    }
-
-    /**
-     * set the document if you have the programming right
-     * @param doc
-     */
-    public void setDoc(XWikiDocument doc) {
-        if (checkProgrammingRights())
-          context.setDoc(doc);
-    }
-
-    /**
-     *
-     * @return the unwrapped version of the context if you have the programming right
-     */
-    public XWikiContext getContext() {
-        if (checkProgrammingRights())
-         return context;
-        else
-         return null;
-    }
-
-    protected XWikiContext getProtectedContext() {
-         return context;
-    }
-
-    public java.lang.Object get(String key) {
-        if (checkProgrammingRights())
-            return context.get(key);
-        else
-            return null;
-    }
-
-    public void put(String key, Object value) {
-        if (checkProgrammingRights())
-            context.put(key, value);
-    }
-
-    public void setFinished(boolean finished) {
-        context.setFinished(finished);
-    }
-
-    /**
-     *
-     * @return the cache duration
-     */
-    public int getCacheDuration() {
-        return context.getCacheDuration();
-    }
-
-    /**
-     *
-     * @param duration in second
-     */
-    public void setCacheDuration(int duration) {
-        context.setCacheDuration(duration);
-    }
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ */
+
+
+package com.xpn.xwiki.api;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.doc.XWikiDocument;
+import com.xpn.xwiki.web.XWikiRequest;
+import com.xpn.xwiki.web.XWikiResponse;
+import com.xpn.xwiki.web.XWikiURLFactory;
+
+
+public class Context extends Api {
+
+    public Context(XWikiContext context) {
+        super(context);
+    }
+
+    /**
+     *
+     * @return an object which contains the Request context
+     */
+    public XWikiRequest getRequest() {
+       return context.getRequest();
+    }
+
+    /**
+     *
+     * @return an object which contains the response object
+     */
+    public XWikiResponse getResponse() {
+       return context.getResponse();
+    }
+
+    public int getMode() {
+        return context.getMode();
+    }
+
+    /**
+     *
+     * @return the current database name
+     */
+    public String getDatabase() {
+        return context.getDatabase();
+    }
+
+    /**
+     *
+     * @return the original database
+     */
+    public String getOriginalDatabase() {
+        return context.getOriginalDatabase();
+    }
+
+    /**
+     * set the database if you have the programming right
+     * @param database the data name
+     */
+    public void setDatabase(String database) {
+        if (checkProgrammingRights())
+          context.setDatabase(database);
+    }
+
+    /**
+     *
+     * @return the url Factory
+     */
+    public XWikiURLFactory getURLFactory() {
+        return context.getURLFactory();
+    }
+
+    /**
+     *
+     * @return true if the server is in virtual mode (ie host more than one wiki)
+     */
+    public boolean isVirtual() {
+        return context.isVirtual();
+    }
+
+    /**
+     *
+     * @return the requested action
+     */
+    public String getAction() {
+         return context.getAction();
+    }
+
+    /**
+     *
+     * @return the language of the current user
+     */
+    public String getLanguage() {
+         return context.getLanguage();
+    }
+
+    /**
+     *
+     * @return the interface language preference of the current user
+     */
+    public String getInterfaceLanguage() {
+         return context.getInterfaceLanguage();
+    }
+
+    /**
+     *
+     * @return the XWiki object if you have the programming right
+     */
+    public com.xpn.xwiki.XWiki getXWiki() {
+        if (checkProgrammingRights())
+         return context.getWiki();
+        else
+         return null;
+    }
+
+    /**
+     *
+     * @return the current requested document
+     */
+    public XWikiDocument getDoc() {
+        if (checkProgrammingRights())
+         return context.getDoc();
+        else
+         return null;
+    }
+
+    /**
+     *
+     * @return the current user which made the request
+     */
+    public String getUser() {
+         return context.getUser();
+    }
+
+    /**
+     *
+     * @return the local username of the current user which made the request
+     */
+    public String getLocalUser() {
+        return context.getLocalUser();
+    }
+
+    /**
+     * set the document if you have the programming right
+     * @param doc
+     */
+    public void setDoc(XWikiDocument doc) {
+        if (checkProgrammingRights())
+          context.setDoc(doc);
+    }
+
+    /**
+     *
+     * @return the unwrapped version of the context if you have the programming right
+     */
+    public XWikiContext getContext() {
+        if (checkProgrammingRights())
+         return context;
+        else
+         return null;
+    }
+
+    protected XWikiContext getProtectedContext() {
+         return context;
+    }
+
+    public java.lang.Object get(String key) {
+        if (checkProgrammingRights())
+            return context.get(key);
+        else
+            return null;
+    }
+
+    public void put(String key, Object value) {
+        if (checkProgrammingRights())
+            context.put(key, value);
+    }
+
+    public void setFinished(boolean finished) {
+        context.setFinished(finished);
+    }
+
+    /**
+     *
+     * @return the cache duration
+     */
+    public int getCacheDuration() {
+        return context.getCacheDuration();
+    }
+
+    /**
+     *
+     * @param duration in second
+     */
+    public void setCacheDuration(int duration) {
+        context.setCacheDuration(duration);
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/api/XWiki.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -394,6 +394,14 @@
         return xwiki.getLanguagePreference(context);
     }
 
+    public String getDocLanguagePreference() {
+        return xwiki.getDocLanguagePreference(context);
+    }
+
+    public String getInterfaceLanguagePreference() {
+        return xwiki.getInterfaceLanguagePreference(context);
+    }
+
     public boolean isVirtual() {
         return xwiki.isVirtual();
     }
@@ -998,7 +1006,7 @@
 
     public Object parseGroovyFromString(String script) throws XWikiException {
         if (checkProgrammingRights())
-          return xwiki.parseGroovyFromString(script, context);
+          return (Object)xwiki.parseGroovyFromString(script, context);
         else
           return null;
     }

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/BooleanClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,145 +1,187 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author sdumitriu
- */
-
-package com.xpn.xwiki.objects.classes;
-
-import org.apache.ecs.xhtml.option;
-import org.apache.ecs.xhtml.select;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.IntegerProperty;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-import com.xpn.xwiki.web.XWikiMessageTool;
-
-public class BooleanClass extends PropertyClass {
-
-    public BooleanClass(PropertyMetaClass wclass) {
-        super("boolean", "Boolean", wclass);
-    }
-
-    public BooleanClass() {
-        this(null);
-    }
-
-    public String getDisplayType() {
-        String dtype = getStringValue("displayType");
-        if ((dtype==null)||(dtype.equals(""))) {
-            return "yesno";
-        }
-        return dtype;
-    }
-
-    public void setDefaultValue(int dvalue) {
-        setIntValue("defaultValue", dvalue);
-    }
-
-    public int getDefaultValue() {
-        return getIntValue("defaultValue", -1);
-    }
-
-    public void setDisplayType(String type) {
-        setStringValue("displayType", type);
-    }
-
-
-    public BaseProperty fromString(String value) {
-        BaseProperty property = newProperty();
-        Number nvalue = null;
-        if ((value!=null)&&(!value.equals("")))
-                nvalue = new Integer(value);
-        property.setValue(nvalue);
-        return property;
-    }
-
-    public BaseProperty newProperty() {
-        BaseProperty property = new IntegerProperty();
-        property.setName(getName());
-        return property;
-    }
-
-    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        IntegerProperty prop = (IntegerProperty) object.safeget(name);
-        if (prop==null)
-            return;
-
-        Integer iValue = (Integer)prop.getValue();
-        if (iValue!=null) {
-            int value = iValue.intValue();
-            buffer.append(getDisplayValue(context, value));
-        }
-    }
-
-
-    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        select select = new select(prefix + name, 1);
-        String String0 = getDisplayValue(context, 0);
-        String String1 = getDisplayValue(context, 1);
-
-        option[] options = { new option("---", "" ), new option(String1, "1" ), new option(String0, "0")};
-        options[0].addElement("---");
-        options[1].addElement(String1);
-        options[2].addElement(String0);
-
-        try {
-        IntegerProperty prop = (IntegerProperty) object.safeget(name);
-        if (prop!=null) {
-            Integer ivalue = (Integer)prop.getValue();
-            if (ivalue!=null) {
-                int value = ivalue.intValue();
-                if (value==1)
-                    options[1].setSelected(true);
-                else if (value==0)
-                    options[2].setSelected(true);
-            }  else {
-                int value = getDefaultValue();
-                if (value==1)
-                    options[1].setSelected(true);
-                else if (value==0)
-                    options[2].setSelected(true);
-            }
-        }} catch (Exception e) {
-            // This should not happen
-            e.printStackTrace();
-        }
-        select.addElement(options);
-        buffer.append(select.toString());
-    }
-
-
-    private String getDisplayValue(XWikiContext context, int value) {
-        try {
-            XWikiMessageTool msg = (XWikiMessageTool) context.get("msg");
-            String strname = getDisplayType() + "_" + value;
-            String result = msg.get(strname);
-            if (result.equals(strname))
-             return "" + value;
-            else
-             return result;
-        } catch (Exception e) {
-            return "" + value;
-        }
-    }
-
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author sdumitriu
+ */
+
+package com.xpn.xwiki.objects.classes;
+
+import org.apache.ecs.xhtml.option;
+import org.apache.ecs.xhtml.select;
+import org.apache.ecs.xhtml.input;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.IntegerProperty;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+import com.xpn.xwiki.web.XWikiMessageTool;
+
+public class BooleanClass extends PropertyClass {
+
+    public BooleanClass(PropertyMetaClass wclass) {
+        super("boolean", "Boolean", wclass);
+    }
+
+    public BooleanClass() {
+        this(null);
+    }
+
+    public String getDisplayType() {
+        String dtype = getStringValue("displayType");
+        if ((dtype==null)||(dtype.equals(""))) {
+            return "yesno";
+        }
+        return dtype;
+    }
+
+    public void setDefaultValue(int dvalue) {
+        setIntValue("defaultValue", dvalue);
+    }
+
+    public int getDefaultValue() {
+        return getIntValue("defaultValue", -1);
+    }
+
+    public void setDisplayType(String type) {
+        setStringValue("displayType", type);
+    }
+
+
+    public BaseProperty fromString(String value) {
+        BaseProperty property = newProperty();
+        Number nvalue = null;
+        if ((value!=null)&&(!value.equals("")))
+                nvalue = new Integer(value);
+        property.setValue(nvalue);
+        return property;
+    }
+
+    public BaseProperty newProperty() {
+        BaseProperty property = new IntegerProperty();
+        property.setName(getName());
+        return property;
+    }
+
+    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        IntegerProperty prop = (IntegerProperty) object.safeget(name);
+        if (prop==null)
+            return;
+
+        Integer iValue = (Integer)prop.getValue();
+        if (iValue!=null) {
+            int value = iValue.intValue();
+            buffer.append(getDisplayValue(context, value));
+        }
+    }
+
+
+    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+    	if(getDisplayType().equals("checkbox")){
+    		displayCheckboxEdit(buffer, name, prefix, object, context);
+    	}
+    	else {
+    		displaySelectEdit(buffer, name, prefix, object, context);
+    	}
+    }
+    public void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        select select = new select(prefix + name, 1);
+        String String0 = getDisplayValue(context, 0);
+        String String1 = getDisplayValue(context, 1);
+
+        option[] options = { new option("---", "" ), new option(String1, "1" ), new option(String0, "0")};
+        options[0].addElement("---");
+        options[1].addElement(String1);
+        options[2].addElement(String0);
+
+        try {
+        IntegerProperty prop = (IntegerProperty) object.safeget(name);
+        if (prop!=null) {
+            Integer ivalue = (Integer)prop.getValue();
+            if (ivalue!=null) {
+                int value = ivalue.intValue();
+                if (value==1)
+                    options[1].setSelected(true);
+                else if (value==0)
+                    options[2].setSelected(true);
+            }  else {
+                int value = getDefaultValue();
+                if (value==1)
+                    options[1].setSelected(true);
+                else if (value==0)
+                    options[2].setSelected(true);
+            }
+	        }
+        } catch (Exception e) {
+            // This should not happen
+            e.printStackTrace();
+        }
+        select.addElement(options);
+        buffer.append(select.toString());
+    }
+
+    public void displayCheckboxEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        org.apache.ecs.xhtml.input check = new input(input.checkbox, prefix + name, 1);
+        org.apache.ecs.xhtml.input checkNo = new input(input.hidden, prefix + name, 0);
+
+        try {
+        IntegerProperty prop = (IntegerProperty) object.safeget(name);
+        if (prop!=null) {
+            Integer ivalue = (Integer)prop.getValue();
+            if (ivalue!=null) {
+                int value = ivalue.intValue();
+                if (value==1)
+                    check.setChecked(true);
+                else if (value==0)
+                	check.setChecked(false);
+            }
+            else {
+                int value = getDefaultValue();
+                if (value==1)
+                    check.setChecked(true);
+                else
+                    check.setChecked(false);
+            }
+        }} catch (Exception e) {
+            // This should not happen
+            e.printStackTrace();
+        }
+        buffer.append(check.toString());
+        buffer.append(checkNo.toString());
+    }
+
+
+    private String getDisplayValue(XWikiContext context, int value) {
+        try {
+            XWikiMessageTool msg = (XWikiMessageTool) context.get("msg");
+            String strname = getDisplayType() + "_" + value;
+            String result = msg.get(strname);
+            if (result.equals(strname)){
+             return "" + value;
+            }
+            else{
+             return result;
+            }
+        } catch (Exception e) {
+            return "" + value;
+        }
+    }
+
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/DateClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -20,127 +20,128 @@
  * @author ludovic
  * @author sdumitriu
  */
-
-package com.xpn.xwiki.objects.classes;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import org.apache.ecs.xhtml.input;
-import org.dom4j.Element;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.DateProperty;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-
-public class DateClass  extends PropertyClass {
-
-    public DateClass(PropertyMetaClass wclass) {
-        super("date", "Date", wclass);
-        setSize(20);
-        setDateFormat("dd/MM/yyyy HH:mm:ss");
-        setEmptyIsToday(1);
-    }
-
-    public DateClass() {
-        this(null);
-    }
-
-    public int getSize() {
-        return getIntValue("size");
-    }
-
-    public void setSize(int size) {
-        setIntValue("size", size);
-    }
-
-    public int getEmptyIsToday() {
-        return getIntValue("emptyIsToday");
-    }
-
-    public void setEmptyIsToday(int emptyIsToday) {
-        setIntValue("emptyIsToday", emptyIsToday);
-    }
-
-    public String getDateFormat() {
-        return getStringValue("dateFormat");
-    }
-
-    public void setDateFormat(String dformat) {
-        setStringValue("dateFormat", dformat);
-    }
-
-    public BaseProperty fromString(String value) {
-        BaseProperty property = newProperty();
-
-        if ((value==null)||(value.equals(""))) {
-            property.setValue(new Date());
-            return property;
-        }
-
-        try {
-            SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat());
-            property.setValue(sdf.parse(value));
-        } catch (ParseException e) {
-            return null;
-        }
-        return property;
-    }
-
-    public BaseProperty newProperty() {
-        BaseProperty property = new DateProperty();
-        property.setName(getName());
-        return property;
-    }
-
-    public String toFormString(BaseProperty property) {
-        SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat());
-        return sdf.format(property.getValue());
-    }
-
-    public BaseProperty newPropertyfromXML(Element ppcel) {
-        String value = ppcel.getText();
-        BaseProperty property = newProperty();
-
-        if ((value==null)||(value.equals(""))) {
-            property.setValue(new Date());
-            return property;
-        }
-
-        try {
-            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
-            property.setValue(sdf.parse(value));
-        } catch (ParseException e) {
-            try {
-                e.printStackTrace();
-                SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.US);
-                property.setValue(sdf.parse(value));
-            } catch (ParseException e2) {
-                e2.printStackTrace();
-                property.setValue(new Date());
-            }
-        }
-        return property;
-    }
-
-    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        buffer.append(toFormString(prop));
-    }
-
-    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        input input = new input();
-
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        if (prop!=null) input.setValue(toFormString(prop));
-
-        input.setType("text");
-        input.setName(prefix + name);
-        input.setSize(getSize());
-        buffer.append(input.toString());
-    }
-}
+
+package com.xpn.xwiki.objects.classes;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.ecs.xhtml.input;
+import org.dom4j.Element;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.DateProperty;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+
+public class DateClass  extends PropertyClass {
+
+    public DateClass(PropertyMetaClass wclass) {
+        super("date", "Date", wclass);
+        setSize(20);
+        setDateFormat("dd/MM/yyyy HH:mm:ss");
+        setEmptyIsToday(1);
+    }
+
+    public DateClass() {
+        this(null);
+    }
+
+    public int getSize() {
+        return getIntValue("size");
+    }
+
+    public void setSize(int size) {
+        setIntValue("size", size);
+    }
+
+    public int getEmptyIsToday() {
+        return getIntValue("emptyIsToday");
+    }
+
+    public void setEmptyIsToday(int emptyIsToday) {
+        setIntValue("emptyIsToday", emptyIsToday);
+    }
+
+    public String getDateFormat() {
+        return getStringValue("dateFormat");
+    }
+
+    public void setDateFormat(String dformat) {
+        setStringValue("dateFormat", dformat);
+    }
+
+    public BaseProperty fromString(String value) {
+        BaseProperty property = newProperty();
+
+        if ((value==null)||(value.equals(""))) {
+            property.setValue(new Date());
+            return property;
+        }
+
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat());
+            property.setValue(sdf.parse(value));
+        } catch (ParseException e) {
+            return null;
+        }
+        return property;
+    }
+
+    public BaseProperty newProperty() {
+        BaseProperty property = new DateProperty();
+        property.setName(getName());
+        return property;
+    }
+
+    public String toFormString(BaseProperty property) {
+        SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat());
+        return sdf.format(property.getValue());
+    }
+
+    public BaseProperty newPropertyfromXML(Element ppcel) {
+        String value = ppcel.getText();
+        BaseProperty property = newProperty();
+
+        if ((value==null)||(value.equals(""))) {
+            property.setValue(new Date());
+            return property;
+        }
+
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
+            property.setValue(sdf.parse(value));
+        } catch (ParseException e) {
+            try {
+                e.printStackTrace();
+                SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.US);
+                property.setValue(sdf.parse(value));
+            } catch (ParseException e2) {
+                e2.printStackTrace();
+                property.setValue(new Date());
+            }
+        }
+        return property;
+    }
+
+    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        BaseProperty prop = (BaseProperty) object.safeget(name);
+        buffer.append(toFormString(prop));
+    }
+
+    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        input input = new input();
+
+        BaseProperty prop = (BaseProperty) object.safeget(name);
+        if (prop!=null) input.setValue(toFormString(prop));
+
+        input.setType("text");
+        input.setName(prefix + name);
+        input.setID(prefix + name);
+        input.setSize(getSize());
+        buffer.append(input.toString());
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/GroupsClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -80,7 +80,7 @@
         if (value == null)
             return list;
 
-        String val = StringUtils.replace(value, "\\,", "%SEP%");
+        value = StringUtils.replace(value, "\\,", "%SEP%");
         String[] result = StringUtils.split(value, ", ");
         for (int i = 0; i < result.length; i++)
             list.add(StringUtils.replace(result[i], "%SEP%", ","));
@@ -135,6 +135,7 @@
          if (!isUsesList()) {
             input in = new input();
             in.setName(prefix + "newgroup");
+            in.setID(prefix + "newgroup");
             in.setSize(15);
             buffer.append("<br />");
             buffer.append(in.toString());

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/LevelsClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -116,6 +116,7 @@
         input in = new input();
         in.setType("hidden");
         in.setName(prefix + name);
+        in.setID(prefix + name);
         buffer.append(in.toString());
     }
 }

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/ListClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,247 +1,285 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author erwan
- * @author sdumitriu
- */
-
-package com.xpn.xwiki.objects.classes;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Arrays;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.ecs.xhtml.input;
-import org.apache.ecs.xhtml.option;
-import org.apache.ecs.xhtml.select;
-import org.dom4j.Element;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.DBStringListProperty;
-import com.xpn.xwiki.objects.ListProperty;
-import com.xpn.xwiki.objects.StringListProperty;
-import com.xpn.xwiki.objects.StringProperty;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-
-public abstract class ListClass extends PropertyClass {
-
-    public ListClass(String name, String prettyname, PropertyMetaClass wclass) {
-        super(name, prettyname, wclass);
-        setRelationalStorage(false);
-        setDisplayType("select");
-        setMultiSelect(false);
-        setSize(1);
-    }
-
-
-    public ListClass(PropertyMetaClass wclass) {
-        this("list", "List", wclass);
-    }
-
-    public ListClass() {
-        this(null);
-    }
-
-    public String getDisplayType() {
-        return getStringValue("displayType");
-    }
-
-    public void setDisplayType(String type) {
-        setStringValue("displayType", type);
-    }
-
-
-
-    public int getSize() {
-        return getIntValue("size");
-    }
-
-    public void setSize(int size) {
-        setIntValue("size", size);
-    }
-
-    public boolean isMultiSelect() {
-        return (getIntValue("multiSelect")==1);
-    }
-
-    public void setMultiSelect(boolean multiSelect) {
-        setIntValue("multiSelect", multiSelect ? 1 : 0);
-    }
-
-    public boolean isRelationalStorage() {
-        return (getIntValue("relationalStorage")==1);
-    }
-
-    public void setRelationalStorage(boolean storage) {
-        setIntValue("relationalStorage", storage ? 1 : 0);
-    }
-
-    public static List getListFromString(String value) {
-        List list = new ArrayList();
-        if (value==null)
-            return list;
-
-        String val = StringUtils.replace(value, "\\|", "%PIPE%");
-        String[] result = StringUtils.split(value,"|");
-        for (int i=0;i<result.length;i++)
-            list.add(StringUtils.replace(result[i],"%PIPE%", "|"));
-        return list;
-    }
-
-    public BaseProperty newProperty() {
-        BaseProperty lprop;
-
-        if (isRelationalStorage()&&isMultiSelect())
-            lprop = new DBStringListProperty();
-        else if (isMultiSelect())
-            lprop = new StringListProperty();
-        else
-            lprop = new StringProperty();
-
-        if (isMultiSelect() && getDisplayType().equals("input")) {
-            ((ListProperty)lprop).setFormStringSeparator("|");
-        }
-
-
-        return lprop;
-    }
-
-    public BaseProperty fromString(String value) {
-        BaseProperty prop = newProperty();
-        if (isMultiSelect()) {
-          if (!getDisplayType().equals("input")) {
-            ((ListProperty)prop).setList(getListFromString(value));
-          } else {
-            ((ListProperty)prop).setList(Arrays.asList(StringUtils.split(value," ,|")));
-          }
-        } else
-            prop.setValue(value);
-        return prop;
-    }
-
-    public BaseProperty fromStringArray(String[] strings) {
-        if ((!isMultiSelect())||(strings.length==1))
-            return fromString(strings[0]);
-        else {
-            List list = new ArrayList();
-            for (int i=0;i<strings.length;i++)
-                list.add(strings[i]);
-            BaseProperty prop = newProperty();
-            ((ListProperty)prop).setList(list);
-            return prop;
-        }
-    }
-
-
-    public BaseProperty newPropertyfromXML(Element ppcel) {
-        if ((!isRelationalStorage())&&(!isMultiSelect()))
-            return super.newPropertyfromXML(ppcel);
-
-        List elist = ppcel.elements("value");
-        BaseProperty lprop = (BaseProperty)newProperty();
-
-
-        if (lprop instanceof ListProperty) {
-            List llist = ((ListProperty)lprop).getList();
-            for (int i=0;i<elist.size();i++) {
-                Element el = (Element) elist.get(i);
-                llist.add(el.getText());
-            }
-        }
-        else {
-            for (int i=0;i<elist.size();i++) {
-                Element el = (Element) elist.get(i);
-                ((StringProperty)lprop).setValue(el.getText());
-            }
-        }
-        return lprop;
-    }
-
-
-    public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        input input = new input();
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        if (prop!=null) input.setValue(prop.toFormString());
-
-        input.setType("hidden");
-        input.setName(prefix + name);
-        buffer.append(input.toString());
-    }
-
-    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        List selectlist;
-        BaseProperty prop =  (BaseProperty)object.safeget(name);
-        if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) {
-            selectlist = (List) prop.getValue();
-            buffer.append(StringUtils.join(selectlist.toArray(), " "));
-        } else {
-            buffer.append(prop.getValue().toString());
-        }
-    }
-
-    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        if (getDisplayType().equals("input")) {
-            input input = new input();
-            BaseProperty prop = (BaseProperty) object.safeget(name);
-            if (prop!=null) input.setValue(prop.toFormString());
-            input.setType("text");
-            input.setSize(60);
-            input.setName(prefix + name);
-            buffer.append(input.toString());
-        } else {
-            select select = new select(prefix + name, 1);
-            select.setMultiple(isMultiSelect());
-            select.setSize(getSize());
-
-            List list = getList(context);
-            List selectlist;
-
-            BaseProperty prop =  (BaseProperty)object.safeget(name);
-            if (prop==null) {
-                selectlist = new ArrayList();
-            } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) {
-                selectlist = (List) prop.getValue();
-            } else {
-                selectlist = new ArrayList();
-                selectlist.add(prop.getValue());
-            }
-
-            // Add options from Set
-            for (Iterator it=list.iterator();it.hasNext();) {
-                String value = it.next().toString();
-                option option = new option(value, value);
-                option.addElement(value);
-                if (selectlist.contains(value))
-                    option.setSelected(true);
-                select.addElement(option);
-            }
-
-            buffer.append(select.toString());
-        }
-    }
-
-    public abstract List getList(XWikiContext context);
-
-
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * @author ludovic
+ * @author erwan
+ * @author sdumitriu
+ */
+
+package com.xpn.xwiki.objects.classes;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Arrays;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.ecs.xhtml.input;
+import org.apache.ecs.xhtml.option;
+import org.apache.ecs.xhtml.select;
+import org.dom4j.Element;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.DBStringListProperty;
+import com.xpn.xwiki.objects.ListProperty;
+import com.xpn.xwiki.objects.StringListProperty;
+import com.xpn.xwiki.objects.StringProperty;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+
+public abstract class ListClass extends PropertyClass {
+
+    public ListClass(String name, String prettyname, PropertyMetaClass wclass) {
+        super(name, prettyname, wclass);
+        setRelationalStorage(false);
+        setDisplayType("select");
+        setMultiSelect(false);
+        setSize(1);
+    }
+
+
+    public ListClass(PropertyMetaClass wclass) {
+        this("list", "List", wclass);
+    }
+
+    public ListClass() {
+        this(null);
+    }
+
+    public String getDisplayType() {
+        return getStringValue("displayType");
+    }
+
+    public void setDisplayType(String type) {
+        setStringValue("displayType", type);
+    }
+
+
+
+    public int getSize() {
+        return getIntValue("size");
+    }
+
+    public void setSize(int size) {
+        setIntValue("size", size);
+    }
+
+    public boolean isMultiSelect() {
+        return (getIntValue("multiSelect")==1);
+    }
+
+    public void setMultiSelect(boolean multiSelect) {
+        setIntValue("multiSelect", multiSelect ? 1 : 0);
+    }
+
+    public boolean isRelationalStorage() {
+        return (getIntValue("relationalStorage")==1);
+    }
+
+    public void setRelationalStorage(boolean storage) {
+        setIntValue("relationalStorage", storage ? 1 : 0);
+    }
+
+    public static List getListFromString(String value) {
+        List list = new ArrayList();
+        if (value==null)
+            return list;
+
+        String val = StringUtils.replace(value, "\\|", "%PIPE%");
+        String[] result = StringUtils.split(value,"|");
+        for (int i=0;i<result.length;i++)
+            list.add(StringUtils.replace(result[i],"%PIPE%", "|"));
+        return list;
+    }
+
+    public BaseProperty newProperty() {
+        BaseProperty lprop;
+
+        if (isRelationalStorage()&&isMultiSelect())
+            lprop = new DBStringListProperty();
+        else if (isMultiSelect())
+            lprop = new StringListProperty();
+        else
+            lprop = new StringProperty();
+
+        if (isMultiSelect() && getDisplayType().equals("input")) {
+            ((ListProperty)lprop).setFormStringSeparator("|");
+        }
+
+
+        return lprop;
+    }
+
+    public BaseProperty fromString(String value) {
+        BaseProperty prop = newProperty();
+        if (isMultiSelect()) {
+          if (!getDisplayType().equals("input")) {
+            ((ListProperty)prop).setList(getListFromString(value));
+          } else {
+            ((ListProperty)prop).setList(Arrays.asList(StringUtils.split(value," ,|")));
+          }
+        } else
+            prop.setValue(value);
+        return prop;
+    }
+
+    public BaseProperty fromStringArray(String[] strings) {
+        if ((!isMultiSelect())||(strings.length==1))
+            return fromString(strings[0]);
+        else {
+            List list = new ArrayList();
+            for (int i=0;i<strings.length;i++)
+                list.add(strings[i]);
+            BaseProperty prop = newProperty();
+            ((ListProperty)prop).setList(list);
+            return prop;
+        }
+    }
+
+
+    public BaseProperty newPropertyfromXML(Element ppcel) {
+        if ((!isRelationalStorage())&&(!isMultiSelect()))
+            return super.newPropertyfromXML(ppcel);
+
+        List elist = ppcel.elements("value");
+        BaseProperty lprop = (BaseProperty)newProperty();
+
+
+        if (lprop instanceof ListProperty) {
+            List llist = ((ListProperty)lprop).getList();
+            for (int i=0;i<elist.size();i++) {
+                Element el = (Element) elist.get(i);
+                llist.add(el.getText());
+            }
+        }
+        else {
+            for (int i=0;i<elist.size();i++) {
+                Element el = (Element) elist.get(i);
+                ((StringProperty)lprop).setValue(el.getText());
+            }
+        }
+        return lprop;
+    }
+
+
+    public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        input input = new input();
+        BaseProperty prop = (BaseProperty) object.safeget(name);
+        if (prop!=null) input.setValue(prop.toFormString());
+
+        input.setType("hidden");
+        input.setName(prefix + name);
+        input.setID(prefix + name);
+        buffer.append(input.toString());
+    }
+
+    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        List selectlist;
+        BaseProperty prop =  (BaseProperty)object.safeget(name);
+        if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) {
+            selectlist = (List) prop.getValue();
+            buffer.append(StringUtils.join(selectlist.toArray(), " "));
+        } else {
+            buffer.append(prop.getValue().toString());
+        }
+    }
+
+    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        if (getDisplayType().equals("input")) {
+            input input = new input();
+            BaseProperty prop = (BaseProperty) object.safeget(name);
+            if (prop!=null) input.setValue(prop.toFormString());
+            input.setType("text");
+            input.setSize(60);
+            input.setName(prefix + name);
+            input.setID(prefix + name);
+            buffer.append(input.toString());
+        } else if (getDisplayType().equals("radio")) {
+        	displayRadioEdit(buffer, name, prefix, object, context);
+        }
+        else {
+        	displaySelectEdit(buffer, name, prefix, object, context);
+        }
+    }
+    
+    protected void displayRadioEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context){
+        List list = getList(context);
+        List selectlist;
+
+        BaseProperty prop =  (BaseProperty)object.safeget(name);
+        if (prop==null) {
+            selectlist = new ArrayList();
+        } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) {
+            selectlist = (List) prop.getValue();
+        } else {
+            selectlist = new ArrayList();
+            selectlist.add(prop.getValue());
+        }
+
+        // Add options from Set
+        for (Iterator it=list.iterator();it.hasNext();) {
+            String value = it.next().toString();
+            input radio = new input(input.radio, prefix + name, value);
+
+            if (selectlist.contains(value))
+                radio.setChecked(true);
+            radio.addElement(value);
+            buffer.append(radio.toString());
+            if(it.hasNext()){
+            	buffer.append("<br/>");
+            }
+        }
+    }
+
+    protected void displaySelectEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context){
+            select select = new select(prefix + name, 1);
+            select.setMultiple(isMultiSelect());
+            select.setSize(getSize());
+        select.setName(prefix + name);
+        select.setID(prefix + name);
+
+            List list = getList(context);
+            List selectlist;
+
+            BaseProperty prop =  (BaseProperty)object.safeget(name);
+            if (prop==null) {
+                selectlist = new ArrayList();
+            } else if ((prop instanceof ListProperty)||(prop instanceof DBStringListProperty)) {
+                selectlist = (List) prop.getValue();
+            } else {
+                selectlist = new ArrayList();
+                selectlist.add(prop.getValue());
+            }
+
+            // Add options from Set
+            for (Iterator it=list.iterator();it.hasNext();) {
+                String value = it.next().toString();
+                option option = new option(value, value);
+                option.addElement(value);
+                if (selectlist.contains(value))
+                    option.setSelected(true);
+                select.addElement(option);
+            }
+
+            buffer.append(select.toString());
+        }
+
+    public abstract List getList(XWikiContext context);
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/NumberClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -20,95 +20,96 @@
  * @author ludovic
  * @author sdumitriu
  */
-
-package com.xpn.xwiki.objects.classes;
-
-import org.apache.ecs.xhtml.input;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.DoubleProperty;
-import com.xpn.xwiki.objects.FloatProperty;
-import com.xpn.xwiki.objects.IntegerProperty;
-import com.xpn.xwiki.objects.LongProperty;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-
-public class NumberClass  extends PropertyClass {
-
-    public NumberClass(PropertyMetaClass wclass) {
-        super("number", "Number", wclass);
-        setSize(30);
-        setNumberType("long");
-    }
-
-    public NumberClass() {
-        this(null);
-    }
-
-    public int getSize() {
-        return getIntValue("size");
-    }
-
-    public void setSize(int size) {
-        setIntValue("size", size);
-    }
-
-    public String getNumberType() {
-        return getStringValue("numberType");
-    }
-
-    public void setNumberType(String ntype) {
-        setStringValue("numberType", ntype);
-    }
-
-    public BaseProperty newProperty() {
-        String ntype = getNumberType();
-        BaseProperty property;
-        if (ntype.equals("integer")) {
-            property = new IntegerProperty();
-        } else if (ntype.equals("float")) {
-            property = new FloatProperty();
-        } else if (ntype.equals("double")) {
-            property = new DoubleProperty();
-        } else {
-            property = new LongProperty();
-        }
-        property.setName(getName());
-        return property;
-    }
-
-
-    public BaseProperty fromString(String value) {
-        BaseProperty property = newProperty();
-        String ntype = getNumberType();
-        Number nvalue = null;
-        if (ntype.equals("integer")) {
-            if ((value!=null)&&(!value.equals("")))
-                nvalue = new Integer(value);
-        } else if (ntype.equals("float")) {
-            if ((value!=null)&&(!value.equals("")))
-                nvalue = new Float(value);
-        } else if (ntype.equals("double")) {
-            if ((value!=null)&&(!value.equals("")))
-                nvalue = new Double(value);
-        } else {
-            if ((value!=null)&&(!value.equals("")))
-                nvalue = new Long(value);
-        }
-        property.setValue(nvalue);
-        return property;
-    }
-
-    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        input input = new input();
-
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        if (prop!=null) input.setValue(prop.toFormString());
-
-        input.setType("text");
-        input.setName(prefix + name);
-        input.setSize(getSize());
-        buffer.append(input.toString());
-    }
-}
+
+package com.xpn.xwiki.objects.classes;
+
+import org.apache.ecs.xhtml.input;
+
+import com.xpn.xwiki.XWikiContext;
+import com.xpn.xwiki.objects.BaseCollection;
+import com.xpn.xwiki.objects.BaseProperty;
+import com.xpn.xwiki.objects.DoubleProperty;
+import com.xpn.xwiki.objects.FloatProperty;
+import com.xpn.xwiki.objects.IntegerProperty;
+import com.xpn.xwiki.objects.LongProperty;
+import com.xpn.xwiki.objects.meta.PropertyMetaClass;
+
+public class NumberClass  extends PropertyClass {
+
+    public NumberClass(PropertyMetaClass wclass) {
+        super("number", "Number", wclass);
+        setSize(30);
+        setNumberType("long");
+    }
+
+    public NumberClass() {
+        this(null);
+    }
+
+    public int getSize() {
+        return getIntValue("size");
+    }
+
+    public void setSize(int size) {
+        setIntValue("size", size);
+    }
+
+    public String getNumberType() {
+        return getStringValue("numberType");
+    }
+
+    public void setNumberType(String ntype) {
+        setStringValue("numberType", ntype);
+    }
+
+    public BaseProperty newProperty() {
+        String ntype = getNumberType();
+        BaseProperty property;
+        if (ntype.equals("integer")) {
+            property = new IntegerProperty();
+        } else if (ntype.equals("float")) {
+            property = new FloatProperty();
+        } else if (ntype.equals("double")) {
+            property = new DoubleProperty();
+        } else {
+            property = new LongProperty();
+        }
+        property.setName(getName());
+        return property;
+    }
+
+
+    public BaseProperty fromString(String value) {
+        BaseProperty property = newProperty();
+        String ntype = getNumberType();
+        Number nvalue = null;
+        if (ntype.equals("integer")) {
+            if ((value!=null)&&(!value.equals("")))
+                nvalue = new Integer(value);
+        } else if (ntype.equals("float")) {
+            if ((value!=null)&&(!value.equals("")))
+                nvalue = new Float(value);
+        } else if (ntype.equals("double")) {
+            if ((value!=null)&&(!value.equals("")))
+                nvalue = new Double(value);
+        } else {
+            if ((value!=null)&&(!value.equals("")))
+                nvalue = new Long(value);
+        }
+        property.setValue(nvalue);
+        return property;
+    }
+
+    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
+        input input = new input();
+
+        BaseProperty prop = (BaseProperty) object.safeget(name);
+        if (prop!=null) input.setValue(prop.toFormString());
+
+        input.setType("text");
+        input.setName(prefix + name);
+        input.setID(prefix + name);
+        input.setSize(getSize());
+        buffer.append(input.toString());
+    }
+}

Modified: xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java
===================================================================
--- xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java	2006-08-09 21:32:26 UTC (rev 1127)
+++ xwiki/trunk/src/main/java/com/xpn/xwiki/objects/classes/PropertyClass.java	2006-08-10 09:41:51 UTC (rev 1128)
@@ -1,308 +1,311 @@
-/*
- * Copyright 2006, XpertNet SARL, and individual contributors as indicated
- * by the contributors.txt.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *
- * @author ludovic
- * @author sdumitriu
- */
-
-package com.xpn.xwiki.objects.classes;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.ecs.xhtml.input;
-import org.dom4j.Element;
-import org.dom4j.dom.DOMElement;
-import org.hibernate.mapping.Property;
-
-import com.xpn.xwiki.XWikiContext;
-import com.xpn.xwiki.XWikiException;
-import com.xpn.xwiki.objects.BaseCollection;
-import com.xpn.xwiki.objects.BaseProperty;
-import com.xpn.xwiki.objects.PropertyInterface;
-import com.xpn.xwiki.objects.meta.MetaClass;
-import com.xpn.xwiki.objects.meta.PropertyMetaClass;
-
-public class PropertyClass extends BaseCollection implements PropertyClassInterface, PropertyInterface {
-    private BaseClass object;
-    private int id;
-    private PropertyMetaClass pMetaClass;
-
-    public PropertyClass() {
-    }
-
-    public PropertyClass(String name, String prettyname, PropertyMetaClass xWikiClass) {
-        super();
-        setName(name);
-        setPrettyName(prettyname);
-        setxWikiClass(xWikiClass);
-        setUnmodifiable(false);
-    }
-
-    public BaseClass getxWikiClass() {
-        if (pMetaClass==null) {
-        MetaClass metaClass = MetaClass.getMetaClass();
-        pMetaClass = (PropertyMetaClass)metaClass.get(getClassType());
-        }
-        return pMetaClass;
-    }
-
-    public void setxWikiClass(BaseClass xWikiClass) {
-        this.pMetaClass = (PropertyMetaClass) xWikiClass;
-    }
-
-    public BaseCollection getObject() {
-            return object;
-   }
-
-    public void setObject(BaseCollection object) {
-            this.object = (BaseClass)object;
-    }
-
-    public int getId() {
-        if (getObject()==null)
-            return id;
-        else
-            return getObject().getId();
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public void checkField(String name) throws XWikiException {
-        // Let's stop checking
-        /*if ((getxWikiClass(context).safeget(name)==null)&&
-            (getxWikiClass(context).safeget("meta" + name)==null)){
-            Object[] args = { name, getxWikiClass(context).getName() };
-            throw new XWikiException( XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_FIELD_DOES_NOT_EXIST,
-                    "Field {0} does not exist in class {1}", null, args);
-        }
-        */
-    }
-
-    public String toString(BaseProperty property) {
-        return property.toText();
-    }
-
-    public BaseProperty fromString(String value) {
-        return null;
-    }
-
-    public BaseProperty newPropertyfromXML(Element ppcel) {
-        String value = ppcel.getText();
-        return fromString(value);
-    }
-
-    public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-       input input = new input();
-       PropertyInterface prop = (PropertyInterface) object.safeget(name);
-       if (prop!=null) input.setValue(prop.toFormString());
-
-       input.setType("hidden");
-       input.setName(prefix + name);
-       buffer.append(input.toString());
-    }
-
-    public void displaySearch(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        input input = new input();
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        if (prop!=null) input.setValue(prop.toFormString());
-
-        input.setType("text");
-        input.setName(prefix + name);
-        buffer.append(input.toString());
-    }
-
-    public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        buffer.append(((BaseProperty)object.safeget(name)).toText());
-    }
-
-    public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
-        input input = new input();
-
-        BaseProperty prop = (BaseProperty) object.safeget(name);
-        if (prop!=null) input.setValue(prop.toFormString());
-
-        input.setType("text");
-        input.setName(prefix + name);
-        buffer.append(input.toString());
-    }
-
-    public String displayHidden(String name, String prefix, BaseCollection object, XWikiContext context) {
-      StringBuffer buffer = new StringBuffer();
-      displayHidden(buffer, name, prefix, object, context);
-      return buffer.toString();
-    }
-    public String displayHidden(String name, BaseCollection object, XWikiContext context) {
-      return displayHidden(name, "", object, context);
-    }
-
-    public String displaySearch(String name, String prefix, BaseCollection object, XWikiContext context) {
-      StringBuffer buffer = new StringBuffer();
-      displaySearch(buffer, name, prefix, object, context);
-      return buffer.toString();
-    }
-    public String displaySearch(String name, BaseCollection object, XWikiContext context) {
-      return displaySearch(name, "", object, context);
-    }
-
-    public String displayView(String name, String prefix, BaseCollection object, XWikiContext context) {
-      StringBuffer buffer = new StringBuffer();
-      displayView(buffer, name, prefix, object, context);
-      return buffer.toString();
-    }
-    public String displayView(String name, BaseCollection object, XWikiContext context) {
-      return displayView(name, "", object, context);
-    }
-
-    public String displayEdit(String name, String prefix, BaseCollection object, XWikiContext context) {
-      StringBuffer buffer = new StringBuffer();
-      displayEdit(buffer, name, prefix, object, context);
-      return buffer.toString();
-    }
-
-    public String displayEdit(String name, BaseCollection object, XWikiContext context) {
-      return displayEdit(name, "", object, context);
-    }
-
-
-    public BaseClass getxWikiClass(XWikiContext context) {
-        return getxWikiClass();
-    }
-
-    public String getClassName() {
-        BaseClass bclass = getxWikiClass();
-        return (bclass==null) ? "" : bclass.getName();
-    }
-
-    // In property classes we need to store this info in the HashMap for fields
-    // This way it is readable by the displayEdit/displayView functions..
-    public String getName() {
-        return getStringValue("name");
-    }
-
-    public void setName(String name) {
-      setStringValue("name", name);
-    }
-
-    public String getPrettyName() {
-        return getStringValue("prettyName");
-    }
-
-    public void setPrettyName(String prettyName) {
-        setStringValue("prettyName", prettyName);
-    }
-
-    public int getNumber() {
-        return getIntValue("number");
-    }
-
-    public void setNumber(int number) {
-      setIntValue("number", number);
-    }
-
-    public String getClassType() {
-        return getClass().getName();
-    }
-
-    public void setClassType(String type) {
-    }
-
-    public Object clone() {
-        PropertyClass pclass = (PropertyClass) super.clone();
-        pclass.setObject(getObject());
-        pclass.setClassType(getClassType());
-        return pclass;
-    }
-
-    public Element toXML(BaseClass bclass) {
-        return toXML();
-    }
-
-    public Element toXML() {
-         Element pel = new DOMElement(getName());
-         Iterator it = getFieldList().iterator();
-         while (it.hasNext()) {
-           BaseProperty bprop = (BaseProperty)it.next();
-           pel.add(bprop.toXML());
-         }
-        Element el = new DOMElement("classType");
-        el.addText(getClassType());
-        pel.add(el);
-        return pel;
-     }
-
-    public void fromXML(Element pcel) throws XWikiException {
-     List list = pcel.elements();
-     BaseClass bclass = getxWikiClass();
-
-     for (int i=0;i<list.size();i++) {
-        Element ppcel = (Element) list.get(i);
-        String name = ppcel.getName();
-        if (bclass==null) {
-            Object[] args = { getClass().getName() };
-            throw new XWikiException( XWikiException.MODULE_XWIKI_CLASSES, XWikiException.ERROR_XWIKI_CLASSES_PROPERTY_CLASS_IN_METACLASS,
-                    "Cannot find property class {0} in MetaClass object", null, args);
-        }
-        PropertyClass pclass = (PropertyClass) bclass.safeget(name);
-        if (pclass!=null) {
-         BaseProperty bprop = pclass.newPropertyfromXML(ppcel);
-         bprop.setObject(this);
-         safeput(name, bprop);
-        }
-     }
-    }
-
-    public String toFormString() {
-        return toString();
-    }
-
-    public void initLazyCollections() {
-    }
-
-    public boolean isUnmodifiable() {
-        return (getIntValue("unmodifiable")==1);
-    }
-
-    public void setUnmodifiable(boolean unmodifiable) {
-        if (unmodifiable)
-         setIntValue("unmodifiable", 1);
-        else
-         setIntValue("unmodifiable", 0);
-    }
-
-    public BaseProperty fromStringArray(String[] strings) {
-        return fromString(strings[0]);
-    }
-
-    public boolean isValidColumnTypes(Property hibprop) {
-        return true;
-    }
-
-    public BaseProperty fromValue(Object value) {
-        BaseProperty property= newProperty();
-        property.setValue(value);
-        return property;
-    }
-
-    public BaseProperty newProperty() {
-        return new BaseProperty();
-    }
-}
+/*
+ * Copyright 2006, XpertNet SARL, and individual contributors as indicated
+ * by the contributors.txt.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTI