Index: main/plugin-cms/sitemap.xmap
===================================================================
--- main/plugin-cms/sitemap.xmap	(revision 26836)
+++ main/plugin-cms/sitemap.xmap	(working copy)
@@ -39,6 +39,7 @@
             <map:generator name="common-metadataset" src="org.ametys.cms.contenttype.CommonMetadataSetNamesGenerator"/>
             <map:generator name="common-metadataset-from-contents" src="org.ametys.cms.contenttype.CommonMetadataSetNamesFromContentsGenerator"/>
             <map:generator name="common-metadata" src="org.ametys.cms.contenttype.CommonMetadataGenerator"/>
+            <map:generator name="common-typed-metadata" src="org.ametys.cms.contenttype.CommonTypedMetadataGenerator"/>
             <map:generator name="common-sortable-metadata" src="org.ametys.cms.contenttype.CommonSortableMetadataGenerator"/>
 
             <map:generator name="profile-rights" src="org.ametys.cms.rights.ProfileRightsGenerator"/>
@@ -359,6 +360,14 @@
                 <map:serialize type="xml"/>
             </map:match>
             
+            <map:match pattern="common-typed-metadata">
+                <map:generate type="common-typed-metadata"/>
+                <map:transform type="i18n" label="xml">
+                    <map:parameter name="locale" value="{locale:locale}"/>
+                </map:transform>
+                <map:serialize type="xml"/>
+            </map:match>
+            
             <map:match pattern="common-sortable-metadata">
                 <map:generate type="common-sortable-metadata"/>
                 <map:transform type="i18n" label="xml">
Index: main/plugin-cms/i18n/messages_en.xml
===================================================================
--- main/plugin-cms/i18n/messages_en.xml	(revision 26925)
+++ main/plugin-cms/i18n/messages_en.xml	(working copy)
@@ -1017,6 +1017,9 @@
     <message key="WIDGET_RICH_TEXT_HIERARCHY_ERROR">The title hierarchy is invalid.</message>
     <message key="WIDGET_RICH_TEXT_TOC_ERROR">Some text is present on the same line as a table of contents.</message>
     
+    <message key="WIDGET_SELECTTYPEDMETADATA_FILTER_NONE">None</message>
+   	<message key="WIDGET_SELECTTYPEDMETADATA_FILTER_LOAD_ERROR">An error occurred in the loading of the metadatas</message>
+    
     <message key="WIDGET_COMBOBOX_ALL_OPTIONS">- All -</message>
     
     <!-- +
Index: main/plugin-cms/i18n/messages_fr.xml
===================================================================
--- main/plugin-cms/i18n/messages_fr.xml	(revision 26925)
+++ main/plugin-cms/i18n/messages_fr.xml	(working copy)
@@ -1018,6 +1018,9 @@
     <message key="WIDGET_RICH_TEXT_HIERARCHY_ERROR">La hiérarchie des titres est incorrecte.</message>
     <message key="WIDGET_RICH_TEXT_TOC_ERROR">Du texte est présent sur la même ligne qu'une table des matières.</message>
     
+    <message key="WIDGET_SELECTTYPEDMETADATA_FILTER_NONE">Aucune</message>
+    <message key="WIDGET_SELECTTYPEDMETADATA_FILTER_LOAD_ERROR">Il y a eu une erreur dans le chargement des métadatas</message>
+    
     <message key="WIDGET_COMBOBOX_ALL_OPTIONS">- Tous -</message>
      
     <!-- +
