[Yanel-commits] rev 20556 - in public/yanel/trunk/src: build contributions/resources/contact-form contributions/resources/contact-form/conf contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources contributions/resources/contact-form/xml contributions/resources/contact-form/xslt contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources core/java/org/wyona/yanel/core core/java/org/wyona/yanel/core/transformation core/java/org/wyona/yanel/core/util realms/yanel-website/content/contact-form realms/yanel-website/content/documentation/i18n realms/yanel-website/content/rtd realms/yanel-website/content/xslt

josias at wyona.com josias at wyona.com
Mon Dec 4 16:50:18 CET 2006


Author: josias
Date: 2006-12-04 16:50:17 +0100 (Mon, 04 Dec 2006)
New Revision: 20556

Added:
   public/yanel/trunk/src/build/global_de.properties
   public/yanel/trunk/src/build/global_en.properties
   public/yanel/trunk/src/contributions/resources/contact-form/conf/
   public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_de.properties
   public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_en.properties
   public/yanel/trunk/src/contributions/resources/contact-form/xml/
   public/yanel/trunk/src/contributions/resources/contact-form/xml/contact-form.xml
   public/yanel/trunk/src/contributions/resources/contact-form/xslt/
   public/yanel/trunk/src/contributions/resources/contact-form/xslt/contact-form.xsl
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/I18nTransformer.java
   public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/HttpServletRequestHelper.java
   public/yanel/trunk/src/realms/yanel-website/content/xslt/contact-form.xsl
Modified:
   public/yanel/trunk/src/build/build.xml
   public/yanel/trunk/src/contributions/resources/contact-form/build.xml
   public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactBean.java
   public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java
   public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/I18nTransformer.java
   public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java
   public/yanel/trunk/src/realms/yanel-website/content/contact-form/en.xhtml
   public/yanel/trunk/src/realms/yanel-website/content/documentation/i18n/en.xhtml
   public/yanel/trunk/src/realms/yanel-website/content/rtd/contact-form.rtd
   public/yanel/trunk/src/realms/yanel-website/content/xslt/global.xsl
Log:
bug #5056 and #5072: improved error handling, i18n, and encoding of the contact resource. thanks to David.

Modified: public/yanel/trunk/src/build/build.xml
===================================================================
--- public/yanel/trunk/src/build/build.xml	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/build/build.xml	2006-12-04 15:50:17 UTC (rev 20556)
@@ -776,6 +776,13 @@
   </target>
 
   <target name="deploy-resources" description="Deploy resources" depends="generate-resources-build">
+  
+    <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes/">
+      <fileset dir="." casesensitive="yes">
+        <include name="global_*.properties"/>
+      </fileset>
+    </copy>
+    
     <ant antfile="${yanel.home.dir}/build/resources.xml" target="deploy-resources"/>
   </target>
 

Added: public/yanel/trunk/src/build/global_de.properties
===================================================================
--- public/yanel/trunk/src/build/global_de.properties	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/build/global_de.properties	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,4 @@
+poweredBy = Angetrieben von 
+allRightsReserved = Alle Rechte vorbehalten 
+pageInfo = Seiten Info 
+search = Suche 


Property changes on: public/yanel/trunk/src/build/global_de.properties
___________________________________________________________________
Name: svn:eol-style
   + native

Added: public/yanel/trunk/src/build/global_en.properties
===================================================================
--- public/yanel/trunk/src/build/global_en.properties	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/build/global_en.properties	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,4 @@
+poweredBy = Powered by 
+allRightsReserved = All rights reserved 
+pageInfo = Page Info 
+search = Search 


Property changes on: public/yanel/trunk/src/build/global_en.properties
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/contributions/resources/contact-form/build.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/build.xml	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/build.xml	2006-12-04 15:50:17 UTC (rev 20556)
@@ -45,5 +45,9 @@
       <fileset refid="maven2.resource.fileset"/>
       <mapper type="flatten"/>
     </copy>
+    
+    <copy todir="${build.dir}/webapps/${servlet.context.prefix}/WEB-INF/classes">
+      <fileset dir="conf" includes="contact-form_*.properties"/>
+    </copy>
   </target>
 </project>

Added: public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_de.properties
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_de.properties	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_de.properties	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,22 @@
+contact = Kontakt
+generalInquiriesPleaseContact = Bei weiteren Fragen, wenden Sie sich bitte an 
+mailingAddressCanBeFound = Mailing Adressen finden Sie auf unserer 
+corporateContactPage = gemeinsamen Kontaktseite
+company = Firma
+firstName = Vorname
+lastName = Nachname
+email = Email
+address = Adresse
+zipCity = PLZ / Stadt
+message = Nachricht
+send = Senden
+requiredFields = Pflichtfelder sind (*) markiert
+emailNotSet = Email darf nicht leer sein!
+emailNotValid = Email ist nicht korrekt
+thankYou = Vielen Dank!
+inquiryContent = Folgende Angaben wurden an uns gesandt.
+smtpConfigError = 'smtp' wurde nicht konfiguriert, checken Sie Ihre rti Konfigurationsdatei
+unknownHost = Unbekannter Host, checken Sie Ihre rti Konfigurationsdatei
+smtpPortNotCorrect = SMPT port ist nicht korrekt, checken Sie Ihre rti Konfigurationsdatei
+invalidAddress = Unbekannte Adresse, please check your rti config file
+couldNotSendMail = Mail konnte nicht versandt werden.


Property changes on: public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_de.properties
___________________________________________________________________
Name: svn:eol-style
   + native

Added: public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_en.properties
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_en.properties	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_en.properties	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,22 @@
+contact = Contact
+generalInquiriesPleaseContact = For general inquiries, please use 
+mailingAddressCanBeFound = Mailing addresses can be found on our 
+corporateContactPage = corporate contact page
+company = Company
+firstName = Firstname
+lastName = Lastname
+email = Email
+address = Address
+zipCity = Zip / City
+message = Message
+send = Send
+requiredFields = fields marked with (*) are required
+emailNotSet = Email must not be empty!
+emailNotValid = Email is not valid
+thankYou = Thank you!
+inquiryContent = This has been sent to us.
+smtpConfigError = 'smtp' was not set properly, please check your rti config file
+unknownHost = Unknown host, please check your rti config file
+smtpPortNotCorrect = SMPT port is not correct, please check your rti config file
+invalidAddress = Invalid address, please check your rti config file
+couldNotSendMail = Could not send mail.


Property changes on: public/yanel/trunk/src/contributions/resources/contact-form/conf/contact-form_en.properties
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactBean.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactBean.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactBean.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -1,6 +1,7 @@
 package org.wyona.yanel.impl.resources;
 
 import javax.servlet.http.HttpServletRequest;
+import org.wyona.yanel.core.util.HttpServletRequestHelper;
 
 public class ContactBean {
     String company, lastName, firstName, address, city, email, message;
@@ -27,12 +28,12 @@
         return lastName;
     }
     public ContactBean(HttpServletRequest request) {
-        company = request.getParameter("company");
-        firstName  = request.getParameter("firstName");
-        lastName = request.getParameter("lastName");
-        address  = request.getParameter("address");
-        city  = request.getParameter("city");
-        email  = request.getParameter("email");
-        message = request.getParameter("message");
+        company = HttpServletRequestHelper.getParameter(request, "company");
+        firstName = HttpServletRequestHelper.getParameter(request, "firstName");
+        lastName = HttpServletRequestHelper.getParameter(request, "lastName");
+        address  = HttpServletRequestHelper.getParameter(request, "address");
+        city  = HttpServletRequestHelper.getParameter(request, "zipCity");
+        email  = HttpServletRequestHelper.getParameter(request, "email");
+        message = HttpServletRequestHelper.getParameter(request, "message");
     }
 }

Modified: public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -19,13 +19,20 @@
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.StringReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
-
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
 import javax.mail.MessagingException;
 import javax.mail.internet.AddressException;
 import javax.servlet.http.HttpServletRequest;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
@@ -44,8 +51,10 @@
 import org.wyona.yarep.core.Repository;
 import org.wyona.yarep.core.RepositoryException;
 import org.wyona.yarep.core.RepositoryFactory;
