Index: plugins/optional/web_creation/src/org/ametys/anycontent/plugins/web_creation/actions/GetTemplatesListGenerator.java
===================================================================
RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/web_creation/src/org/ametys/anycontent/plugins/web_creation/actions/GetTemplatesListGenerator.java,v
retrieving revision 1.1
diff -u -r1.1 GetTemplatesListGenerator.java
--- plugins/optional/web_creation/src/org/ametys/anycontent/plugins/web_creation/actions/GetTemplatesListGenerator.java 13 Mar 2007 10:43:43 -0000 1.1
+++ plugins/optional/web_creation/src/org/ametys/anycontent/plugins/web_creation/actions/GetTemplatesListGenerator.java 2 Sep 2008 09:50:23 -0000
@@ -17,6 +17,7 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.generation.ServiceableGenerator;
+import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -36,7 +37,9 @@
{
private static final String __TAG_RESULT = "result";
private static final String __TAG_TEMPLATE = "template";
+ private static final String __TAG_DISPLAY_NAME = "displayName";
private static final String __TAG_DESCRIPTION = "description";
+ private static final String __CONFIGURATION_DISPLAY_NAME = "displayName";
private static final String __CONFIGURATION_DESCRIPTION = "description";
private String _rootDirectoryPath = "";
@@ -154,12 +157,13 @@
return false;
}
- private String getTemplateDescription (String templateName)
+ private Template getTemplateDescription (String templateName)
{
File templateDirectory = getTemplateDirectory(templateName);
File templateDescFile = new File(templateDirectory.getAbsolutePath() + "/thumbnail.xml");
+ String displayName = templateName;
String description = "-";
try
{
@@ -167,6 +171,7 @@
{
DefaultConfigurationBuilder dcb = new DefaultConfigurationBuilder();
Configuration root = dcb.buildFromFile(templateDescFile);
+ displayName = root.getChild(__CONFIGURATION_DISPLAY_NAME).getValue(templateName);
description = root.getChild(__CONFIGURATION_DESCRIPTION).getValue("-");
}
}
@@ -175,7 +180,7 @@
getLogger().error("Unable to get template description for template " + templateName, e);
}
- return description;
+ return new Template(displayName, description);
}
public void generate() throws IOException, SAXException, ProcessingException
@@ -191,6 +196,7 @@
for (int i = 0; i < templatesName.length; i++)
{
+ Template template = getTemplateDescription(templatesName[i]);
AttributesImpl atts2 = new AttributesImpl();
atts2.addAttribute("", "name", "name", "CDATA", templatesName[i]);
@@ -205,12 +211,8 @@
}
contentHandler.startElement("", __TAG_TEMPLATE, __TAG_TEMPLATE, atts2);
- AttributesImpl atts3 = new AttributesImpl();
- contentHandler.startElement("", __TAG_DESCRIPTION, __TAG_DESCRIPTION, atts3);
- String txt = getTemplateDescription(templatesName[i]);
- contentHandler.characters(txt.toCharArray(), 0, txt.length());
-
- contentHandler.endElement("", __TAG_DESCRIPTION, __TAG_DESCRIPTION);
+ XMLUtils.createElement(contentHandler, __TAG_DISPLAY_NAME, template.getDisplayName());
+ XMLUtils.createElement(contentHandler, __TAG_DESCRIPTION, template.getDescription());
contentHandler.endElement("", __TAG_TEMPLATE, __TAG_TEMPLATE);
}
@@ -229,4 +231,36 @@
}
+ /**
+ * Template with a display name and a description.
+ */
+ private static class Template
+ {
+ private String _displayName;
+ private String _description;
+
+ public Template(String displayName, String description)
+ {
+ _displayName = displayName;
+ _description = description;
+ }
+
+ /**
+ * Retrieve the display name.
+ * @return the display name.
+ */
+ public String getDisplayName()
+ {
+ return _displayName;
+ }
+
+ /**
+ * Retrieve the description.
+ * @return the description.
+ */
+ public String getDescription()
+ {
+ return _description;
+ }
+ }
}
Index: plugins/optional/web_creation/resources_dynamic/js/pages.js
===================================================================
RCS file: /cvs/produits/Ametys/AnyContent_2.9/plugins/optional/web_creation/resources_dynamic/js/pages.js,v
retrieving revision 1.4
diff -u -r1.4 pages.js
--- plugins/optional/web_creation/resources_dynamic/js/pages.js 3 Sep 2007 16:53:41 -0000 1.4
+++ plugins/optional/web_creation/resources_dynamic/js/pages.js 2 Sep 2008 09:50:23 -0000
@@ -419,10 +419,10 @@
var nodes = result.selectNodes("/result/template");
for (var i = 0; i < nodes.length; i++)
- {
+ {
var opt = _document.createElement("option");
opt.value = nodes[i].getAttribute('name');
- opt.innerHTML = nodes[i].getAttribute('name');
+ opt.text = nodes[i].selectSingleNode("displayName")[Tools.xmlTextContent];
select.appendChild(opt);
var t = {};
Le patch qui devrait corriger le tout mais qui ne fonctionne pas et je sais pas pourquoi...