Index: main/plugin-cms/resources/js/org/ametys/cms/widgets/SelectTypedMetadata.i18n.js
===================================================================
--- main/plugin-cms/resources/js/org/ametys/cms/widgets/SelectTypedMetadata.i18n.js	(revision 0)
+++ main/plugin-cms/resources/js/org/ametys/cms/widgets/SelectTypedMetadata.i18n.js	(revision 0)
@@ -0,0 +1,140 @@
+/*
+ *  Copyright 2010 Anyware Services
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+Ext.namespace('org.ametys.cms.widgets');
+
+//Register widget
+org.ametys.utils.Widgets.registerWidget ('string', 'typed-metadata', 'org.ametys.cms.widgets.SelectTypedMetadata');
+
+org.ametys.cms.widgets._metadataSetName = "index";
+
+org.ametys.cms.widgets.SelectTypedMetadata = function(config, enumeratedValues) 
+{
+	this.store = new Ext.data.SimpleStore({
+		idIndex: 0,
+        fields: [
+           {name: 'value'},
+           {name: 'label'}        
+        ]
+	});
+	
+	this._metadataSetName = org.ametys.cms.widgets._metadataSetName;
+
+	org.ametys.cms.widgets.SelectTypedMetadata.superclass.constructor.call(this, config, enumeratedValues);
+};
+
+Ext.extend(org.ametys.cms.widgets.SelectTypedMetadata, org.ametys.form.ComboField, {
+	height: 107,
+	width: 100,
+	minChars: 0, 
+	triggerAction: 'all',
+	forceSelection: true,
+	selectOnFocus: true,
+	valueField: 'value',
+	displayField: 'label',
+	mode: 'local'
+});
+
+/**
+ * Force expand on focus
+ */
+org.ametys.cms.widgets.SelectTypedMetadata.prototype._onFocus = function ()
+{
+	if(this.triggerAction == 'all') 
+	{
+        this.doQuery(this.allQuery, true);
+    } 
+	else 
+	{
+        this.doQuery(this.getRawValue());
+    }
+}
+
+org.ametys.cms.widgets.SelectTypedMetadata.prototype.onSelectContentTypes = function (cTypes)
+{
+	this._cTypes = cTypes;
+	this._metadataSetName = org.ametys.cms.widgets._metadataSetName;
+	this._loadSkins();
+}
+
+org.ametys.cms.widgets.SelectTypedMetadata.prototype.onRender = function(ct, position)
+{
+	org.ametys.cms.widgets.SelectTypedMetadata.superclass.onRender.call(this, ct, position);
+	this._loadSkins();
+
+	this.addListener('focus', this._onFocus, this);
+	
+	org.ametys.cms.widgets.ContentTypesWidget.registerListener (this);
+}
+
+org.ametys.cms.widgets.SelectTypedMetadata.prototype._loadSkins = function ()
+{
+	params = {};
+	params.ids = this._cTypes;
+	params.metadataSetName = this._metadataSetName;
+
+	var firstLoad = false;
+	if (typeof this._cTypes == 'undefined')
+	{
+		firstLoad = true;
+	}
+	
+	var serverMessage = new org.ametys.servercomm.ServerMessage('cms', '/common-typed-metadata', params, org.ametys.servercomm.ServerComm.PRIORITY_MAJOR, this._loadSkinsCb, this, [firstLoad]);
+	org.ametys.servercomm.ServerComm.getInstance().send(serverMessage);
+}
+
+org.ametys.cms.widgets.SelectTypedMetadata.prototype._loadSkinsCb = function (response, args)
+{
+	if (org.ametys.servercomm.ServerComm.handleBadResponse("<i18n:text i18n:key="WIDGET_SELECTTYPEDMETADATA_FILTER_LOAD_ERROR"/>", response, "org.ametys.web.administration.SkinsWidget"))
+	{
+		return;
+	}
+	
+	var store = this.getStore();
+	store.removeAll();	
+	
+	var metadataTab = [];
+	
+	var metadatas = response.selectNodes("metadata/metadata");
+	
+	var noData = {
+            value: "",
+            label: "<i18n:text i18n:key="WIDGET_SELECTTYPEDMETADATA_FILTER_NONE"/>"
+    };
+	metadataTab.push(new this.store.recordType(noData));
+
+	for (var i=0; i &lt; metadatas.length; i++)
+	{
+		var data = {
+	            value: metadatas[i].getAttribute('name'),
+	            label: metadatas[i].selectSingleNode('label')[org.ametys.servercomm.ServerComm.xmlTextContent]
+	    };
+
+		metadataTab.push(new this.store.recordType(data));
+	}
+	
+	this.store.add(metadataTab);
+	
+	// We set the value after the loading of the store
+	this.setValue(this.getValue());
+	
+	// Check if it's the first time we load (cType is not defined before first load)
+	var firstLoad = args[0];
+	if (!firstLoad &amp;&amp; this.store.find('value',this.getValue()) == -1 )
+	{
+		this.setValue("");
+	}
+}
\ No newline at end of file
Index: main/plugin-cms/src/org/ametys/cms/contenttype/CommonTypedMetadataGenerator.java
===================================================================
--- main/plugin-cms/src/org/ametys/cms/contenttype/CommonTypedMetadataGenerator.java	(revision 0)
+++ main/plugin-cms/src/org/ametys/cms/contenttype/CommonTypedMetadataGenerator.java	(revision 0)
@@ -0,0 +1,210 @@
+/*
+ *  Copyright 2010 Anyware Services
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.ametys.cms.contenttype;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.cocoon.xml.AttributesImpl;
+import org.apache.cocoon.xml.XMLUtils;
+import org.apache.commons.lang.StringUtils;
+import org.xml.sax.SAXException;
+
+import org.ametys.cms.lucene.FieldNames;
+import org.ametys.cms.repository.DefaultContent;
+import org.ametys.runtime.util.I18nizableText;
+
+/**
+ * SAX common metadata given content types and metadata-set
+ */
+public class CommonTypedMetadataGenerator extends ServiceableGenerator
+{
+    /** The content type extension point */
+    protected ContentTypeExtensionPoint _cTypeEP;
+    
+    @Override
+    public void service(ServiceManager smanager) throws ServiceException
+    {
+        super.service(smanager);
+        _cTypeEP = (ContentTypeExtensionPoint) smanager.lookup(ContentTypeExtensionPoint.ROLE);
+    }
+    
+    @Override
+    public void generate() throws IOException, SAXException, ProcessingException
+    {
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        
+        String paramIds = request.getParameter("ids");
+        String metadataSetName = request.getParameter("metadataSetName");
+
+        Boolean hasDocument = false;
+        
+        String[] ids = null;
+        if (!StringUtils.isEmpty(paramIds))
+        {
+            ids = paramIds.split(",");
+        }
+        else
+        {
+            ids =  getAllAvailablesContentTypes(request, true);
+            hasDocument = true;
+        }
+        
+        Map<String, I18nizableText> allMetadata = new HashMap<String, I18nizableText>();
+        Map<String, MetadataType> commonMetadataNames = null;
+        
+        if (StringUtils.isNotEmpty(metadataSetName))
+        {
+            for (String id : ids)
+            {
+                ContentType cType = _cTypeEP.getExtension(id);
+                
+                // Documents are not a content-type
+                if (!id.equals("resource"))
+                {
+                    MetadataSet metadataSet = cType.getMetadataSetForView(metadataSetName);
+                    
+                    // Test if the metadataSetName view is defined
+                    if (metadataSet != null)
+                    {
+                        Map<String, MetadataType> metadataSetNames = new HashMap<String, MetadataType>();
+                        for (MetadataSetElement metadataSetElement : metadataSet.getElements())
+                        {
+                            if (metadataSetElement instanceof MetadataDefinitionReference)
+                            {
+                                String metadataName = ((MetadataDefinitionReference) metadataSetElement).getMetadataName();
+                                MetadataDefinition metaDef = cType.getMetadataDefinition(metadataName);
+                                
+                                if (metaDef.getType().equals(MetadataType.DATE))
+                                {
+                                    metadataSetNames.put(metadataName, metaDef.getType());
+                                    
+                                    I18nizableText label = metaDef.getLabel();
+                                    allMetadata.put(metadataName, label);
+                                }
+                            }
+                        }
+                        
+                        if (commonMetadataNames == null)
+                        {
+                            commonMetadataNames = metadataSetNames;
+                        }
+                        else
+                        {
+                            // Maps intersection
+                            commonMetadataNames.keySet().retainAll(metadataSetNames.keySet());
+                        }
+                    }
+                }
+                else
+                {
+                    hasDocument = true;
+                }
+            }
+        }
+        
+        saxCommonMetadata (commonMetadataNames, allMetadata, hasDocument);
+    }
+    
+    /**
+     * SAX the common metadata
+     * @param commonMetadataNames the name of metadata to SAX
+     * @param allMetadata the all metadata
+     * @throws SAXException if an error occurred while saxing
+     */
+    protected void saxCommonMetadata (Map<String, MetadataType> commonMetadataNames, Map<String, I18nizableText> allMetadata, Boolean hasDocument) throws SAXException
+    {
+        contentHandler.startDocument();
+        XMLUtils.startElement(contentHandler, "metadata");
+        if (!hasDocument)
+        {
+            Map<String, I18nizableText> commonMetadata = new HashMap<String, I18nizableText>();
+            if (allMetadata != null && commonMetadataNames != null)
+            {
+                for (String metadataName : allMetadata.keySet())
+                {
+                    if (commonMetadataNames.containsKey(metadataName))
+                    {
+                        commonMetadata.put(metadataName, allMetadata.get(metadataName));
+                    }
+                }
+                
+                for (String name : commonMetadata.keySet())
+                {
+                    AttributesImpl attrs = new AttributesImpl();
+                    attrs.addCDATAAttribute("name", name);
+                    
+                    MetadataType metadataType = commonMetadataNames.get(name);
+                   
+                    attrs.addCDATAAttribute("type", metadataType.toString());
+                    
+                    XMLUtils.startElement(contentHandler, "metadata", attrs);
+                    commonMetadata.get(name).toSAX(contentHandler, "label");
+                    XMLUtils.endElement(contentHandler, "metadata");
+                }
+            }
+            
+            AttributesImpl attrs = new AttributesImpl();
+            attrs.addAttribute("", "name", "name", "CDATA", FieldNames.LAST_VALIDATION);
+            attrs.addAttribute("", "type", "type", "CDATA", MetadataType.DATE.toString());
+            
+            XMLUtils.startElement(contentHandler, "metadata", attrs);
+            new I18nizableText("plugin.web", "PLUGINS_WEB_LAST_VALIDATION_DATE").toSAX(contentHandler, "label");
+            XMLUtils.endElement(contentHandler, "metadata");
+        }
+        
+        AttributesImpl attrs = new AttributesImpl();
+        attrs.addAttribute("", "name", "name", "CDATA", FieldNames.LAST_MODIFIED);
+        attrs.addAttribute("", "type", "type", "CDATA", MetadataType.DATE.toString());
+        
+        XMLUtils.startElement(contentHandler, "metadata", attrs);
+        new I18nizableText("plugin.web", "PLUGINS_WEB_LAST_MODIFICATION_DATE").toSAX(contentHandler, "label");
+        XMLUtils.endElement(contentHandler, "metadata");
+        
+        XMLUtils.endElement(contentHandler, "metadata");
+        contentHandler.endDocument();
+    }
+    
+    /**
+     * Get all the available content types 
+     * @param request the request
+     * @param publicOnly Only the non private content types will be returned
+     * @return all the available content types 
+     */
+    protected String[] getAllAvailablesContentTypes (Request request, boolean publicOnly)
+    {
+        Set<String> publicTypes = new HashSet<String>();
+        
+        for (String id : _cTypeEP.getExtensionsIds())
+        {
+            if (!publicOnly || !_cTypeEP.getExtension(id).isPrivate())
+            {
+                publicTypes.add(id);
+            }
+        }
+        
+        return publicTypes.toArray(new String[publicTypes.size()]);
+    }
+}