+import org.wyona.yanel.core.transformation.I18nTransformer;
 import org.wyona.yarep.util.RepoPath;
 import org.wyona.yarep.util.YarepUtil;
+import org.wyona.yanel.core.util.HttpServletRequestHelper;;
 
 /**
  * 
@@ -53,27 +62,24 @@
 public class ContactResource extends Resource implements ViewableV1 {
 
     private static final String SMTP_HOST = "smtpHost:";
-
     private static final String SMTP_PORT = "smtpPort:";
-
     private static final String TO = "to:";
-
     private static Category log = Category.getInstance(ContactResource.class);
-
-    private String smtpHost;
-
+    private String smtpHost = "";
     private int smtpPort = 0;
-
-    private String to;
-
-    private String from;
-
-    private String subject;
-
-    private String content;
-    
+    private String to = "";
+    private String from = "";
+    private String subject = "YANEL FEEDBACK";
+    private String content = "";
     private ContactBean contact = null;
-
+    private String defaultLanguage = "en";
+    private String messageBundle = "contact-form";
+    
+    private Repository repository  = null;
+    private RepoPath rp = null;
+    private Path path = null;
+    private String language = null;
+    
     /**
      * 
      */
@@ -91,288 +97,174 @@
      * 
      */
     public View getView(Path path, String viewId) {
-        View defaultView = new View();
-        defaultView.setMimeType("application/xml");
-        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
-        defaultView.setInputStream(new java.io.StringBufferInputStream(sb
-                .toString()));
-        return defaultView;
+        return null;
     }
 
     /**
-     * @throws Exception
      * 
      */
     public View getView(HttpServletRequest request, String viewId)
             throws Exception {
-        Path path = new Path(request.getServletPath());
-        Enumeration enumeration = request.getParameterNames();
-        boolean submit = enumeration.hasMoreElements();
-        // if submit null just return the file
-        if (!submit) {
-            View defaultView = new View();
-            return plainRequest(path, defaultView);
+        path = new Path(request.getServletPath());
+        rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+        repository = rp.getRepo();
+        try {
+            language = request.getParameter("yanel.meta.language");
+        } catch(Exception e) {
+            log.debug("language param is not found will use default : " + language);
+            language = defaultLanguage;
         }
-        String uri = request.getRequestURI();
-
-        boolean success = false;
-        Map status = null;
-        if (!getProperties(path)) {
-            log.warn("SetupException: ");
-            status = new HashMap(3);
-            status.put(SendMail.STATUS, "user-error");
-            status.put(SendMail.MESSAGE, "Please verify your setup of the rti!");
-            return computeForward(path, status);
-        } else {
-            // getting the form values
-            contact = new ContactBean(request);
-            verifyContact(contact);
-            try {
-                SendMail.send(smtpHost, smtpPort, from, to, subject, content);
-                success = true;
-                status = new HashMap(3);
-                status.put(SendMail.STATUS, "success");
-            } catch (AddressException e) {
-                log.warn("AddressException: ", e);
-                status = new HashMap(3);
-                status.put(SendMail.STATUS, "user-error");
-                status.put(SendMail.MESSAGE, e.getMessage());
-            } catch (MessagingException e) {
-                log.warn("MessagingException: "
-                        + "An error occured while sending email.", e);
-
-                status = new HashMap(3);
-                status.put(SendMail.STATUS, "server-error");
-                status.put(SendMail.MESSAGE,
-                        "An error occured while sending email: "
-                                + e.getMessage());
-            } finally {
-                return computeForward(path, status);
-            }
+        if(language == null || ("").equals(language)) {
+            log.debug("language param is empty or null : " + language);
+            language = defaultLanguage;
         }
-    }
-
-    private View plainRequest(Path path, View defaultView) throws Exception,
-            TransformerConfigurationException,
-            TransformerFactoryConfigurationError, NoSuchNodeException,
-            TransformerException {
-        Repository contentRepo;
-        RepoPath rp = contentRepo(path);
-        contentRepo = rp.getRepo();
-
-        Transformer transformer = TransformerFactory.newInstance()
-                .newTransformer(getXSLTStreamSource(path, contentRepo));
-        transformer.setParameter("yanel.path.name", path.getName());
-        transformer.setParameter("yanel.path", path.toString());
-        transformer.setParameter("yanel.back2context", backToRoot(path, ""));
-        transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
-        // TODO: Is this the best way to generate an InputStream from an
-        // OutputStream?
-        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
-        transformer.transform(new StreamSource(rp.getRepo().getInputStream(
-                new org.wyona.yarep.core.Path(rp.getPath().toString()))),
-                new StreamResult(baos));
-        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos
-                .toByteArray()));
-        defaultView.setMimeType(getMimeType(path));
-        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos
-                .toByteArray()));
-
-        return defaultView;
-    }
-
-    private RepoPath contentRepo(Path path) throws Exception {
-        return new YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(
-                path.toString()), getRepositoryFactory());
-    }
-
-    private String getMimeType(Path path, String viewId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    private View computeForward(Path path, Map status) throws Exception {
-        View defaultView = new View();
-        defaultView.setMimeType("application/xml");
-        StringBuffer sb = new StringBuffer("<?xml version=\"1.0\"?>");
-        sb.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
-        sb.append("<head>");
-        // here we need to test the status of the mail
-        String statusCode = (String) status.get(SendMail.STATUS);
-        if (statusCode.equals("success")) {
-            sb.append("<title>Your message has been sent successfully.</title>");
-            sb.append("</head>");
-            sb.append("<body>");
-            sb.append("<div id=\"contenBody\">");
-            sb.append("<h1>Success</h1>");
-            sb.append("<p>Following message has been sent:</p>");
-            // decoding content of the message body
-            StringReader stringReader = new StringReader(content);
-            BufferedReader reader = new BufferedReader(stringReader);
-            String line = null;
-            while ((line = reader.readLine()) != null) {
-                sb.append("<p>" + line + "</p>");
+        Transformer transformer = null;
+        I18nTransformer i18nTransformer = null;
+        File xslFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "contact-form.xsl");
+        File xmlFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "contact-form.xml");        
+        try {
+            transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslFile));
+            boolean submit = false;
+            Enumeration enumeration = request.getParameterNames();
+            while(enumeration.hasMoreElements()){
+                if(enumeration.nextElement().toString().equals("submit")) 
+                    submit = true;
             }
-            // finishing
-            sb.append("</div>");
-            sb.append("</body>");
-        } else {
-            sb.append("<title>Your message has not been sent.</title>");
-            sb.append("</head>");
-            sb.append("<body>");
-            sb.append("<div id=\"contenBody\">");
+            if(submit) {
+                sendMail(request, transformer);
+                transformer.setParameter("company", HttpServletRequestHelper.getParameter(request, "company"));
+                transformer.setParameter("firstName", HttpServletRequestHelper.getParameter(request, "firstName"));
+                transformer.setParameter("lastName", HttpServletRequestHelper.getParameter(request, "lastName"));
+                transformer.setParameter("email", HttpServletRequestHelper.getParameter(request, "email"));
+                transformer.setParameter("address", HttpServletRequestHelper.getParameter(request, "address"));
+                transformer.setParameter("zipCity", HttpServletRequestHelper.getParameter(request, "zipCity"));
+                transformer.setParameter("message", HttpServletRequestHelper.getParameter(request, "message"));
+            }
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+            transformer.transform(new javax.xml.transform.stream.StreamSource(xmlFile), new StreamResult(byteArrayOutputStream));
+            //translate the form
+            i18nTransformer = new I18nTransformer(messageBundle, language);
+            SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
             
+            transformer = TransformerFactory.newInstance().newTransformer(getXSLTStreamSource(path, repository));
+            transformer.setParameter("yanel.path.name", path.getName());
+            transformer.setParameter("yanel.path", path.toString());
+            transformer.setParameter("yanel.back2context", backToRoot(path, ""));
+            transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ 
+            byteArrayOutputStream = new ByteArrayOutputStream();
+            transformer.transform(new StreamSource(i18nTransformer.getInputStream()), new StreamResult(byteArrayOutputStream));
+            //tranlate the page
+            i18nTransformer = new I18nTransformer("global", language);
+            saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser.parse(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()), i18nTransformer);
             
-            String errorMessage = (String) status.get(SendMail.MESSAGE);
-            errorMessage = errorMessage.replaceAll("<", "&lt;");
-            errorMessage = errorMessage.replaceAll(">", "&gt;");
-            
-            sb.append(getForm(errorMessage, contact));
-            /*
-            sb.append("<h1>" + status.get(SendMail.STATUS) + "</h1>");
-            sb.append("<p>Your message has not been sent.</p>");
-            
-            sb.append("<p>" + errorMessage + "</p>");
-            */
-            sb.append("</div>");
-            sb.append("</body>");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
         }
-        sb.append("</html>");
-        computeView(path, defaultView, sb);
+        View defaultView = new View();
+        defaultView.setMimeType("application/xml");
+        defaultView.setInputStream(i18nTransformer.getInputStream());
         return defaultView;
     }
+
     
-    
-    private String getForm(String errorMessage, ContactBean bean) {
-      
-      String form = "<form method=\"post\" action=\"#\">" +
-                    "\n\t<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">" +
-                    "\n\t\t<tr>" + 
-                    "\n\t\t\t<td colspan=\"2\">" + 
-                    "\n\t\t\t\t<h1>Your mail could not be sent</h1>" + 
-                    "\n\t\t\t\t<h2>" + errorMessage + "</h2>" + 
-                    "\n\t\t\t</td>" + 
-                    "\n\t\t</tr>" + 
-                    "\n\t\t<tr>" + 
-                    "\n\t\t\t<td colspan=\"2\"></td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">Company</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"text\" name=\"company\" class=\"box\" size=\"40\" value=\"" + contact.getCompany() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">Firstname</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"text\" name=\"firstName\" class=\"box\" size=\"40\" value=\"" + contact.getFirstName() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">Lastname</td>" +
-                    "\n\t\t\t\t<td>" +
-                    "\n\t\t\t\t\t<input type=\"text\" name=\"lastName\" class=\"box\" size=\"40\" value=\"" + contact.getLastName() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">Address</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"text\" name=\"address\" class=\"box\" size=\"40\" value=\"" + contact.getAddress() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">ZIP / City</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"text\" name=\"city\" class=\"box\" size=\"40\" value=\"" + contact.getCity() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">E-Mail</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"text\" name=\"email\" class=\"box\" backgroundcolor=\"lightgrey\" size=\"40\" value=\"" + contact.getEmail() + "\"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td align=\"right\" valign=\"top\" class=\"contentfield\">Message</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<textarea rows=\"8\" name=\"message\" cols=\"30\" class=\"box\" value=\"" + contact.getMessage() + "\">&#160;</textarea>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t\t<tr>" +
-                    "\n\t\t\t<td>&#160;" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t\t<td>" +
-                    "\n\t\t\t\t<input type=\"submit\" value=\"send \"/>" +
-                    "\n\t\t\t</td>" +
-                    "\n\t\t</tr>" +
-                    "\n\t</table>" +
-                    "</form>";
-                    
-        return form;  
-    }
 
-    private void computeView(Path path, View defaultView, StringBuffer sb)
-            throws Exception, TransformerConfigurationException,
-            TransformerFactoryConfigurationError, NoSuchNodeException,
-            TransformerException {
 
-        RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
-        
-        Transformer transformer = prepareTransformer(path);
-        transformer.setParameter("yanel.back2context", backToRoot(path, ""));
-        transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
-        // TODO: Is this the best way to generate an InputStream from an
-        // OutputStream?
-        
-        java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
-        transformer.transform(new StreamSource(
-                new java.io.StringBufferInputStream(sb.toString())),
-                new StreamResult(baos));
-        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos
-                .toByteArray()));
-        defaultView.setMimeType(getMimeType(path));
-        defaultView.setInputStream(new java.io.ByteArrayInputStream(baos
-                .toByteArray()));
-    }
-
-    private Transformer prepareTransformer(Path path) throws Exception,
-            TransformerConfigurationException,
-            TransformerFactoryConfigurationError, NoSuchNodeException {
-        Repository contentRepo;
-        RepoPath rp = contentRepo(path);
-        contentRepo = rp.getRepo();
-        Transformer transformer = TransformerFactory.newInstance()
-                .newTransformer(getXSLTStreamSource(path, contentRepo));
-        transformer.setParameter("yanel.path.name", path.getName());
-        transformer.setParameter("yanel.path", path.toString());
-        return transformer;
-    }
-
+    
     /**
-     * Here we need to verify whether we have all props that we need for the
-     * SendMail class.
+     * 
+     * @param request
+     * @param transformer
      */
-    private boolean verifyContact(ContactBean contact) {
-        boolean success = false;
-        if (null != contact.email & null != contact.message) {
-
-            from = contact.email;
-            subject = "Yanel feedback";
+    private void sendMail(HttpServletRequest request, Transformer transformer) {
+        String email = request.getParameter("email");
+        if(email == null || ("").equals(email)) {
+            transformer.setParameter("error", "emailNotSet");
+        } else if(!validateEmail(email)) {
+            transformer.setParameter("error", "emailNotValid");
+        } else {
+            contact = new ContactBean(request);
+            smtpHost = getProperty(SMTP_HOST);
+            try {
+                smtpPort = Integer.parseInt(getProperty(SMTP_PORT));
+            } catch(NumberFormatException nfe) {
+                log.error(nfe);
+                transformer.setParameter("error", "smtpPortNotCorrect");
+                smtpPort = 0;
+            }
+            to = getProperty(TO);
+            from = email;
             content = "Company: " + contact.getCompany() + "\n" + "Firstname: "
                     + contact.getFirstName() + "\n" + "Lastname: "
                     + contact.getLastName() + "\n" + "Address: "
                     + contact.getAddress() + "\n" + "City: " + contact.getCity()
                     + "\n" + "Email: " + contact.getEmail() + "\n" + "\n"
                     + "Message:\n" + contact.message;
-            success = true;
+            
+            if(smtpHost != null && smtpPort != 0 && to != null) {
+                try {
+                    SendMail.send(smtpHost, smtpPort, from, to, subject, content);
+                    transformer.setParameter("sent", "true");
+                } catch(javax.mail.MessagingException me) {
+                    log.error("#" + me + "#");
+                    if(("" + me).startsWith("javax.mail.MessagingException: Unknown SMTP")) {
+                        transformer.setParameter("error", "unknownHost");
+                    } else if(("" + me).startsWith("javax.mail.SendFailedException: Invalid Addresses")) {
+                        transformer.setParameter("error", "invalidAddress");
+                    } else {
+                        transformer.setParameter("error", "couldNotSendMail");
+                    }
+                }
+            } else {
+                transformer.setParameter("error", "smtpConfigError");
+            }
         }
-        return success;
-
     }
+    
+    /**
+     * this method checks if the specified email is valid against a regex
+     * @param email
+     * @return true if email is valid
+     */
+    private boolean validateEmail(String email) {
+        String emailRegEx = "(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*";
+        Pattern pattern = Pattern.compile(emailRegEx);
+        Matcher matcher = pattern.matcher(email);
+        return matcher.find();
+    }
+    
+    /**
+     * 
+     * @param path
+     * @return
+     * @throws Exception
+     */
+    private RepoPath contentRepo(Path path) throws Exception {
+        return new YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(
+                path.toString()), getRepositoryFactory());
+    }
 
     /**
      * 
+     * @param path
+     * @param viewId
+     * @return
      */
+    private String getMimeType(Path path, String viewId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
+    /**
+     * 
+     * @param path
+     * @param repo
+     * @return
+     * @throws NoSuchNodeException
+     */
     private StreamSource getXSLTStreamSource(Path path, Repository repo)
             throws NoSuchNodeException, RepositoryException {
         Path xsltPath = getXSLTPath(path);
@@ -388,21 +280,18 @@
             return new StreamSource(xsltFile);
         }
     }
-
+    
     /**
      * 
+     * @param path
+     * @return
      */
     private Path getXSLTPath(Path path) {
         String xsltPath = null;
         try {
-            // TODO: Get yanel RTI yarep properties file name from framework
-            // resp. use MapFactory ...!
-            RepoPath rpRTI = new org.wyona.yarep.util.YarepUtil()
-                    .getRepositoryPath(new org.wyona.yarep.core.Path(path
-                            .toString()), getRTIRepositoryFactory());
-            java.io.BufferedReader br = new java.io.BufferedReader(rpRTI
+            java.io.BufferedReader br = new java.io.BufferedReader(rp
                     .getRepo().getReader(
-                            new org.wyona.yarep.core.Path(new Path(rpRTI
+                            new org.wyona.yarep.core.Path(new Path(rp
                                     .getPath().toString()).getRTIPath()
                                     .toString())));
 
@@ -413,69 +302,45 @@
                     return new Path(xsltPath);
                 }
             }
-            log.error("No XSLT Path within: " + rpRTI.getPath());
+            log.error("No XSLT Path within: " + rp.getPath());
         } catch (Exception e) {
             log.warn(e);
         }
-
         return null;
     }
-
+    
     /**
-     * Here we need to verify that all default information like mail host, port,
-     * etc. are set. If not we can directly abort the processing and report an
-     * error.
+     * this method reads out the specified key from rti file 
+     * if key cannot be found return null
+     * @param key
+     * @return value
      */
-    private boolean getProperties(Path path) {
-        boolean success = false;
-        String line = null;
+    private String getProperty(String key) {
         try {
-            // TODO: Get yanel RTI yarep properties file name from framework
-            // resp. use MapFactory ...!
-            RepoPath rpRTI = new org.wyona.yarep.util.YarepUtil()
-                    .getRepositoryPath(new org.wyona.yarep.core.Path(path
-                            .toString()), getRTIRepositoryFactory());
-            java.io.BufferedReader br = new java.io.BufferedReader(rpRTI
-                    .getRepo().getReader(
-                            new org.wyona.yarep.core.Path(new Path(rpRTI
-                                    .getPath().toString()).getRTIPath()
-                                    .toString())));
-
-            while ((line = br.readLine()) != null) {
-                if (line.indexOf(SMTP_HOST) == 0) {
-                    smtpHost = line.substring(SMTP_HOST.length() + 1);
+            java.io.BufferedReader bufferedReader = new java.io.BufferedReader(rp.getRepo().getReader(new org.wyona.yarep.core.Path(new Path(rp.getPath().toString()).getRTIPath().toString())));
+            String line = null;
+            while((line = bufferedReader.readLine()) != null) {
+                if(line.indexOf(key) == 0) {
+                    return line.substring(key.length() + 1);
                 }
-                if (line.indexOf(SMTP_PORT) == 0) {
-                    smtpPort = Integer.parseInt(line.substring(SMTP_PORT
-                            .length() + 1));
-                }
-                if (line.indexOf(TO) == 0) {
-                    to = line.substring(TO.length() + 1);
-                }
             }
         } catch (Exception e) {
-            log.warn(e);
+            log.error(e);
         }
-        if (null != smtpHost & 0 < smtpPort & null != to) {
-            success = true;
-        }
-        return success;
+        return null;
     }
-
+    
     /**
      * 
+     * @param path
+     * @return
      */
     private String getMimeType(Path path) {
         String mimeType = null;
         try {
-            // TODO: Get yanel RTI yarep properties file name from framework
-            // resp. use MapFactory ...!
-            RepoPath rpRTI = new org.wyona.yarep.util.YarepUtil()
-                    .getRepositoryPath(new org.wyona.yarep.core.Path(path
-                            .toString()), getRTIRepositoryFactory());
-            java.io.BufferedReader br = new java.io.BufferedReader(rpRTI
+            java.io.BufferedReader br = new java.io.BufferedReader(rp
                     .getRepo().getReader(
-                            new org.wyona.yarep.core.Path(new Path(rpRTI
+                            new org.wyona.yarep.core.Path(new Path(rp
                                     .getPath().toString()).getRTIPath()
                                     .toString())));
 
@@ -483,37 +348,30 @@
                 if (mimeType.indexOf("mime-type:") == 0) {
                     mimeType = mimeType.substring(11);
                     log.info("*" + mimeType + "*");
-                    // TODO: Maybe validate mime-type ...
                     return mimeType;
                 }
             }
         } catch (Exception e) {
             log.warn(e);
         }
-
         // NOTE: Assuming fallback re dir2xhtml.xsl ...
         return "application/xhtml+xml";
     }
-    
-    /**
-     * 
-     * @return
-     */
-    protected RepositoryFactory getRepositoryFactory() {
-        return yanel.getRepositoryFactory("DefaultRepositoryFactory");
-    }
-    
-    /**
-     * 
-     * @return
-     */
-    protected RepositoryFactory getRTIRepositoryFactory() {
-        return yanel.getRepositoryFactory("RTIRepositoryFactory");
-    }
-    
+   
    /**
-    *
+    * 
+    * @return
     */
+   protected RepositoryFactory getRepositoryFactory() {
+       return yanel.getRepositoryFactory("DefaultRepositoryFactory");
+   }
+   
+   /**
+    * 
+    * @param path
+    * @param backToRoot
+    * @return
+    */
    private String backToRoot(Path path, String backToRoot) {
        org.wyona.commons.io.Path parent = path.getParent();
        if (parent != null && !isRoot(parent)) {
@@ -521,12 +379,14 @@
        }
        return backToRoot;
    }
-   
-  /**
-   *
-   */
-  private boolean isRoot(org.wyona.commons.io.Path path) {
-      if (path.toString().equals(File.separator)) return true;
-      return false;
-  }
-}
+
+   /**
+    * 
+    * @param path
+    * @return
+    */
+   private boolean isRoot(org.wyona.commons.io.Path path) {
+       if (path.toString().equals(File.separator)) return true;
+       return false;
+   }
+}
\ No newline at end of file

Added: public/yanel/trunk/src/contributions/resources/contact-form/xml/contact-form.xml
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/xml/contact-form.xml	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/xml/contact-form.xml	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<form name="contact-form">
+  <inputfields>
+    <input required="false">company</input>
+    <input required="false">firstName</input>
+    <input required="false">lastName</input>
+    <input required="true">email</input>
+    <input required="false">address</input>
+    <input required="false">zipCity</input>
+  </inputfields>
+  <textAreas>
+    <textArea required="false">message</textArea>
+  </textAreas>
+</form>


Property changes on: public/yanel/trunk/src/contributions/resources/contact-form/xml/contact-form.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: public/yanel/trunk/src/contributions/resources/contact-form/xslt/contact-form.xsl
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/xslt/contact-form.xsl	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/contact-form/xslt/contact-form.xsl	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns="http://www.w3.org/1999/xhtml"
+>
+
+  <xsl:output method="xhtml" encoding="UTF-8"/>
+
+  <xsl:param name="company" select="''"/>
+  <xsl:param name="firstName" select="''"/>
+  <xsl:param name="lastName" select="''"/>
+  <xsl:param name="email" select="''"/>
+  <xsl:param name="address" select="''"/>
+  <xsl:param name="zipCity" select="''"/>
+  <xsl:param name="message" select="''"/>
+  <xsl:param name="error" select="''"/>
+  
+  <xsl:param name="sent" select="'false'"/>
+
+  <xsl:template match="/">
+    <html xmlns="http://www.w3.org/1999/xhtml">
+      <head>
+        <title><i18n:message key="contact"/></title>
+      </head>
+      
+      <body>
+        <h3><i18n:message key="contact"/></h3>
+        <p><i18n:message key="generalInquiriesPleaseContact"/><a href="mailto:contact at wyona.com">contact at wyona.com</a>.</p>
+        <p><i18n:message key="mailingAddressCanBeFound"/><a href="http://www.wyona.com/contact.html"><i18n:message key="corporateContactPage"/></a>.</p>
+        <div id="contenBody">
+        
+          <xsl:choose>
+            <xsl:when test="$error != ''">
+              <xsl:apply-templates select="form" mode="error"/>
+            </xsl:when>
+            <xsl:when test="$sent = 'true'">
+              <xsl:apply-templates select="form" mode="thankYou"/>
+            </xsl:when>
+            <xsl:otherwise>
+               <xsl:apply-templates select="form" mode="init"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        
+        </div>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="form" mode="init">
+    <form name="contact-form" method="post" action="#">
+      <table cellpadding="0" cellspacing="0" border="0">
+        <xsl:for-each select="inputfields/input">
+          <xsl:variable name="inputName"><xsl:value-of select="."/></xsl:variable>
+          <tr>
+            <td align="right" valign="top" class="contentfield"><i18n:message><xsl:attribute name="key"><xsl:value-of select="$inputName"/></xsl:attribute></i18n:message>:&#0160;</td>
+            <td>
+              <input type="text" name="{$inputName}" class="box" size="40"/>
+            </td>
+            <td><xsl:if test="@required = 'true'">*</xsl:if></td>
+          </tr>
+        </xsl:for-each>
+        
+        <xsl:for-each select="textAreas">
+          <xsl:variable name="inputName"><xsl:value-of select="textArea"/></xsl:variable>
+          <tr>
+            <td align="right" valign="top" class="contentfield"><i18n:message><xsl:attribute name="key"><xsl:value-of select="$inputName"/></xsl:attribute></i18n:message>:&#0160;</td>
+            <td>
+              <textarea rows="8" name="{$inputName}" cols="30" class="box"></textarea>
+            </td>
+            <td><xsl:if test="@required = 'true'">*</xsl:if></td>
+          </tr>
+        </xsl:for-each>
+        
+        <tr>
+          <td colspan="2">&#160;
+          </td>
+          <td>
+            <input type="submit" name="submit" value="i18n:attr key=send"/>
+          </td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield" colspan="3"><br/><i18n:message key="requiredFields"/></td>
+        </tr>
+      </table>
+    </form>
+  </xsl:template>
+
+  <xsl:template match="form" mode="error">
+    <form name="contact-form" method="post" action="#">
+      <table cellpadding="0" cellspacing="0" border="0">
+        <tr>
+          <td colspan="3" align="left" valign="top" class="contentfield"><font color="red"><i18n:message key="{$error}"/></font></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="company"/>&#0160;</td>
+          <td>
+            <input type="text" name="company" class="box" size="40" value="{$company}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="firstName"/>:&#0160;</td>
+          <td>
+            <input type="text" name="firstName" class="box" size="40" value="{$firstName}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="lastName"/>:&#0160;</td>
+          <td>
+            <input type="text" name="lastName" class="box" size="40" value="{$lastName}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="address"/>:&#0160;</td>
+          <td>
+            <input type="text" name="address" class="box" size="40" value="{$address}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="zipCity"/>:&#0160;</td>
+          <td>
+            <input type="text" name="zipCity" class="box" size="40" value="{$zipCity}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield">
+            <xsl:if test="starts-with($error, 'email')">
+              <font color="#FF0000"><i18n:message key="email"/>:&#0160;</font>
+            </xsl:if>
+            <xsl:if test="not(starts-with($error, 'email'))">
+              <i18n:message key="email"/>:&#0160;
+            </xsl:if>
+          </td>
+          <td>
+            <input type="text" name="email" class="box" size="40" value="{$email}"/>
+          </td>
+          <td>*</td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="message"/>:&#0160;</td>
+          <td>
+            <textarea rows="8" name="message" cols="30" class="box"><xsl:value-of select="$message"/></textarea>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td colspan="2">&#160;
+          </td>
+          <td>
+            <input type="submit" name="submit" value="i18n:attr key=send"/>
+          </td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield" colspan="3"><br/><i18n:message key="requiredFields"/></td>
+        </tr>
+      </table>
+    </form>
+  </xsl:template>
+  
+  <xsl:template match="form" mode="thankYou">
+    <table>
+      <tr>
+        <td colspan="3" align="right" valign="top" class="contentfield"><i18n:message key="thankYou"/></td>
+      </tr>
+      <tr>
+        <td colspan="3" align="right" valign="top" class="contentfield"><i18n:message key="inquiryContent"/></td>
+      </tr>
+      
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="company"/>:&#0160;</td>
+        <td><xsl:value-of select="$company"/></td>
+        <td></td>
+      </tr>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="firstName"/>:&#0160;</td>
+        <td><xsl:value-of select="$firstName"/></td>
+        <td></td>
+      </tr>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="lastName"/>:&#0160;</td>
+        <td><xsl:value-of select="$lastName"/></td>
+        <td></td>
+      </tr>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="address"/>:&#0160;</td>
+        <td><xsl:value-of select="$address"/></td>
+        <td></td>
+      </tr>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="zipCity"/>:&#0160;</td>
+        <td><xsl:value-of select="$zipCity"/></td>
+        <td></td>
+      </tr>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="message"/>:&#0160;</td>
+        <td><xsl:value-of select="$message"/></td>
+        <td></td>
+      </tr>
+    </table>
+  </xsl:template>
+</xsl:stylesheet>


Property changes on: public/yanel/trunk/src/contributions/resources/contact-form/xslt/contact-form.xsl
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/I18nTransformer.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/I18nTransformer.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/I18nTransformer.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -1,101 +0,0 @@
-package org.wyona.yanel.impl.resources;
-
-import java.io.ByteArrayInputStream;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import org.apache.log4j.Category;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class I18nTransformer extends DefaultHandler {
-
-    private static Category log = Category.getInstance(I18nTransformer.class);
-    private Locale currentLocale = null;
-    private ResourceBundle messageBundle = null;
-    private ByteArrayInputStream byteArrayInputStream = null;
-    private StringBuffer transformedXmlAsBuffer = null;
-
-    public I18nTransformer(String messages, String language) {
-        currentLocale = new Locale(language);
-        messageBundle = ResourceBundle.getBundle(messages, currentLocale);
-    }
-
-    public void startDocument() throws SAXException {
-        transformedXmlAsBuffer = new StringBuffer();
-    }
-
-    public void endDocument() throws SAXException {
-        setResultInputStream();
-    }
-
-    public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {
-        String eName = ("".equals(localName)) ? qName : localName;
-        
-        if ((eName.equals("message")) || (eName.equals("i18n:message"))) {
-            String key = attrs.getValue("key");
-            String i18nText = messageBundle.getString(key);
-            log.debug("TAG [key] " + key + " [message]" + i18nText);
-            char[] i18nMessage = i18nText.toCharArray(); 
-            characters(i18nMessage, 0, i18nMessage.length);
-        } else {
-            transformedXmlAsBuffer.append("<" + eName);
-            for(int i = 0; i < attrs.getLength(); i++) {
-                String aName = attrs.getQName(i);
-                String aValue = attrs.getValue(i);
-                if(aValue.indexOf("i18n:attr key=") != -1) {
-                    String key = aValue.substring(14);
-                    String i18nValue = messageBundle.getString(key);
-                    aValue = i18nValue;
-                    log.debug("ATTR [key] " + key + " [message]" + i18nValue);
-                }
-                aValue = replaceAmpersand(aValue);
-                transformedXmlAsBuffer.append(" " + aName + "=\"" + aValue + "\"");
-            }
-            transformedXmlAsBuffer.append(">");
-        }
-    }
-
-    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
-        String eName = ("".equals(localName)) ? qName : localName;
-        if ((eName.equals("message")) || (eName.equals("i18n:message"))) {
-            /*ignore these tags*/
-        } else {
-            transformedXmlAsBuffer.append("</" + eName + ">");
-        }
-    }
-
-    public void characters(char[] buf, int offset, int len) throws SAXException {
-        String s = new String(buf, offset, len);
-        s =  replaceAmpersand(s);
-        transformedXmlAsBuffer.append(s);
-    }
-
-    private void setResultInputStream() {
-        this.byteArrayInputStream = new ByteArrayInputStream(transformedXmlAsBuffer.toString().getBytes());
-    }
- 
-    public ByteArrayInputStream getInputStream() {
-        return this.byteArrayInputStream;
-    }
-    
-    /**
-     * this method replaces all occurences of '&' but not '&amp;' with '&amp;'
-     * @param inputString with or without '&'
-     * @return replaced ampersands as string
-     */
-    private String replaceAmpersand(String inputString) {
-        String [] tokens = inputString.split("&amp;");
-        String replacedAmpersand = null;
-        if(inputString.indexOf("&amp;") == -1) {
-            replacedAmpersand = inputString.replaceAll("&", "&amp;");
-        } else {
-            replacedAmpersand = "";
-            for(int i = 0; i < tokens.length; i++) {
-                replacedAmpersand += tokens[i].replaceAll("&", "&amp;") + "&amp;";
-            }
-        }
-        log.debug("[" + inputString + "] replaced with [" + replacedAmpersand + "]");
-        return replacedAmpersand;
-    }
-}

Modified: public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -51,7 +51,7 @@
 import org.wyona.yanel.core.api.attributes.ViewableV1;
 import org.wyona.yanel.core.attributes.viewable.View;
 import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-import org.wyona.yarep.core.NoSuchNodeException;
+import org.wyona.yanel.core.transformation.I18nTransformer;
 import org.wyona.yarep.core.RepositoryException;
 import org.wyona.yarep.core.Repository;
 import org.wyona.yarep.core.RepositoryFactory;
@@ -81,7 +81,7 @@
     private Repository repository  = null;
     private String language = "en";
     //messages is the name of the ResourceBundle
-    private String messages = "messages";
+    private String messages = "nutch";
     private RepoPath rp = null;
 
     /**
@@ -148,12 +148,12 @@
         }
         String _language = language;
         try {
-            _language = request.getParameter("language");
+            _language = request.getParameter("yanel.meta.language");
         } catch(Exception e) {
             //use fallback language
             _language = language;
         }
-        if(_language == null) _language = language;
+        if(_language == null || ("").equals(_language)) _language = language;
         return getView(new Path(request.getServletPath()), viewId, request.getParameter("query"), _start, _hitsPerPage, _language);
     }
 
@@ -181,32 +181,33 @@
         if (searchTerm != null && searchTerm.length() > 0) {
             Element queryElement = (Element) rootElement.appendChild(document.createElementNS(NAME_SPACE, "query"));
             queryElement.appendChild(document.createTextNode(searchTerm));
-        resultsElement = (Element) rootElement.appendChild(document.createElementNS(NAME_SPACE, "results"));
-        resultsElement.setAttributeNS(NAME_SPACE, "start", "" + start);
-        configuration = new Configuration();
+            resultsElement = (Element) rootElement.appendChild(document.createElementNS(NAME_SPACE, "results"));
+            resultsElement.setAttributeNS(NAME_SPACE, "start", "" + start);
+            configuration = new Configuration();
+    
+            try {
+                String confDir = "file:" + rtd.getConfigFile().getParentFile().getAbsolutePath()
+                        + File.separator + "conf";
+                log.debug("Conf Dir: " + confDir);
+                URL defaultResource = new URL(confDir + File.separator + defaultFile);
+                configuration.addDefaultResource(defaultResource);
+                URL finalResource = new URL(confDir + File.separator + localFile);
+                configuration.addFinalResource(finalResource);
+            } catch (MalformedURLException e) {
+                log.error(e.getMessage(), e);
+            }
+    
+            try {
+                crawlDir = new File(configuration.get("searcher.dir"));
+            } catch (Exception e) {
+                log.error(e);
+                exceptionElement = (Element) resultsElement.appendChild(document.createElementNS(NAME_SPACE, "exception"));
+                exceptionElement.appendChild(document.createTextNode(e.getMessage()));
+            }
+    
+            if (crawlDir != null) 
+                createDocument4SearchResult(searchTerm, start, hitsPerPage);
 
-        try {
-            String confDir = "file:" + rtd.getConfigFile().getParentFile().getAbsolutePath()
-                    + File.separator + "conf";
-            log.debug("Conf Dir: " + confDir);
-            URL defaultResource = new URL(confDir + File.separator + defaultFile);
-            configuration.addDefaultResource(defaultResource);
-            URL finalResource = new URL(confDir + File.separator + localFile);
-            configuration.addFinalResource(finalResource);
-        } catch (MalformedURLException e) {
-            log.error(e.getMessage(), e);
-        }
-
-        try {
-            crawlDir = new File(configuration.get("searcher.dir"));
-        } catch (Exception e) {
-            log.error(e);
-            exceptionElement = (Element) resultsElement.appendChild(document.createElementNS(NAME_SPACE, "exception"));
-            exceptionElement.appendChild(document.createTextNode(e.getMessage()));
-        }
-
-        if (crawlDir != null) createDocument4SearchResult(searchTerm, start, hitsPerPage);
-
         } else {
             rootElement.appendChild(document.createElementNS(NAME_SPACE, "no-query"));
         }
@@ -239,8 +240,13 @@
             transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
             byteArrayOutputStream = new ByteArrayOutputStream();
             transformer.transform(new StreamSource(i18nTransformer.getInputStream()), new StreamResult(byteArrayOutputStream));
+ 
+            inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+            i18nTransformer = new I18nTransformer("global", language);
+            saxParser = SAXParserFactory.newInstance().newSAXParser();
+            saxParser.parse(inputStream, i18nTransformer);
             
-            return new java.io.ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+            return i18nTransformer.getInputStream();
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
@@ -276,8 +282,10 @@
         try {
             if (!crawlDir.isDirectory()) {
                 exceptionElement = (Element) resultsElement.appendChild(document.createElementNS(NAME_SPACE, "exception"));
-                exceptionMessage = "No such crawl directory: " + crawlDir;
+                
+                exceptionMessage = "noSuchCrawlDirectory#" + crawlDir;
                 exceptionElement.appendChild(document.createTextNode(exceptionMessage));
+                
                 log.warn(exceptionMessage);
                 return;
             } else {

Added: public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/I18nTransformer.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/I18nTransformer.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/I18nTransformer.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,126 @@
+package org.wyona.yanel.core.transformation;
+
+import java.io.ByteArrayInputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import org.apache.log4j.Category;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class I18nTransformer extends DefaultHandler {
+
+    private static Category log = Category.getInstance(I18nTransformer.class);
+    private Locale currentLocale = null;
+    private ResourceBundle messageBundle = null;
+    private ByteArrayInputStream byteArrayInputStream = null;
+    private StringBuffer transformedXmlAsBuffer = null;
+
+    public I18nTransformer(String messages, String language) {
+        currentLocale = new Locale(language);
+        messageBundle = ResourceBundle.getBundle(messages, currentLocale);
+    }
+
+    public void startDocument() throws SAXException {
+        transformedXmlAsBuffer = new StringBuffer();
+    }
+
+    public void endDocument() throws SAXException {
+        setResultInputStream();
+    }
+
+    public void startElement(String namespaceURI, String localName, String qName, Attributes attrs) throws SAXException {
+        String eName = ("".equals(localName)) ? qName : localName;
+        
+        if ((eName.equals("message")) || (eName.equals("i18n:message"))) {
+            String key = attrs.getValue("key");
+            //String i18nText = messageBundle.getString(key);
+            
+            
+            String i18nText;
+            try {
+                i18nText = messageBundle.getString(key);
+            } catch (Exception e) {
+                log.error("cannot find message for key: " + key);
+                i18nText = key;
+            }
+            
+            
+            log.debug("TAG [key] " + key + " [message]" + i18nText);
+            char[] i18nMessage = i18nText.toCharArray(); 
+            characters(i18nMessage, 0, i18nMessage.length);
+        } else {
+            transformedXmlAsBuffer.append("<" + eName);
+            for(int i = 0; i < attrs.getLength(); i++) {
+                String aName = attrs.getQName(i);
+                String aValue = attrs.getValue(i);
+                if(aValue.indexOf("i18n:attr key=") != -1) {
+                    String key = aValue.substring(14);
+                    //String i18nValue = messageBundle.getString(key);
+                    String i18nValue;
+                    
+                    try {
+                        i18nValue = messageBundle.getString(key);
+                    } catch (Exception e) {
+                        log.error("cannot find message for key: " + key);
+                        i18nValue = key;
+                    }
+                    
+                    aValue = i18nValue;
+                    log.debug("ATTR [key] " + key + " [message]" + i18nValue);
+                }
+                aValue = replaceAmpersand(aValue);
+                transformedXmlAsBuffer.append(" " + aName + "=\"" + aValue + "\"");
+            }
+            transformedXmlAsBuffer.append(">");
+        }
+    }
+
+    public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+        String eName = ("".equals(localName)) ? qName : localName;
+        if ((eName.equals("message")) || (eName.equals("i18n:message"))) {
+            /*ignore these tags*/
+        } else {
+            transformedXmlAsBuffer.append("</" + eName + ">");
+        }
+    }
+
+    public void characters(char[] buf, int offset, int len) throws SAXException {
+        String s = new String(buf, offset, len);
+        s =  replaceAmpersand(s);
+        transformedXmlAsBuffer.append(s);
+    }
+
+    private void setResultInputStream() {
+        try {
+            this.byteArrayInputStream = new ByteArrayInputStream(transformedXmlAsBuffer.toString().getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            log.error(e.getMessage(), e);
+        }
+    }
+ 
+    public ByteArrayInputStream getInputStream() {
+        return this.byteArrayInputStream;
+    }
+    
+    /**
+     * this method replaces all occurences of '&' but not '&amp;' with '&amp;'
+     * @param inputString with or without '&'
+     * @return replaced ampersands as string
+     */
+    private String replaceAmpersand(String inputString) {
+        String [] tokens = inputString.split("&amp;");
+        String replacedAmpersand = null;
+        if(inputString.indexOf("&amp;") == -1) {
+            replacedAmpersand = inputString.replaceAll("&", "&amp;");
+        } else {
+            replacedAmpersand = "";
+            for(int i = 0; i < tokens.length; i++) {
+                replacedAmpersand += tokens[i].replaceAll("&", "&amp;") + "&amp;";
+            }
+        }
+        log.debug("[" + inputString + "] replaced with [" + replacedAmpersand + "]");
+        return replacedAmpersand;
+    }
+}


Property changes on: public/yanel/trunk/src/core/java/org/wyona/yanel/core/transformation/I18nTransformer.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/HttpServletRequestHelper.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/HttpServletRequestHelper.java	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/HttpServletRequestHelper.java	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2006 Wyona
+ *
+ *  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.wyona.org/licenses/APACHE-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.wyona.yanel.core.util;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * TODO:
+ * create Request class which extends javax.servlet.http.HttpServletRequest
+ * and override the getParameter(...) method.
+ *
+ */
+public class HttpServletRequestHelper  {
+    public static String form_encoding = "UTF-8";
+    public static String container_encoding = "ISO-8859-1";
+    
+    public static String getParameter(HttpServletRequest req, String name) {
+        String value = req.getParameter(name);
+        if (form_encoding == null || container_encoding == null || value == null) {
+            return value;
+        }
+        // Form and container encoding are equal, skip expensive value decoding
+        if (container_encoding.equals(form_encoding)) {
+            return value;
+        }
+        return decode(value);
+    }
+
+    private static String decode(String str) {
+        if (str == null) return null;
+        try {
+            if (container_encoding == null)
+                container_encoding = "ISO-8859-1";
+            byte[] bytes = str.getBytes(container_encoding);
+            return new String(bytes, form_encoding);
+        } catch (UnsupportedEncodingException uee) {
+            throw new RuntimeException("Unsupported Encoding Exception", uee);
+        }
+    }
+}


Property changes on: public/yanel/trunk/src/core/java/org/wyona/yanel/core/util/HttpServletRequestHelper.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/realms/yanel-website/content/contact-form/en.xhtml
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/contact-form/en.xhtml	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/realms/yanel-website/content/contact-form/en.xhtml	2006-12-04 15:50:17 UTC (rev 20556)
@@ -1,101 +1,10 @@
 <?xml version="1.0"?>
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <title>Contact</title>
-  </head>
-  
-  <body>
-    <h3>Contact</h3>
-
-    <p>For general inquiries, please use <a href="mailto:contact at wyona.com">contact at wyona.com</a>.</p>
-
-    <p>Mailing addresses can be found on our <a href="http://www.wyona.com/contact.html">corporate contact page</a>.</p>
-<!--
-    <div id="boxBody"> 
-      <strong>Contact</strong>
-      <br/>Wyona AG
-      <br/>Hardstrasse 219
-      <br/>
-      <br/>phone: +41 44 272 91 61 
-      <br/>fax: +41 44 272 91 62 
-      <br/>skype: <a href="callto:wyona-switzerland">wyona-switzerland</a>
-      <br/>email: <a href="mailto:contact at wyona.com">contact at wyona.com</a>
-      <br/>8005
-      <br/>Zürich 
-      <br/>Switzerland 
-    </div>
--->
-    
-<!--
-    <div id="contenBody">
-      
-      <form method="post" action="#">
-        <table cellpadding="0" cellspacing="0" border="0">
-          <tr>
-            <td colspan="2">
-              <h1>Contact</h1>
-              <h2>Please contact us via this form or call us </h2>
-            </td>
-          </tr>
-          <tr>
-            <td colspan="2"></td>
-          </tr>
-          
-          <tr>
-            <td align="right" valign="top" class="contentfield">Company</td>
-            <td>
-              <input type="text" name="company" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">Firstname</td>
-            <td>
-              <input type="text" name="firstName" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">Lastname</td>
-            <td>
-              <input type="text" name="lastName" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">Address</td>
-            <td>
-              <input type="text" name="address" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">ZIP / City</td>
-            <td>
-              <input type="text" name="city" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">E-Mail</td>
-            <td>
-              <input type="text" name="email" class="box" size="40" value=""/>
-            </td>
-          </tr>
-          <tr>
-            <td align="right" valign="top" class="contentfield">Message</td>
-            <td>
-              <textarea rows="8" name="message" cols="30" class="box">&#160;</textarea>
-            </td>
-          </tr>
-          <tr>
-            <td>&#160;
-            </td>
-            <td>
-              <input type="submit" value="send "/>
-            </td>
-          </tr>
-        </table>
-      </form>
-    </div>
--->
-  </body>
-</html>
+<form name="contact-form">
+  <company/>
+  <firstName/>
+  <lastName/>
+  <email required="true"/>
+  <address/>
+  <zipCity/>
+  <message textArea="true"/>
+</form>

Modified: public/yanel/trunk/src/realms/yanel-website/content/documentation/i18n/en.xhtml
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/documentation/i18n/en.xhtml	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/realms/yanel-website/content/documentation/i18n/en.xhtml	2006-12-04 15:50:17 UTC (rev 20556)
@@ -31,7 +31,7 @@
 Assuming you want the following text internationalized:<br/> <tt><b>"Hello World"</b></tt> you would have to replace the Hallo World with a tag <tt><b>&lt;i18n:message key="HelloWorld"&gt;</b></tt> where the key has to be unique within a bundle named messages.<br/>
 </p>
 <p>
-The transformer finds this tag looks in his properties for the selected locale, which is here by default (<b>en</b>)glish if no <tt>request.parameter</tt> name <tt>lang</tt> is given, and replaces the 
+The transformer finds this tag looks in his properties for the selected locale, which is here by default (<b>en</b>)glish if no <tt>request.parameter</tt> name <tt>yanel.meta.language</tt> is given, and replaces the 
 <tt><b>&lt;i18n:message key="HelloWorld"&gt;</b></tt> with the value from <tt>messages_en.properties</tt>. So that the result would be <tt><b>"Hello World"</b></tt>.<br/>
 </p>
 <p>
@@ -39,5 +39,6 @@
 here the transformer will look for a key cancel within the properties and replace it with the selected language. 
 </p>
 
+
 </body>
 </html>
\ No newline at end of file

Modified: public/yanel/trunk/src/realms/yanel-website/content/rtd/contact-form.rtd
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/rtd/contact-form.rtd	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/realms/yanel-website/content/rtd/contact-form.rtd	2006-12-04 15:50:17 UTC (rev 20556)
@@ -1,4 +1,4 @@
-<{http://www.wyona.org/yanel/resource/1.0}xml/>
+<{http://www.wyona.org/yanel/resource/1.0}contact-form/>
 mime-type: application/xhtml+xml
 xslt: /xslt/global.xsl
 
@@ -8,3 +8,4 @@
 #to: contact at localhost
 #smtpHost: localhost
 #smtpPort: 25
+

Added: public/yanel/trunk/src/realms/yanel-website/content/xslt/contact-form.xsl
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/xslt/contact-form.xsl	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/realms/yanel-website/content/xslt/contact-form.xsl	2006-12-04 15:50:17 UTC (rev 20556)
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns="http://www.w3.org/1999/xhtml"
+>
+
+  <xsl:output method="xhtml" encoding="UTF-8"/>
+
+  <xsl:param name="company" select="''"/>
+  <xsl:param name="firstName" select="''"/>
+  <xsl:param name="lastName" select="''"/>
+  <xsl:param name="address" select="''"/>
+  <xsl:param name="zipCity" select="''"/>
+  <xsl:param name="error" select="''"/>
+  <xsl:param name="sent" select="'false'"/>
+
+  <xsl:template match="/">
+    <html xmlns="http://www.w3.org/1999/xhtml">
+      <head>
+        <title><i18n:message key="contact"/></title>
+      </head>
+      
+      <body>
+        <h3><i18n:message key="contact"/></h3>
+        <p><i18n:message key="generalInquiriesPleaseContact"/><a href="mailto:contact at wyona.com">contact at wyona.com</a>.</p>
+        <p><i18n:message key="mailingAddressCanBeFound"/></p>
+        <div id="contenBody">
+        
+          <xsl:choose>
+            <xsl:when test="$error != ''">
+              <xsl:apply-templates select="form" mode="error"/>
+            </xsl:when>
+            <xsl:when test="$sent = 'true'">
+              <xsl:apply-templates select="form" mode="thankYou"/>
+            </xsl:when>
+            <xsl:otherwise>
+               <xsl:apply-templates select="form" mode="init"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        
+        </div>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="form" mode="init">
+    <form name="contact-form" method="post">
+      <table cellpadding="0" cellspacing="0" border="0">
+        <xsl:for-each select="//form">
+          <xsl:variable name="inputName"><xsl:value-of select="."/></xsl:variable>
+          <tr>
+            <td align="right" valign="top" class="contentfield"><i18n:message><xsl:value-of select="$inputName"/></i18n:message>:&#0160;</td>
+            <td>
+            
+              <xsl:choose>
+                <xsl:when test="@textArea = 'true'">
+                   <textarea rows="8" name="{$inputName}" cols="30" class="box"></textarea>
+                </xsl:when>
+                <xsl:otherwise>
+                  <input type="text" name="{$inputName}" class="box" size="40"/>
+                </xsl:otherwise>
+              </xsl:choose>
+              
+            </td>
+            <td><xsl:if test="@required = 'true'">*</xsl:if></td>
+          </tr>
+        </xsl:for-each>
+        <tr>
+          <td colspan="2">&#160;
+          </td>
+          <td>
+            <input type="submit" value="i18n:attr key=send"/>
+          </td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield" colspan="3"><br/><i18n:message key="requiredFields"/></td>
+        </tr>
+      </table>
+    </form>
+  </xsl:template>
+
+  <xsl:template match="form" mode="error">
+    <form name="contact-form" method="post">
+      <table cellpadding="0" cellspacing="0" border="0">
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="company"/>&#0160;</td>
+          <td>
+            <input type="text" name="company" class="box" size="40" value="{$company}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="firstName"/>:&#0160;</td>
+          <td>
+            <input type="text" name="firstName" class="box" size="40" value="{$firstName}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="lastName"/>:&#0160;</td>
+          <td>
+            <input type="text" name="lastName" class="box" size="40" value="{$lastName}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="address"/>:&#0160;</td>
+          <td>
+            <input type="text" name="address" class="box" size="40" value="{$address}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="zipCity"/>:&#0160;</td>
+          <td>
+            <input type="text" name="city" class="box" size="40" value="{$zipCity}"/>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="email"/>:&#0160;</td>
+          <td>
+            <input type="text" name="email" class="box" size="40" value="{$email}"/>
+          </td>
+          <td>*</td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield"><i18n:message key="message"/>:&#0160;</td>
+          <td>
+            <textarea rows="8" name="message" cols="30" class="box"><xsl:value-of select="message"/></textarea>
+          </td>
+          <td></td>
+        </tr>
+        <tr>
+          <td colspan="2">&#160;
+          </td>
+          <td>
+            <input type="submit" value="i18n:attr key=send"/>
+          </td>
+        </tr>
+        <tr>
+          <td align="right" valign="top" class="contentfield" colspan="3"><br/><i18n:message key="requiredFields"/></td>
+        </tr>
+      </table>
+    </form>
+  </xsl:template>
+  
+  <xsl:template match="form" mode="thankYou">
+    <table>
+      <tr>
+        <td align="right" valign="top" class="contentfield"><i18n:message key="thankYou"/></td>
+      </tr>
+    </table>
+  </xsl:template>
+</xsl:stylesheet>


Property changes on: public/yanel/trunk/src/realms/yanel-website/content/xslt/contact-form.xsl
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: public/yanel/trunk/src/realms/yanel-website/content/xslt/global.xsl
===================================================================
--- public/yanel/trunk/src/realms/yanel-website/content/xslt/global.xsl	2006-12-04 15:40:44 UTC (rev 20555)
+++ public/yanel/trunk/src/realms/yanel-website/content/xslt/global.xsl	2006-12-04 15:50:17 UTC (rev 20556)
@@ -1,8 +1,9 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 
 <xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
   xmlns="http://www.w3.org/1999/xhtml"
 >
 
@@ -17,7 +18,7 @@
 <xsl:param name="yanel.back2context" select="'BACK2CONTEXT_IS_NULL'"/>
 <xsl:param name="yarep.back2realm" select="'BACK2REALM_IS_NULL'"/>
 
-<xsl:param name="language" select="'en'"/>
+<xsl:param name="yanel.meta.language" select="'en'"/>
 
 <xsl:variable name="name-without-suffix" select="substring-before($yanel.path.name, '.')"/>
 
@@ -77,8 +78,8 @@
 <tr>
   <td colspan="3" id="footer">
   <p>
-    <font size="-1">Powered by <a href="http://yanel.wyona.org">Wyona Yanel</a>, <a href="https://svn.wyona.org/repos/public/tomcat-cluster/">Wyona Balancer</a>, <a href="http://tomcat.apache.org">Apache Tomcat</a>, <a href="http://httpd.apache.org">Apache HTTP Server</a></font><br/>
-    Copyright &#169; 2006 <a href="http://www.wyona.com">Wyona</a>. All rights reserved. - <a href="?yanel.resource.meta">Page Info</a>
+    <font size="-1"><i18n:message key="poweredBy"/><a href="http://yanel.wyona.org">Wyona Yanel</a>, <a href="https://svn.wyona.org/repos/public/tomcat-cluster/">Wyona Balancer</a>, <a href="http://tomcat.apache.org">Apache Tomcat</a>, <a href="http://httpd.apache.org">Apache HTTP Server</a></font><br/>
+    Copyright &#169; 2006 <a href="http://www.wyona.com">Wyona</a>. <i18n:message key="allRightsReserved"/>. - <a href="?yanel.resource.meta"><i18n:message key="pageInfo"/></a>
   </p>
   </td>
 </tr>
@@ -91,10 +92,10 @@
 
 <xsl:template name="navigation">
 <b>All You Need</b><br/>
-&#160;<a href="{$yarep.back2realm}{$language}/about.html">About</a><br/>
+&#160;<a href="{$yarep.back2realm}{$yanel.meta.language}/about.html">About</a><br/>
 &#160;<a href="{$yarep.back2realm}download.html">Download</a><br/>
 &#160;<a href="{$yarep.back2realm}license.html">License</a><br/>
-&#160;<a href="{$yarep.back2realm}{$language}/getting-started.html">Getting Started</a><br/>
+&#160;<a href="{$yarep.back2realm}{$yanel.meta.language}/getting-started.html">Getting Started</a><br/>
 &#160;Features<br/>
 <!--
 &#160;News<br/>
@@ -119,7 +120,7 @@
 &#160;Solutions<br/>
 &#160;<a href="{$yarep.back2realm}en/contact.html">Contact</a><br/>
 <br/>
-<b>Search</b>
+<b><i18n:message key="search"/></b>
 &#160;<form action="{$yarep.back2realm}en/search.html" method="GET"><input type="text" name="query" class="searchbox" size="14"/></form>
 </xsl:template>
 




More information about the Yanel-commits mailing list