You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by so...@apache.org on 2006/07/09 18:25:44 UTC

svn commit: r420311 [1/2] - in /lenya/branches/revolution/1.3.x/src: java/org/apache/lenya/cms/cocoon/components/source/impl/ java/org/apache/lenya/cms/content/ java/org/apache/lenya/cms/content/flat/ webapp/lenya/modules/edit/ webapp/lenya/modules/fil...

Author: solprovider
Date: Sun Jul  9 09:25:42 2006
New Revision: 420311

URL: http://svn.apache.org/viewvc?rev=420311&view=rev
Log:
Added Edit, Link, and File Modules for editing Flat content.  
Still need editor for XML Resources, and the ability to create a new Resource.

To use (after migrating a Publication to Flat content), browse http://server/pub/edit

Added:
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/resource.xsl   (with props)
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/save.xsl   (with props)
Modified:
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/StringSource.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java
    lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java
    lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/code.js

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/ContentSourceFactory.java Sun Jul  9 09:25:42 2006
@@ -8,6 +8,7 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.StringTokenizer;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceFactory;
@@ -108,16 +109,7 @@
         }catch(org.apache.lenya.cms.publication.PageEnvelopeException pee){
             throw new MalformedURLException("Could not get Publication ID.");
         }
-       // Decide Usage
-       // Content or Meta
-       int requestType = REQUEST_DATA;
-       pos = location.indexOf(":::");
-       if(pos != -1){
-          requestType = REQUEST_INFO;
-       }else{
-          pos = location.indexOf("::");
-          if(pos != -1) requestType = REQUEST_META;
-       }
+
        //Revision
        String revision = "live";
        pos = location.lastIndexOf("!");
@@ -133,50 +125,66 @@
           location = location.substring(0, pos);
        }
 //TODO: Set language to document or publication's default if not specified.
-       int endpos;
+
+//System.out.println("LOC="+location);
+       // Decide Usage
+       StringTokenizer tokens = new StringTokenizer(location, "/:", true);
+       if(!tokens.hasMoreTokens()) throw new MalformedURLException("Nothing specified.");
+       String token = tokens.nextToken();
+       if(location.indexOf(":") > 0) token = tokens.nextToken();  //Remove protocol
+       int colonCount = 0;
+       while(token.equals(":")){
+         colonCount++;
+         token = tokens.nextToken();
+       }
+       int slashCount = 0;
+       while(token.equals("/")){
+         slashCount++;
+         token = tokens.nextToken();
+       }
+       int requestType = colonCount - 1;
+       boolean isFormat2 = false;
+       if(token.equals("DATA")){
+          requestType = REQUEST_DATA;
+          isFormat2 = true;
+       }else if(token.equals("META")){
+          requestType = REQUEST_META;
+          isFormat2 = true;
+       }else if(token.equals("INFO")){
+          requestType = REQUEST_INFO;
+          isFormat2 = true;
+       }
+       if(isFormat2){
+          token = tokens.nextToken();
+          int slashCount2 = 0;
+          while(token.equals("/")){
+             slashCount2++;
+             token = tokens.nextToken();
+          }
+          slashCount = (slashCount > slashCount2 ? slashCount : slashCount2);
+       }
+//System.out.println("SL=" + slashCount + "TOK=" + token);
        String structure = "";
        String unid = "";
        String fullid = "";
-       pos = location.indexOf(":///");
-       if(pos != -1){
-          // content:///parents/resourceID
-          //Guess structure?
-          fullid = location.substring(pos + 4);
-       }else{
-          pos = location.indexOf("://");
-	    if(pos != -1){
-          // content://structure/parents/resourceID
-             pos += 3;
-             endpos = location.indexOf("/", pos);
-             if(endpos > 0){
-                structure = location.substring(pos, endpos);
-                fullid = location.substring(endpos + 1);
-//System.out.println("CSF SF S=" + structure + "  F=" + fullid);
-             }else{
-                structure = location.substring(pos);
-             }
-          }else{
-             //Use UNID
-             // content:/resourceUNID
-             pos = location.indexOf(":/");
-             if(pos != -1){
-                // module:/unid
-                pos += 2;
-                unid = location.substring(pos);
-             }else{
-                // (Default protocol)
-                pos = location.indexOf("/");
-                if(pos != -1){
-                   fullid = location;
-                }else{
-                   unid = location;
-                }
-             }
-          }
+       if(slashCount == 1){
+          if(tokens.hasMoreTokens()){
+             slashCount = 0;
+          }else unid = token;
+       }
+       if((slashCount == 0) || (slashCount == 2)){
+          structure = token;
+       }
+       if((slashCount == 0) || (slashCount == 2)|| (slashCount == 3)){
+          StringBuffer buffer = new StringBuffer();
+          while(tokens.hasMoreTokens()) buffer.append(tokens.nextToken());
+          fullid = buffer.toString();
        }
+       // Convert fullid to unid
        if(unid.length() < 1){
-          unid = content.getUNID(structure, "/" + fullid);
+          unid = content.getUNID(structure, fullid);
        }
+       // Defaults
        if(language.length() < 1){
           Resource resource = content.getResource(unid);
           if(resource != null) language = resource.getDefaultLanguage();

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/StringSource.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/StringSource.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/StringSource.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/cocoon/components/source/impl/StringSource.java Sun Jul  9 09:25:42 2006
@@ -18,8 +18,6 @@
 import org.xml.sax.SAXException;
 import org.apache.avalon.framework.component.ComponentManager;
 import org.apache.avalon.framework.component.ComponentSelector;
-import org.apache.cocoon.serialization.Serializer;
-
 
 /**
  * Creates a Source from a String, Document, Node, or XMLizable.
@@ -73,18 +71,12 @@
            inputStream = new ByteArrayInputStream(temp.getBytes(ENCODING));
         }else{
            // Serialize the SAX events to the XMLSerializer:
-           ComponentSelector serializerSelector = null;
-           Serializer serializer = null;
+           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            try{
-              serializerSelector = (ComponentSelector) manager.lookup(Serializer.ROLE + "Selector");
-              serializer = (Serializer)serializerSelector.select("xml");
-              ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-              serializer.setOutputStream((OutputStream) outputStream );
+org.apache.xml.serialize.OutputFormat format = new org.apache.xml.serialize.OutputFormat("xml", "UTF-8", true);
+org.apache.xml.serialize.XMLSerializer serializer = new org.apache.xml.serialize.XMLSerializer(outputStream, format);
               toSAX( serializer );
-              inputStream = new ByteArrayInputStream( outputStream.toByteArray() );
-           }catch(org.apache.avalon.framework.component.ComponentException ce){
-              exists = false;
-              throw new SourceException("StringSource: ComponentException", ce );
+              inputStream = new ByteArrayInputStream(outputStream.toByteArray());
            }catch(SAXException se){
               exists = false;
               throw new SourceException("Could not serialize to a ByteArray.", se );

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/ResourceTransformer.java Sun Jul  9 09:25:42 2006
@@ -31,13 +31,19 @@
  */
 public class ResourceTransformer extends AbstractDOMTransformer{
     protected org.w3c.dom.Document transform(org.w3c.dom.Document doc){
+System.out.println("ResourceTransformer - BEGIN");
+       String unid = this.source;
        Request request = ObjectModelHelper.getRequest(super.objectModel);
+       return transformDocument(request, unid, doc);
+    }
+    static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc){
        PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
        Publication pub = envelope.getPublication();
        Content content = pub.getContent();
-       String unid = this.source;
        Resource resource = content.getResource(unid);
        resource.update(doc);
+System.out.println("ResourceTransformer - RETURN");
        return doc;
     }
+
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/CreateRevisionTransformer.java Sun Jul  9 09:25:42 2006
@@ -26,6 +26,11 @@
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
+//For userid
+import org.apache.cocoon.environment.Session;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.ac.User;
+
 /**
  * @cocoon.sitemap.component.documentation
  * This transformer creates a new Revision.
@@ -33,122 +38,121 @@
  * It takes the UNID as the src parameter, uses the current language, and create a new Revision
  * It will be enhanced to take "/structure/path/docid" as the src.  That will be easy.  If there is a slash, then convert using Content.getUNID().
  * 
- * Much of the code was modified from org.apache.lenya.cms.cocoon.acting.UploadAction
- * 
  * @author <a href="mailto:solprovider@apache.org">Paul Ercolino</a>
  */
 public class CreateRevisionTransformer extends AbstractDOMTransformer{
-    private static final String SERIALIZER_NAME = "xml";
-    public static final String UPLOADASSET_PARAM_NAME = "properties.asset.data";
-    public static final String UPLOADASSET_PARAM_PREFIX = "properties.asset.";
-    public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
-    public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
-    public static final String CONTENT_PREFIX = "content";
-    public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
-    // optional parameters for meta data according to dublin core
-    public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
+   private static final String SERIALIZER_NAME = "xml";
+   public static final String UPLOADASSET_PARAM_PREFIX = "dc.";
+   public static final String UPLOADASSET_RETURN_FILESIZE = "file-size";
+   public static final String UPLOADASSET_RETURN_MIMETYPE = "mime-type";
+   public static final String CONTENT_PREFIX = "content";
+   public static final String FILE_NAME_REGEXP = "[-a-zA-Z0-9_. ]+";
+   // optional parameters for meta data according to dublin core
+   public static final String[] DUBLIN_CORE_PARAMETERS = { "title", "creator", "subject",
             "description", "publisher", "contributor", "date", "type", "format", "identifier",
             "source", "language", "relation", "coverage", "rights" };
 
-    protected org.w3c.dom.Document transform(org.w3c.dom.Document doc){
-       Request request = ObjectModelHelper.getRequest(super.objectModel);
-       PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
-       Publication pub = envelope.getPublication();
-       Content content = pub.getContent();
-       String unid = this.source;
-       String language = envelope.getDocument().getLanguage();
-       String sourceName = content.getNewURI(unid, language);
-       try{
-           save(sourceName, doc);
-       }catch(java.io.IOException ioe){
-           System.out.println("CreateRevision: IOException");
-       }catch(org.apache.cocoon.ProcessingException pe){
-           System.out.println("CreateRevision: ProcessingException");
-       }catch(org.xml.sax.SAXException saxe){
-           System.out.println("CreateRevision: SAXException");
-       }
-       return doc;
-    }
+   protected org.w3c.dom.Document transform(org.w3c.dom.Document doc){
+      Request request = ObjectModelHelper.getRequest(super.objectModel);
+      createRevision(request, this.source, doc, false);
+      return doc;
+   }
 
-    /**
-     *
-     * @param systemID The name of the revision xml file.
-     * @param doc The data to be inserted.
-     */
-    private void save(String systemID, org.w3c.dom.Document doc)
-    throws SAXException, IOException, ProcessingException {
-        // test parameters
-        if (systemID == null) throw new ProcessingException("createFile: systemID is required.");
-        if (doc == null) throw new ProcessingException("createFile: document is required.");
-        File file = new File(systemID);
-        if(file.exists()){
-System.out.println("Revision '"+systemID+"' already exists.");
-           throw new ProcessingException("Revision '"+systemID+"' already exists.");
-        }
-        String filenameNoExtension = systemID;
-        int pos = systemID.lastIndexOf(".");
-        if(pos > 0) filenameNoExtension = systemID.substring(0, pos);
-//System.out.println("Upload: FNE=" + filenameNoExtension);
-        //Check for file upload from request, Save fileupload.
-        Request request = ObjectModelHelper.getRequest(super.objectModel);
-        File assetFile;
-        // determine if the upload is an asset or a content upload
-        Map dublinCoreParams = getDublinCoreParameters(request);
-        // upload the file to the uploadDir
-        Part part = (Part) request.get(UPLOADASSET_PARAM_NAME);
-        String extension = "";
-        Document metadoc = (Document) null;
-        if(null != part){
-           String filename = part.getFileName();
-           pos = filename.lastIndexOf(".");
-           if(pos > 0) extension = filename.substring(pos);
-System.out.println("Upload: EXT=" + extension);
-           String mimeType = part.getMimeType();
-           dublinCoreParams.put("format", mimeType);
-           int fileSize = part.getSize();
-           dublinCoreParams.put("extent", Integer.toString(fileSize));
-           assetFile = new File(filenameNoExtension + "." + extension);
-           try{
-              saveFileFromPart(assetFile, part);
-           }catch(java.lang.Exception e){
-System.out.println("CreateRevision: Exception saving upload.");
-               throw new ProcessingException("CreateRevision: Exception saving upload.");
-           }
-           try{
-              metadoc = createMetaDocument(dublinCoreParams);
-           }catch(javax.xml.transform.TransformerConfigurationException tce){
-System.out.println("CreateRevision: TransformerConfigurationException creating DC Meta Document.");
-           }catch(javax.xml.transform.TransformerException te){
-System.out.println("CreateRevision: TransformerException creating DC Meta Document.");
-           }catch(javax.xml.parsers.ParserConfigurationException pce){
-System.out.println("CreateRevision: ParserConfigurationException creating DC Meta Document.");
+   static public org.w3c.dom.Document transformDocument(Request request, String unid, org.w3c.dom.Document doc, boolean setLive){
+      createRevision(request, unid, doc, setLive);
+      return doc;
+   }
 
-           }
-        }
-//Upload is saved.
-//doc contains input.
-//metadoc contains DublinCore Document.
-//WORK: Merge documents and store extension.
-        if(null != metadoc){
-            File metaDataFile = new File(filenameNoExtension + ".meta");
+   /**
+    *
+    * @param request The request
+    * @param doc The data to be inserted.
+    */
+   static private void createRevision(Request request, String unid, org.w3c.dom.Document doc, boolean setLive)
+//         throws SAXException, IOException, ProcessingException 
+{
+      if (doc == null){
+System.out.println("CreateRevision: Document is required.");
+//         throw new ProcessingException("CreateRevision: document is required.");
+      }
+      PageEnvelope envelope = (PageEnvelope) request.getAttribute(PageEnvelope.class.getName());
+      Publication pub = envelope.getPublication();
+      Content content = pub.getContent();
+      String language = envelope.getDocument().getLanguage();
+      String newFilename = content.getNewURI(unid, language);
+      if (newFilename == null){
+System.out.println("CreateRevision: Could not get new filename.");
+//         throw new ProcessingException("CreateRevision: Could not get new filename.");
+      }
+      File file = new File(newFilename);
+      if(file.exists()){
+System.out.println("Revision '"+newFilename+"' already exists.");
+//         throw new ProcessingException("Revision '" + newFilename + "' already exists.");
+      }
+      String filenameNoExtension = newFilename;
+      int pos = newFilename.lastIndexOf(".");
+      if(pos > 0) filenameNoExtension = newFilename.substring(0, pos);
+      String revision = (new File(filenameNoExtension)).getName();
+
+      File assetFile;
+      // determine if the upload is an asset or a content upload
+      Map dublinCoreParams = getDublinCoreParameters(request);
+      // upload the file to the uploadDir
+      String extension = "";
+//      Document metadoc = (Document) null;
+      Element root = doc.getDocumentElement();
+      if(root.hasAttribute("filefield")){
+         Part part = (Part) request.get(root.getAttribute("filefield"));
+         if(null != part){
+            String filename = part.getFileName();
+            pos = filename.lastIndexOf(".");
+            if(pos > 0) extension = filename.substring(pos + 1);
+//System.out.println("Upload: EXT=" + extension);
+            String mimeType = part.getMimeType();
+            dublinCoreParams.put("format", mimeType);
+            int fileSize = part.getSize();
+            dublinCoreParams.put("extent", Integer.toString(fileSize));
+            assetFile = new File(filenameNoExtension + "." + extension);
             try{
-               DocumentHelper.writeDocument(metadoc, metaDataFile);
-            }catch(javax.xml.transform.TransformerConfigurationException tce){
-System.out.println("CreateRevision: TransformerConfigurationException saving DC Meta Document.");
-            }catch(javax.xml.transform.TransformerException te){
-System.out.println("CreateRevision: TransformerException saving DC Meta Document.");
+               saveFileFromPart(assetFile, part);
+            }catch(java.lang.Exception e){
+System.out.println("CreateRevision: Exception saving upload.");
             }
-        }
-            try{
-               DocumentHelper.writeDocument(doc, file);
-            }catch(javax.xml.transform.TransformerConfigurationException tce){
+            //Add Meta to doc
+            addMeta(doc, dublinCoreParams);
+         }  // END - part not null
+      }  // END - doc has "file" attribute.
+      //ASSUME: Upload is saved.
+      //Store creator, when, revision and extension.
+      root.setAttribute("revision", revision);
+      String userid = "anonymous";
+      Session session = request.getSession();
+      if(session != null){
+         Identity identity = (Identity) session.getAttribute(Identity.class.getName());
+         if(identity != null){
+            User user = identity.getUser();
+            if(user != null) userid = user.getId();
+         }
+      } 
+      root.setAttribute("creator", userid);
+      root.setAttribute("when", getDateString());
+      if(extension.length() > 0) root.setAttribute("extension", extension);
+      try{
+         DocumentHelper.writeDocument(doc, file);
+      }catch(javax.xml.transform.TransformerConfigurationException tce){
 System.out.println("CreateRevision: TransformerConfigurationException");
-               throw new ProcessingException("CreateRevision: TransformerConfigurationException");
-            }catch(javax.xml.transform.TransformerException te){
+      }catch(javax.xml.transform.TransformerException te){
 System.out.println("CreateRevision: TransformerException");
-               throw new ProcessingException("CreateRevision: TransformerException");
-            }
-    }
+      }catch(java.io.IOException ioe){
+         System.out.println("CreateRevision: IOException writing XML file.");
+      }
+      //Update Translation
+      FlatResource resource = (FlatResource) ((FlatContent)content).getResource(unid, language, "edit");
+      FlatTranslation translation = resource.getTranslation();
+      translation.setEdit(revision);
+      if(setLive) translation.setLive(revision);
+      translation.save();
+   }
 
     /**
      * Saves the asset to a file.
@@ -157,7 +161,7 @@
      * @param part The part of the multipart request.
      * @throws Exception if an error occurs.
      */
-    protected void saveFileFromPart(File assetFile, Part part) throws Exception {
+    static private void saveFileFromPart(File assetFile, Part part) throws Exception {
         if (!assetFile.exists()) {
             boolean created = assetFile.createNewFile();
             if (!created) {
@@ -183,7 +187,7 @@
      * @param request The request.
      * @return A map.
      */
-    protected Map getDublinCoreParameters(Request request) {
+    static private Map getDublinCoreParameters(Request request) {
         HashMap dublinCoreParams = new HashMap();
         for (int i = 0; i < DUBLIN_CORE_PARAMETERS.length; i++) {
             String paramName = DUBLIN_CORE_PARAMETERS[i];
@@ -191,32 +195,23 @@
             if (paramValue == null)  paramValue = "";
             dublinCoreParams.put(paramName, paramValue);
         }
-        Iterator iter = dublinCoreParams.keySet().iterator();
-        while (iter.hasNext()) {
-            String paramName = (String) iter.next();
-            getLogger().debug(paramName + ": " + dublinCoreParams.get(paramName));
-        }
         return dublinCoreParams;
     }
 
-    /**
-     * Create the meta data file given the dublin core parameters.
-     * 
-     * @param dublinCoreParams a <code>Map</code> containing the dublin core values
-     * @throws TransformerConfigurationException if an error occurs.
-     * @throws TransformerException if an error occurs.
-     * @throws ParserConfigurationException if an error occurs.
-     */
-    protected org.w3c.dom.Document createMetaDocument(Map dublinCoreParams)
-            throws TransformerConfigurationException, TransformerException, ParserConfigurationException {
-        NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", "metadata");
-        Element root = helper.getDocument().getDocumentElement();
-        Iterator iter = dublinCoreParams.keySet().iterator();
-        while (iter.hasNext()) {
-            String tagName = (String) iter.next();
-            String tagValue = (String) dublinCoreParams.get(tagName);
-            root.appendChild(helper.createElement(tagName, tagValue));
-        }
-        return helper.getDocument();
-    }
+   static private void addMeta(Document doc, Map dublinCoreParams){
+      NamespaceHelper helper = new NamespaceHelper("http://purl.org/dc/elements/1.1/", "dc", doc);
+      Element root = doc.getDocumentElement();
+// DESIGN CHANGE: No metadata element.
+//      org.w3c.dom.Node meta = root.appendChild(helper.createElement("metadata"));
+      Iterator iter = dublinCoreParams.keySet().iterator();
+      while (iter.hasNext()) {
+         String tagName = (String) iter.next();
+         String tagValue = (String) dublinCoreParams.get(tagName);
+//         meta.appendChild(helper.createElement(tagName, tagValue));
+         root.appendChild(helper.createElement(tagName, tagValue));
+      }
+   }
+   static private String getDateString(){
+      return Long.toString(new java.util.Date().getTime());
+   }
 }

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatContent.java Sun Jul  9 09:25:42 2006
@@ -33,8 +33,7 @@
       return resource.getMetaURI();
    }
    public String getNewURI(String unid, String language){
-
-      Resource resource = getResource(unid, language, "live");
+      Resource resource = getResource(unid, language, "edit");
       return resource.getNewURI();
    }
    public String getUNID(String structure, String id){

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatIndex.java Sun Jul  9 09:25:42 2006
@@ -78,6 +78,7 @@
       return indexFile.getPath();
    }
    public void update(){
+//TODO: Add publication ID to the log.
 System.out.println("Indexer updating " + indexName + "(" + language + ")");
       loadConfiguration();
       // Init Document
@@ -111,7 +112,11 @@
    private void updateStructure(Document document, Element root){
       FlatRelations relations = content.getRelations(structure);
       Element resourceElement = relations.getRoot();
-      addStructureResource(document, root, resourceElement, "", "");
+      if(null == resourceElement){
+         System.out.println("Error creating Index " + indexName + "_" + language + ".  Could not find Structure " + structure);
+      }else{
+         addStructureResource(document, root, resourceElement, "", "");
+      }
    }
 /**
  * Add child "resource" elements of resourceElement to root, and recurse for each.  Must pass filters.

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatResource.java Sun Jul  9 09:25:42 2006
@@ -56,7 +56,7 @@
       }
       pos = unid.lastIndexOf("_");
       if(pos > 0){
-         defaultLanguage = unid.substring(pos);
+         defaultLanguage = unid.substring(pos + 1);
          unid = unid.substring(0, pos);
          useDefaultLanguage = false;
       }
@@ -264,6 +264,7 @@
       return newElement;
    }
    public Document update(Document document){
+System.out.println("FlatResource.update - BEGIN");
       Element root = document.getDocumentElement();
       if(root.hasAttribute("id")) setID(root.getAttribute("id"));
       if(root.hasAttribute("defaultlanguage")) setDefaultLanguage(root.getAttribute("defaultlanguage"));
@@ -278,24 +279,30 @@
          if(translation.hasAttribute("action")){
             String action = translation.getAttribute("action");
             if(action.equalsIgnoreCase("delete")){
+System.out.println("FlatResource.update - Delete Translation");
                deleteTranslation(language);
                exist = false;
             }
          }
+System.out.println("FlatResource.update - Get translation");
          if(exist){
             ft = getTranslation(language, false);
             if(null == ft) exist = false;
          }
+System.out.println("FlatResource.update - Update Translation");
          if(exist){
             if(translation.hasAttribute("live")) ft.setLive(translation.getAttribute("live"));
             if(translation.hasAttribute("edit")) ft.setEdit(translation.getAttribute("edit"));
             NodeList revisions = translation.getElementsByTagName("revision");
             int revisionslength = revisions.getLength();
             for(int r = 0; r < revisionslength; r++){
-              Element revision = (Element) revisions.item(t);
+System.out.println("FlatResource.update - BEFORE");
+              Element revision = (Element) revisions.item(r);
+System.out.println("FlatResource.update - AFTER");
               if(revision.hasAttribute("action")){
                  String action = revision.getAttribute("action");
                  if(action.equalsIgnoreCase("delete")){
+System.out.println("FlatResource.update - Delete Revision");
                     String revisionid = revision.getAttribute("revision");
                     ft.deleteRevision(revisionid);
                   }
@@ -304,6 +311,7 @@
             ft.save();
          }
       }
+System.out.println("FlatResource.update - RETURN");
       return document;
    }
    private void setID(String newid){
@@ -320,8 +328,17 @@
    }
    private void deleteTranslation(String language){
       File translationDirectory = new File(resourceDirectory, language);
+System.out.println("DELETE=" + translationDirectory.getAbsolutePath());
+      deleteFile(translationDirectory);
+   }
 //TODO: Backup before delete.  Use renameTo() to move outside the resource directory.
-      translationDirectory.delete();
+   private void deleteFile(File file){
+      if(!file.exists()) return;
+      if(file.isDirectory()){
+         File[] files = file.listFiles();
+         for(int f = 0; f < files.length; f++) deleteFile(files[f]);
+      }
+      file.delete();
    }
    private void save(){
       if(isChanged){

Modified: lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java (original)
+++ lenya/branches/revolution/1.3.x/src/java/org/apache/lenya/cms/content/flat/FlatTranslation.java Sun Jul  9 09:25:42 2006
@@ -49,17 +49,31 @@
       translationDirectory = new File(resourceDirectory, language);
       if(!translationDirectory.exists()) translationDirectory = new File(resourceDirectory, defaultLanguage);
       if(!translationDirectory.exists()) return;
-      try{
-         document = DocumentHelper.readDocument(new File(translationDirectory, "translation.xml"));
+      File translationFile = new File(translationDirectory, "translation.xml");
+      if(translationFile.exists()){
+         try{
+            document = DocumentHelper.readDocument(translationFile);
+            root = document.getDocumentElement();
+            if(root.hasAttribute("live")) live = root.getAttribute("live");
+            if(root.hasAttribute("edit")) edit = root.getAttribute("edit");
+         }catch(javax.xml.parsers.ParserConfigurationException pce){
+System.out.println("FlatTranslation - ParserConfigurationException: " + translationFile.getAbsolutePath());
+         }catch(org.xml.sax.SAXException saxe){
+System.out.println("FlatTranslation - SAXException: " + translationFile.getAbsolutePath());
+         }catch(java.io.IOException ioe){
+System.out.println("FlatTranslation - IOException: " + translationFile.getAbsolutePath());
+         }
+      }else{
+         try{
+            document = DocumentHelper.createDocument("", "translation", null);
+         }catch(javax.xml.parsers.ParserConfigurationException pce){
+System.out.println("New FlatTranslation - ParserConfigurationException:" + translationFile.getAbsolutePath());
+            return;
+         }
+
          root = document.getDocumentElement();
-         if(root.hasAttribute("live")) live = root.getAttribute("live");
-         if(root.hasAttribute("edit")) edit = root.getAttribute("edit");
-      }catch(javax.xml.parsers.ParserConfigurationException pce){
-System.out.println("FlatTranslation: ParserConfigurationException");
-      }catch(org.xml.sax.SAXException saxe){
-System.out.println("FlatTranslation: SAXException");
-      }catch(java.io.IOException ioe){
-System.out.println("FlatTranslation: IOException");
+         root.setAttribute("language", language);
+         isChanged = true;
       }
    }
    public String[] getRevisions() {
@@ -141,6 +155,7 @@
    void save(){
       if(isChanged){
          File file = new File(translationDirectory, "translation.xml");
+/*
          Document doc;
          try{
             doc = DocumentHelper.readDocument(file);
@@ -155,10 +170,12 @@
             return;
          }
          root = doc.getDocumentElement();
+*/
          root.setAttribute("live", live);
          root.setAttribute("edit", edit);
          try{
-            DocumentHelper.writeDocument(doc, file);
+//            DocumentHelper.writeDocument(doc, file);
+            DocumentHelper.writeDocument(document, file);
          }catch(javax.xml.transform.TransformerConfigurationException tce){
 System.out.println("FlatTranslation.save - TransformerConfigurationException:" + file.getAbsolutePath());
          }catch(javax.xml.transform.TransformerException te){

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl Sun Jul  9 09:25:42 2006
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0" 
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:dcterms="http://purl.org/dc/terms/"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    exclude-result-prefixes="page xhtml"
+>
+
+<xsl:param name="publication"/>
+<xsl:param name="module"/>
+<xsl:param name="publicationname"/>
+<xsl:param name="publicationlanguages"/>
+<xsl:variable name="language"><xsl:value-of select="/index/@language"/></xsl:variable>
+
+<xsl:template match="/index">
+  <html>
+    <head>
+      <title><xsl:value-of select="$publication"/>&#160;<i18n:text>Resources</i18n:text></title>
+    </head>	
+    <body>
+<h1><xsl:value-of select="$publication"/>&#160;<i18n:text>Resources</i18n:text></h1>
+<table border="1">
+<tr>
+<th><i18n:text>UNID</i18n:text></th>
+<th><i18n:text>Type</i18n:text></th>
+<th><i18n:text>ID</i18n:text></th>
+</tr>
+<xsl:apply-templates select="resource"/>
+</table></body></html>
+</xsl:template>
+
+<xsl:template match="resource">
+<tr><td><xsl:element name="a">
+<xsl:attribute name="href">/<xsl:value-of select="$publication"/>/<xsl:value-of select="$module"/>/<xsl:value-of select="@unid"/></xsl:attribute><xsl:value-of select="@unid"/></xsl:element></td>
+<td><xsl:value-of select="@type"/><xsl:if test="@doctype">/<xsl:value-of select="@doctype"/></xsl:if></td>
+<td><xsl:value-of select="@id"/></td>
+</tr>
+</xsl:template>
+
+<!-- OBSOLETE
+<xsl:template match="resource">
+<tr><td><xsl:element name="a">
+<xsl:attribute name="href">/<xsl:value-of select="$publication"/>/<xsl:value-of select="$module"/>/<xsl:value-of select="@type"/><xsl:if test="@doctype">/<xsl:value-of select="@doctype"/></xsl:if>/<xsl:value-of select="@unid"/></xsl:attribute><xsl:value-of select="@unid"/></xsl:element></td>
+<td><xsl:value-of select="@id"/></td>
+<td><xsl:value-of select="@title"/></td>
+</tr>
+</xsl:template>
+-->
+
+</xsl:stylesheet> 

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/all.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html Sun Jul  9 09:25:42 2006
@@ -0,0 +1,9 @@
+<HTML>
+<HEAD>
+<TITLE>Error</TITLE>
+</HEAD>
+<BODY>
+<H1>Error</H1>
+The Edit Module cannot be used with Hierarchical Content.  The Authoring Module is intended for Hierarchical Content, but it was not found.  If the Content is Flat (such as after using the "flat" migration Module), please change the content setting in {pub}/config/publication.xconf, and then restart Lenya to build the Indexes.
+</BODY>
+</HTML>
\ No newline at end of file

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/hierarchical.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap Sun Jul  9 09:25:42 2006
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Edit Module -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+   <map:resources>
+      <map:resource name="all">
+         <map:select type="parameter">
+            <map:parameter name="parameter-selector-test" value="{publication:contenttype}"/>
+            <map:when test="flat">
+               <map:generate type="sitetree" src="all"/>
+               <map:transform src="module:///all.xsl">
+                  <map:parameter name="publication" value="{publication:publication}"/>
+                  <map:parameter name="module" value="{module:module}"/>
+                  <map:parameter name="publicationname" value="{publication:name}"/>
+                  <map:parameter name="publicationlanguages" value="{publication:languages}"/>
+               </map:transform>
+               <map:transform type="i18n"/>           
+               <map:serialize type="html"/>
+            </map:when>
+            <map:otherwise>
+               <map:act type="resource-exists" src="module://authoring/module.xmap">
+                  <map:redirect-to uri="/{publication:publication}/authoring"/>
+               </map:act>
+            </map:otherwise>
+         </map:select>
+         <map:generate src="module:///hierarchical.html"/> 
+         <map:serialize type="html"/>
+      </map:resource>
+   </map:resources>
+  <!-- =========================== Pipelines ================================ -->
+   <map:pipelines>
+      <map:pipeline>
+         <map:match pattern="**">
+            <!-- module/unid -->
+<!-- Request does not specify anything after the slash -->
+            <map:match pattern="{module:module}/">
+               <map:call resource="all"/>
+            </map:match>
+<!-- Resource -->
+            <map:match pattern="{module:module}/*">
+               <map:act type="resource-exists" src="module://{content:type:{1}}/edit.xmap">
+                  <map:mount uri-prefix="" src="module://{content:type:{../1}}/edit.xmap"/> 
+                  <map:serialize type="html"/>
+               </map:act>
+               <map:aggregate element="content">
+                  <map:part src="content:::/{1}"/>
+                  <map:part src="content::/{1}"/>
+               </map:aggregate>
+               <map:transform src="module:///resource.xsl">
+                  <map:parameter name="module" value="{module:module}"/>
+                  <map:parameter name="publication" value="{publication:publication}"/>
+                  <map:parameter name="publicationname" value="{publication:name}"/>
+                  <map:parameter name="type" value="{content:type:{1}}"/>
+               </map:transform>
+               <map:transform type="i18n"/>
+               <map:serialize type="html"/>
+            </map:match>
+<!-- Default = Show list of all Resources -->
+            <map:call resource="all"/>
+         </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml Sun Jul  9 09:25:42 2006
@@ -0,0 +1,6 @@
+<module id="edit" name="Edit">
+<version>Flat</version>
+<description>PageModule for editing Resources.</description>
+<usage>
+</usage>
+</module>
\ No newline at end of file

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/module.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl Sun Jul  9 09:25:42 2006
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0" 
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:dcterms="http://purl.org/dc/terms/"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    exclude-result-prefixes="page xhtml"
+>
+
+<xsl:param name="publication"/>
+<xsl:param name="publicationname"/>
+<xsl:param name="module"/>
+<xsl:param name="type"/>
+
+<xsl:template match="/content">
+  <html><head>
+  <xsl:apply-templates select="resource" mode="head"/>
+  </head><body> 
+<xsl:apply-templates/>
+   </body></html>
+</xsl:template>
+
+<xsl:template match="resource" mode="head">
+<title><xsl:value-of select="$publicationname"/>&#160;<i18n:text>Resource</i18n:text>&#160;<xsl:value-of select="@unid"/></title>
+</xsl:template>
+
+<xsl:template match="resource">
+<h1><xsl:value-of select="$publicationname"/>&#160;<i18n:text>Resource</i18n:text>&#160;<xsl:value-of select="@unid"/></h1>
+<table border="1">
+<tr>
+<th><i18n:text>ID</i18n:text></th>
+<th><i18n:text>Type</i18n:text></th>
+<xsl:if test="@doctype"><th><i18n:text>DocumentType</i18n:text></th></xsl:if>
+</tr>
+<tr>
+<td><xsl:value-of select="@type"/></td>
+<td><xsl:value-of select="@id"/></td>
+<xsl:if test="@doctype"><td colspan="2"><xsl:value-of select="@doctype"/></td></xsl:if>
+</tr>
+<xsl:apply-templates select="translation"/>
+</table><br/>
+</xsl:template>
+
+<xsl:template match="translation">
+<tr><td colspan="3"><i18n:text>Translation</i18n:text>&#160;<xsl:value-of select="@language"/>
+<xsl:if test="@language = ../@defaultlanguage">&#160;(Default)</xsl:if></td>
+</tr>
+<xsl:apply-templates select="revision"/>
+</xsl:template>
+
+<xsl:template match="revision">
+<tr><td>
+<xsl:element name="a">
+<xsl:attribute name="href">/<xsl:value-of select="$publication"/>/<xsl:value-of select="$module"/>/<xsl:value-of select="../../@unid"/>_<xsl:value-of select="../@language"/>!<xsl:value-of select="@revision"/></xsl:attribute><xsl:value-of select="@revision"/></xsl:element>
+<xsl:if test="@revision = ../@live">&#160;LIVE</xsl:if>
+<xsl:if test="@revision = ../@edit">&#160;EDIT</xsl:if>
+</td>
+<td>
+<xsl:if test="@extension"><xsl:value-of select="@extension"/></xsl:if>
+<xsl:if test="@href"><xsl:value-of select="@href"/></xsl:if></td>
+<td><xsl:value-of select="@title"/></td>
+</tr>
+</xsl:template>
+
+<!-- Copy -->
+<xsl:template match="@*|node()" priority="-1">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/edit/resource.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js Sun Jul  9 09:25:42 2006
@@ -0,0 +1,71 @@
+var manager = Packages.org.apache.cocoon.components.CocoonComponentManager.getSitemapComponentManager();
+
+function update(){
+   var publication = cocoon.parameters.publication;
+   var module = cocoon.parameters.module;
+   var unid = cocoon.parameters.unid;
+
+   var flowHelper = new Packages.org.apache.lenya.cms.cocoon.flow.FlowHelper();
+   var documentHelper = flowHelper.getDocumentHelper(cocoon);
+   var pageEnvelope = flowHelper.getPageEnvelope(cocoon);
+   var pub = pageEnvelope.getPublication();
+   var content = pub.getContent();
+   var resource = content.getResource(unid);
+   //Input
+print("####### FILE UPDATE BEGIN #######");
+   var dom = loadDocument("cocoon:/" + module + "/savedata/" + unid);
+   var root = dom.getDocumentElement();
+print("ROOT=" + root.getTagName());
+   var child = root.getFirstChild();
+   while(child != null){
+      var childtag = child.getNodeName();
+      if(childtag.equalsIgnoreCase("resource")){
+         var doc = convertNodeToDocument(child);
+         Packages.org.apache.lenya.cms.content.ResourceTransformer.transformDocument(cocoon.request, unid, doc);
+      }
+      if(childtag.equalsIgnoreCase("revision")){
+         var language = child.getAttribute("language");
+         var setLive = false;
+         if(child.hasAttribute("live")){
+            if(child.getAttribute("live").equalsIgnoreCase("true")) setLive = true;
+         }
+         var revision = child.getFirstChild();
+         var doc = convertNodeToDocument(revision);
+         Packages.org.apache.lenya.cms.content.flat.CreateRevisionTransformer.transformDocument(cocoon.request, unid + "_" + language, doc, setLive);
+      }
+      child = child.getNextSibling();
+   }
+   cocoon.sendPage("edit/" + unid);
+}
+
+
+function convertNodeToDocument(node){
+   var factory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+   var builder = factory.newDocumentBuilder();
+   var doc = builder.newDocument();
+   doc.appendChild(doc.importNode(node, true));
+   return doc;
+}
+
+
+/**
+ * loadDocument() reads in an XML file and returns a DOM Document.
+**/
+function loadDocument(uri) {
+  var parser = null;
+  var source = null;
+  var resolver = null;
+  try {
+      parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+      resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+      source = resolver.resolveURI(uri);
+      var stream = source.getInputStream();
+      var is = new Packages.org.xml.sax.InputSource(stream);
+      is.setSystemId(source.getURI());
+      return parser.parseDocument(is);
+  } finally {
+      if (source != null) resolver.release(source);
+      if (parser != null) cocoon.releaseComponent(parser);
+      if (resolver != null) cocoon.releaseComponent(resolver);
+  }
+}

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/code.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css Sun Jul  9 09:25:42 2006
@@ -0,0 +1,39 @@
+/* Header Menu */
+body {
+   font-family: Tahoma, Verdana, sans-serif;
+   background-color: #EEFFEE;
+}
+
+h1 {  padding: 0px 0px 0px 0px; }
+
+table {
+   padding: 1 1 1 1px;
+   border: solid 0px #336633;
+   background-color: #EEFFEE;
+   border-collapse: collapse;
+   border-color: #669966;
+   width: auto;
+}
+
+th{
+    font-size: 80%;
+    padding: 3px;
+    background-color: #EEFFEE;
+   border: solid 1px #336633;
+    vertical-align: center;
+}
+
+td{
+    font-size: 80%;
+    padding: 3px;
+    background-color: #EEFFEE;
+   border: solid 1px #336633;
+    vertical-align: center;
+}
+.spacer{
+   border: solid 0px #336633;
+}
+.dark{
+    background-color: #DDEEDD;
+}
+

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap Sun Jul  9 09:25:42 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Link Module: Edit -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <!-- =========================== Pipelines ================================ -->
+   <map:pipelines>
+      <map:pipeline>
+<!-- Remove Revision -->
+            <map:match pattern="edit/*!*">
+               <map:generate src="cocoon:/edit/{1}"/>
+               <map:serialize type="html"/>
+            </map:match>
+<!-- Show Resource -->
+            <map:match pattern="edit/*">
+               <map:aggregate element="content">
+                  <map:part src="content:::/{1}!edit"/>
+               </map:aggregate>
+               <map:transform src="module:///resource.xsl">
+                  <map:parameter name="module" value="{module:module}"/>
+                  <map:parameter name="publication" value="{publication:publication}"/>
+                  <map:parameter name="publicationname" value="{publication:name}"/>
+                  <map:parameter name="languages" value="{publication:languages}"/>
+               </map:transform>
+               <map:transform type="i18n"/>
+               <map:serialize type="html"/>
+            </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/edit.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap Sun Jul  9 09:25:42 2006
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Link Module -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:flow language="javascript">
+     <map:script src="module:///code.js"/>
+  </map:flow>
+   <map:pipelines>
+      <map:pipeline type="noncaching">
+         <map:match pattern="{module:module}/*.css">
+            <map:read src="module:///{1}.css" mime-type="text/css"/>
+         </map:match>
+         <map:match pattern="formdata">
+            <map:generate type="serverpages" src="module://form/post.xsp"/>
+            <map:serialize type="xml"/>
+         </map:match>
+         <map:match pattern="{module:module}/save/*">
+            <map:call function="update">
+             <map:parameter name="publication" value="{page-envelope:publication-id}"/>
+             <map:parameter name="module" value="{module:module}"/>
+             <map:parameter name="unid" value="{1}"/>
+           </map:call>
+         </map:match>
+         <map:match pattern="{module:module}/savedata/*">
+            <map:aggregate element="save">
+               <map:part src="content:/INFO/{1}!edit"/>
+               <map:part src="cocoon:/formdata"/>
+            </map:aggregate>
+            <map:transform src="module:///save.xsl">
+               <map:parameter name="unid" value="{1}"/>
+            </map:transform>
+            <map:serialize type="xml"/>
+         </map:match>
+         <map:match pattern="edit/*">
+            <map:act type="resource-exists" src="module://edit/module.xmap">
+               <map:redirect-to uri="/{publication:publication}/edit/{../1}"/>
+            </map:act>
+            <map:mount uri-prefix="" src="module:///edit.xmap"/> 
+            <map:serialize type="html"/>
+         </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/module.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl Sun Jul  9 09:25:42 2006
@@ -0,0 +1,308 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:page="http://apache.org/cocoon/lenya/cms-page/1.0"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0" 
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:dcterms="http://purl.org/dc/terms/"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    exclude-result-prefixes="page xhtml"
+>
+
+<xsl:param name="module"/>
+<xsl:param name="publication"/>
+<xsl:param name="publicationname"/>
+<xsl:param name="languages"/>
+
+<xsl:template match="/content">
+  <html><head>
+  <xsl:apply-templates select="resource" mode="head"/>
+  </head><body>
+<xsl:apply-templates/>
+   </body></html>
+</xsl:template>
+
+
+<xsl:template match="resource" mode="head">
+<link rel="stylesheet" href="/{$publication}/{$module}/edit.css" type="text/css"/>
+<title><xsl:value-of select="$publicationname"/>&#160;<i18n:text>Resource</i18n:text>&#160;<xsl:value-of select="@unid"/></title>
+</xsl:template>
+
+
+<xsl:template match="resource">
+<h1><xsl:value-of select="$publicationname"/>&#160;<i18n:text>File</i18n:text>&#160;<i18n:text>Resource</i18n:text>&#160;<xsl:value-of select="@unid"/></h1>
+<form method="post" action="/{$publication}/{$module}/save/{@unid}" enctype="multipart/form-data">
+<table>
+<!-- Resource Info -->
+<tr>
+<th colspan="3"><i18n:text>ID</i18n:text></th>
+<td colspan="3"><xsl:value-of select="@id"/></td>
+<td colspan="2" class="dark">
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name">defaultlanguage</xsl:attribute>
+<xsl:attribute name="value"></xsl:attribute>
+<xsl:if test="string-length(@defaultlanguage) &lt; 1"><xsl:attribute name="checked"/></xsl:if>
+</xsl:element><i18n:text>No Default Language</i18n:text>
+</td>
+</tr>
+<tr>
+<th colspan="3"><i18n:text>Change ID to</i18n:text></th>
+<td colspan="5">
+[Not implemented yet]
+<!-- TODO: Must update Structures in FlatResource.setID()
+<xsl:element name="input">
+<xsl:attribute name="type">text</xsl:attribute>
+<xsl:attribute name="name">new.id</xsl:attribute>
+<xsl:attribute name="size">60</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="@id"/></xsl:attribute>
+</xsl:element>
+-->
+</td>
+</tr>
+<!-- Spacer -->
+<tr><td colspan="8" class="spacer">&#160;</td></tr>
+<!-- Column Headers -->
+<xsl:if test="translation">
+<tr>
+<xsl:if test="@doctype"><td colspan="2"><xsl:value-of select="@doctype"/></td></xsl:if>
+</tr>
+<tr>
+<th class="dark"><i18n:text>Delete</i18n:text></th>
+<th><i18n:text>Live</i18n:text></th>
+<th><i18n:text>Edit</i18n:text></th>
+<th><i18n:text>Extension</i18n:text></th>
+<th><i18n:text>Title</i18n:text></th>
+<th><i18n:text>Creator</i18n:text></th>
+<th><i18n:text>When</i18n:text></th>
+<th><i18n:text>Revision</i18n:text></th>
+</tr>
+</xsl:if>
+<!-- Translations -->
+<xsl:apply-templates select="translation"/>
+<!-- Spacer -->
+<tr><td colspan="8" class="spacer">&#160;</td></tr>
+
+<!-- New Translation -->
+<xsl:variable name="languageoptionstest"><xsl:call-template name="languageoptionstest"/></xsl:variable>
+<xsl:if test="string-length($languageoptionstest) &gt; 0">
+<tr>
+<th colspan="2" rowspan="3" class="spacer"><i18n:text>New</i18n:text><br/><i18n:text>Translation</i18n:text></th>
+<th><i18n:text>Language</i18n:text></th>
+<td colspan="3">
+<xsl:element name="SELECT">
+<xsl:attribute name="name">new.language</xsl:attribute>
+<OPTION VALUE=""><i18n:text>None</i18n:text></OPTION>
+<xsl:call-template name="languageoptions"/>
+</xsl:element>
+</td>
+<td colspan="2" class="dark">
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name">defaultlanguage</xsl:attribute>
+<xsl:attribute name="value">new</xsl:attribute>
+</xsl:element><i18n:text>Default Language</i18n:text>
+</td>
+</tr>
+
+<tr>
+<th><i18n:text>File</i18n:text></th>
+<td colspan="5">
+<xsl:element name="input">
+<xsl:attribute name="type">file</xsl:attribute>
+<xsl:attribute name="name">new.file</xsl:attribute>
+<xsl:attribute name="size">50</xsl:attribute>
+</xsl:element>
+</td>
+</tr>
+<tr>
+<th><i18n:text>Title</i18n:text></th>
+<td colspan="5">
+<xsl:element name="input">
+<xsl:attribute name="type">text</xsl:attribute>
+<xsl:attribute name="name">new.title</xsl:attribute>
+<xsl:attribute name="size">60</xsl:attribute>
+</xsl:element>
+</td>
+</tr>
+</xsl:if>
+<!-- Finish -->
+<tr><td colspan="8" class="spacer">&#160;</td></tr>
+<tr><th colspan="8" class="spacer"><input type="submit" value="Save" i18n:attribute="value"/></th></tr>
+</table>
+</form>
+<br/>
+</xsl:template>
+
+
+<xsl:template match="translation">
+<xsl:variable name="edit"><xsl:value-of select="@edit"/></xsl:variable>
+<!-- Spacer -->
+<tr><td colspan="8" class="spacer">&#160;</td></tr>
+<!-- Header -->
+<tr>
+<td class="dark">
+<xsl:if test="@language != ../@defaultlanguage">
+<xsl:element name="input">
+<xsl:attribute name="type">checkbox</xsl:attribute>
+<xsl:attribute name="name">delete</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="@language"/></xsl:attribute>
+</xsl:element>
+</xsl:if>
+</td>
+<td>
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="@language"/>.live</xsl:attribute>
+<xsl:attribute name="value"/>
+<xsl:if test="string-length(@live) &lt; 1"><xsl:attribute name="checked"/></xsl:if>
+</xsl:element>
+</td>
+<th colspan="4"><i18n:text>Translation</i18n:text>&#160;<xsl:value-of select="@language"/></th>
+<td colspan="2" class="dark">
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name">defaultlanguage</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="@language"/></xsl:attribute>
+<xsl:if test="@language = ../@defaultlanguage"><xsl:attribute name="checked"/></xsl:if>
+</xsl:element><i18n:text>Default Language</i18n:text>
+</td>
+</tr>
+<!-- Revisions -->
+<xsl:apply-templates select="revision"/>
+<!-- New Revision -->
+<tr>
+<th rowspan="2"><i18n:text>New</i18n:text></th>
+<td rowspan="2">
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="@language"/>.live</xsl:attribute>
+<xsl:attribute name="value">new</xsl:attribute>
+</xsl:element>
+</td>
+
+<th><i18n:text>File</i18n:text></th>
+<td colspan="5">
+<xsl:element name="input">
+<xsl:attribute name="type">file</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="@language"/>.file</xsl:attribute>
+<xsl:attribute name="size">50</xsl:attribute>
+</xsl:element>
+</td>
+</tr>
+<tr>
+<th><i18n:text>Title</i18n:text></th>
+<td colspan="5">
+<xsl:element name="input">
+<xsl:attribute name="type">text</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="@language"/>.title</xsl:attribute>
+<xsl:attribute name="size">60</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="revision[@revision= $edit]/@title"/></xsl:attribute>
+</xsl:element>
+</td>
+</tr>
+</xsl:template>
+
+
+<xsl:template match="revision">
+<tr>
+<td class="dark">
+<xsl:if test="(@revision != ../@live) and (@revision != ../@edit)">
+<xsl:element name="input">
+<xsl:attribute name="type">checkbox</xsl:attribute>
+<xsl:attribute name="name">delete</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="../@language"/>.<xsl:value-of select="@revision"/></xsl:attribute>
+</xsl:element>
+</xsl:if>
+</td>
+
+<td>
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="../@language"/>.live</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="@revision"/></xsl:attribute>
+<xsl:if test="@revision = ../@live"><xsl:attribute name="checked"/></xsl:if>
+</xsl:element>
+</td>
+
+<td>
+<xsl:element name="input">
+<xsl:attribute name="type">radio</xsl:attribute>
+<xsl:attribute name="name"><xsl:value-of select="../@language"/>.edit</xsl:attribute>
+<xsl:attribute name="value"><xsl:value-of select="@revision"/></xsl:attribute>
+<xsl:if test="@revision = ../@edit"><xsl:attribute name="checked"/></xsl:if>
+</xsl:element>
+</td>
+
+<td>
+<xsl:value-of select="@extension"/></td>
+<td><xsl:value-of select="@title"/></td>
+<td><xsl:value-of select="@creator"/></td>
+<td><xsl:value-of select="@when"/></td>
+<td><xsl:value-of select="@revision"/></td>
+</tr>
+</xsl:template>
+
+
+<xsl:template name="languageoption">
+<xsl:param name="lang"/>
+<xsl:if test="not(/content/resource/translation[@language = $lang])">
+<option value="{$lang}"><i18n:text key="language-{$lang}"><xsl:value-of select="$lang"/></i18n:text></option>
+</xsl:if>
+</xsl:template>
+
+<xsl:template name="languageoptions">
+<xsl:param name="langs" select="$languages"/>
+<xsl:variable name="more"><xsl:value-of select="substring-after($langs,';')"/></xsl:variable>
+<xsl:choose>
+<xsl:when test="string-length($more) &gt; 0">
+<xsl:call-template name="languageoption">
+   <xsl:with-param name="lang" select="substring-before($langs,';')"/>
+</xsl:call-template>
+<xsl:call-template name="languageoptions">
+   <xsl:with-param name="langs" select="$more"/>
+</xsl:call-template>
+</xsl:when>
+<xsl:otherwise>
+<xsl:call-template name="languageoption">
+   <xsl:with-param name="lang" select="$langs"/>
+</xsl:call-template>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<xsl:template name="languagetest">
+<xsl:param name="language"/>
+<xsl:if test="not(/content/resource/translation[@language = $language])"><xsl:value-of select="$language"/></xsl:if>
+</xsl:template>
+
+<xsl:template name="languageoptionstest">
+<xsl:param name="langs" select="$languages"/>
+<xsl:variable name="more"><xsl:value-of select="substring-after($langs,';')"/></xsl:variable>
+<xsl:choose>
+<xsl:when test="string-length($more) &gt; 0">
+<xsl:call-template name="languagetest">
+   <xsl:with-param name="langs" select="substring-before($langs,';')"/>
+</xsl:call-template>
+<xsl:call-template name="languageoptionstest">
+   <xsl:with-param name="langs" select="$more"/>
+</xsl:call-template>
+</xsl:when>
+<xsl:otherwise>
+<xsl:call-template name="languagetest">
+   <xsl:with-param name="language" select="$langs"/>
+</xsl:call-template>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:template>
+
+<!-- Copy -->
+<xsl:template match="@*|node()" priority="-1">
+  <xsl:copy>
+    <xsl:apply-templates select="@*|node()"/>
+  </xsl:copy>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/resource.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl Sun Jul  9 09:25:42 2006
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0" 
+>
+
+<xsl:param name="unid"/>
+
+<xsl:template match="/save">
+<save>
+<xsl:attribute name="unid"><xsl:value-of select="$unid"/></xsl:attribute>
+<xsl:apply-templates select="resource"/>
+</save>
+</xsl:template>
+
+<xsl:template match="resource">
+<xsl:variable name="newid"><xsl:value-of select="/save/form/field[@name='new.id']"/></xsl:variable>
+<xsl:variable name="newdefaultlanguage"><xsl:value-of select="/save/form/field[@name='defaultlanguage']"/></xsl:variable>
+<xsl:element name="resource">
+<xsl:if test="@id != $newid"><xsl:attribute name="id"><xsl:value-of select="$newid"/></xsl:attribute></xsl:if>
+<xsl:if test="@defaultlanguage != $newdefaultlanguage"><xsl:attribute name="defaultlanguage"><xsl:value-of select="$newdefaultlanguage"/></xsl:attribute></xsl:if>
+<xsl:apply-templates select="translation" mode="info"/>
+</xsl:element>
+<xsl:apply-templates select="translation" mode="new"/>
+<xsl:call-template name="newtranslation"/>
+</xsl:template>
+
+<xsl:template match="translation" mode="info">
+<xsl:variable name="language"><xsl:value-of select="@language"/></xsl:variable>
+<xsl:variable name="livenew"><xsl:value-of select="/save/form/field[@name=concat($language, '.live')]"/></xsl:variable>
+<xsl:variable name="editnew"><xsl:value-of select="/save/form/field[@name=concat($language, '.edit')]"/></xsl:variable>
+<xsl:variable name="file"><xsl:value-of select="/save/form/field[@name=concat($language , '.file')]"/></xsl:variable>
+<xsl:variable name="title"><xsl:value-of select="/save/form/field[@name=concat($language , '.title')]"/></xsl:variable>
+<xsl:variable name="newrevision"><xsl:if test="(string-length($file) &gt; 0) and (string-length($title) &gt; 0)">1</xsl:if></xsl:variable>
+<xsl:element name="translation">
+<xsl:attribute name="language"><xsl:value-of select="@language"/></xsl:attribute>
+<xsl:choose>
+<xsl:when test="/save/form/field[@name='delete'] = $language">
+<xsl:attribute name="action">delete</xsl:attribute>
+</xsl:when>
+<xsl:otherwise>
+<xsl:if test="(@live != $livenew) and (($livenew != 'new') or (newrevision='1'))">
+<xsl:attribute name="live"><xsl:value-of select="$livenew"/></xsl:attribute>
+</xsl:if>
+<xsl:if test="(@edit != $editnew) and (newrevision != '1')"><xsl:attribute name="edit"><xsl:value-of select="$editnew"/></xsl:attribute></xsl:if>
+<xsl:apply-templates select="revision" mode="info">
+   <xsl:with-param name="language" select="$language"/>
+</xsl:apply-templates>
+</xsl:otherwise>
+</xsl:choose>
+</xsl:element>
+</xsl:template>
+
+<xsl:template match="translation" mode="new">
+<xsl:variable name="language"><xsl:value-of select="@language"/></xsl:variable>
+<xsl:call-template name="newrevision">
+   <xsl:with-param name="language" select="$language"/>
+</xsl:call-template>
+
+</xsl:template>
+
+<xsl:template match="revision" mode="info">
+<xsl:param name="language"/>
+<xsl:if test="/save/form/field[@name='delete'] = concat($language , '.', @revision)">
+<xsl:element name="revision">
+<xsl:attribute name="action">delete</xsl:attribute>
+<xsl:attribute name="revision"><xsl:value-of select="@revision"/></xsl:attribute>
+</xsl:element>
+</xsl:if>
+</xsl:template>
+
+<xsl:template name="newtranslation">
+<xsl:variable name="language"><xsl:value-of select="/save/form/field[@name='new.language']"/></xsl:variable>
+<xsl:if test="string-length($language) &gt; 0">
+<xsl:call-template name="newrevision">
+   <xsl:with-param name="language" select="$language"/>
+   <xsl:with-param name="fieldlanguage" select="'new'"/>
+</xsl:call-template>
+</xsl:if>
+</xsl:template>
+
+<xsl:template name="newrevision">
+<xsl:param name="language"/>
+<xsl:param name="fieldlanguage" select="$language"/>
+<xsl:variable name="file"><xsl:value-of select="/save/form/field[@name=concat($fieldlanguage , '.file')]"/></xsl:variable>
+<xsl:variable name="title"><xsl:value-of select="/save/form/field[@name=concat($fieldlanguage , '.title')]"/></xsl:variable>
+<xsl:variable name="live"><xsl:value-of select="/save/form/field[@name=concat($fieldlanguage , '.live')]"/></xsl:variable>
+
+<xsl:variable name="editrev"><xsl:value-of select="/save/resource/translation[@language = $fieldlanguage]/@edit"/></xsl:variable>
+<xsl:variable name="editfile"><xsl:value-of select="/save/resource/translation[@language = $fieldlanguage]/revision[@revision = $editrev]/@file"/></xsl:variable>
+<xsl:variable name="edittitle"><xsl:value-of select="/save/resource/translation[@language = $fieldlanguage]/revision[@revision = $editrev]/@title"/></xsl:variable>
+<xsl:if test="($file != $editfile) or ($title != $edittitle)">
+<xsl:element name="revision">
+<xsl:attribute name="action">new</xsl:attribute>
+<xsl:attribute name="language"><xsl:value-of select="$language"/></xsl:attribute>
+<xsl:if test="$live = 'new'"><xsl:attribute name="live">true</xsl:attribute></xsl:if>
+<file>
+<xsl:attribute name="file"><xsl:value-of select="$file"/></xsl:attribute>
+<xsl:attribute name="filefield"><xsl:value-of select="$fieldlanguage"/>.file</xsl:attribute>
+<xsl:attribute name="title"><xsl:value-of select="$title"/></xsl:attribute>
+</file>
+</xsl:element>
+</xsl:if>
+</xsl:template>
+
+</xsl:stylesheet> 

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/file/save.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/code.js
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/code.js?rev=420311&r1=420310&r2=420311&view=diff
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/code.js (original)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/flat/code.js Sun Jul  9 09:25:42 2006
@@ -195,6 +195,8 @@
                   }
                }
             }
+//TODO: Remove lenya:meta element but copy the children
+
             if(file.hasAttribute("href")) fileroot.setAttribute("href", file.getAttribute("href"));
             if(hasExtension) fileroot.setAttribute("extension", extension);
             writeDocument(filedoc, ResourcesDirectory + unid + file.getAttribute("filename"));
@@ -259,10 +261,11 @@
    for(var f = 0; f < indexfilenameslength; f++){
       var filename = indexfilenames[f];
       var newfile = new Packages.java.io.File(newindexdirectory, filename);
-      if(!newfile.exists()){
+//CHANGE: Overwrite Indexes because they changed.
+//      if(!newfile.exists()){
          var oldfile = new Packages.java.io.File(oldindexdirectory, filename);
          copyfile(oldfile.getAbsolutePath(), newfile.getAbsolutePath());
-      }
+//      }
    }
    //### Return
    cocoon.sendPage("finish");

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js Sun Jul  9 09:25:42 2006
@@ -0,0 +1,90 @@
+var manager = Packages.org.apache.cocoon.components.CocoonComponentManager.getSitemapComponentManager();
+
+function update(){
+   var publication = cocoon.parameters.publication;
+   var module = cocoon.parameters.module;
+   var unid = cocoon.parameters.unid;
+
+   var flowHelper = new Packages.org.apache.lenya.cms.cocoon.flow.FlowHelper();
+   var documentHelper = flowHelper.getDocumentHelper(cocoon);
+   var pageEnvelope = flowHelper.getPageEnvelope(cocoon);
+   var pub = pageEnvelope.getPublication();
+   var content = pub.getContent();
+   var resource = content.getResource(unid);
+   //Input
+print("####### LINK UPDATE BEGIN #######");
+   var dom = loadDocument("cocoon:/" + module + "/savedata/" + unid);
+   var root = dom.getDocumentElement();
+print("ROOT=" + root.getTagName());
+   var child = root.getFirstChild();
+
+/********* Example XML *********
+<save unid="0011">
+   <resource id="" defaultlanguage="new">
+      <translation language="en">
+          <revision action="delete" revision="123456789"/>
+      </translation>
+      <translation language="ru" action="delete"/>
+   </resource>
+   <revision action="new" language="en">
+      <link href="http://enURL" title="enTitle"/>
+   </revision>
+   <translation action="new" language="xx"/>
+   <revision action="new" language="xx">
+      <link href="http://xxURL" title="xxTitle"/>
+   </revision>
+</save>
+********************************/
+
+   while(child != null){
+      var childtag = child.getNodeName();
+      if(childtag.equalsIgnoreCase("resource")){
+         var doc = convertNodeToDocument(child);
+         Packages.org.apache.lenya.cms.content.ResourceTransformer.transformDocument(cocoon.request, unid, doc);
+      }
+      if(childtag.equalsIgnoreCase("revision")){
+         var language = child.getAttribute("language");
+         var setLive = false;
+         if(child.hasAttribute("live")){
+            if(child.getAttribute("live").equalsIgnoreCase("true")) setLive = true;
+         }
+         var revision = child.getFirstChild();
+         var doc = convertNodeToDocument(revision);
+         Packages.org.apache.lenya.cms.content.flat.CreateRevisionTransformer.transformDocument(cocoon.request, unid + "_" + language, doc, setLive);
+      }
+      child = child.getNextSibling();
+   }
+   cocoon.sendPage("edit/" + unid);
+}
+
+
+function convertNodeToDocument(node){
+   var factory = Packages.javax.xml.parsers.DocumentBuilderFactory.newInstance();
+   var builder = factory.newDocumentBuilder();
+   var doc = builder.newDocument();
+   doc.appendChild(doc.importNode(node, true));
+   return doc;
+}
+
+
+/**
+ * loadDocument() reads in an XML file and returns a DOM Document.
+**/
+function loadDocument(uri) {
+  var parser = null;
+  var source = null;
+  var resolver = null;
+  try {
+      parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE);
+      resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
+      source = resolver.resolveURI(uri);
+      var stream = source.getInputStream();
+      var is = new Packages.org.xml.sax.InputSource(stream);
+      is.setSystemId(source.getURI());
+      return parser.parseDocument(is);
+  } finally {
+      if (source != null) resolver.release(source);
+      if (parser != null) cocoon.releaseComponent(parser);
+      if (resolver != null) cocoon.releaseComponent(resolver);
+  }
+}

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/code.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css Sun Jul  9 09:25:42 2006
@@ -0,0 +1,39 @@
+/* Header Menu */
+body {
+   font-family: Tahoma, Verdana, sans-serif;
+   background-color: #EEFFEE;
+}
+
+h1 {  padding: 0px 0px 0px 0px; }
+
+table {
+   padding: 1 1 1 1px;
+   border: solid 0px #336633;
+   background-color: #EEFFEE;
+   border-collapse: collapse;
+   border-color: #669966;
+   width: auto;
+}
+
+th{
+    font-size: 80%;
+    padding: 3px;
+    background-color: #EEFFEE;
+   border: solid 1px #336633;
+    vertical-align: center;
+}
+
+td{
+    font-size: 80%;
+    padding: 3px;
+    background-color: #EEFFEE;
+   border: solid 1px #336633;
+    vertical-align: center;
+}
+.spacer{
+   border: solid 0px #336633;
+}
+.dark{
+    background-color: #DDEEDD;
+}
+

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap Sun Jul  9 09:25:42 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Link Module: Edit -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <!-- =========================== Pipelines ================================ -->
+   <map:pipelines>
+      <map:pipeline>
+<!-- Remove Revision -->
+            <map:match pattern="edit/*!*">
+               <map:generate src="cocoon:/edit/{1}"/>
+               <map:serialize type="html"/>
+            </map:match>
+<!-- Show Resource -->
+            <map:match pattern="edit/*">
+               <map:aggregate element="content">
+                  <map:part src="content:::/{1}!edit"/>
+               </map:aggregate>
+               <map:transform src="module:///resource.xsl">
+                  <map:parameter name="module" value="{module:module}"/>
+                  <map:parameter name="publication" value="{publication:publication}"/>
+                  <map:parameter name="publicationname" value="{publication:name}"/>
+                  <map:parameter name="languages" value="{publication:languages}"/>
+               </map:transform>
+               <map:transform type="i18n"/>
+               <map:serialize type="html"/>
+            </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/edit.xmap
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap?rev=420311&view=auto
==============================================================================
--- lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap (added)
+++ lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap Sun Jul  9 09:25:42 2006
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Link Module -->
+<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
+  <map:flow language="javascript">
+     <map:script src="module:///code.js"/>
+  </map:flow>
+   <map:pipelines>
+      <map:pipeline type="noncaching">
+         <map:match pattern="{module:module}/*.css">
+            <map:read src="module:///{1}.css" mime-type="text/css"/>
+         </map:match>
+         <map:match pattern="formdata">
+            <map:generate type="serverpages" src="module://form/post.xsp"/>
+            <map:serialize type="xml"/>
+         </map:match>
+         <map:match pattern="{module:module}/save/*">
+            <map:call function="update">
+             <map:parameter name="publication" value="{page-envelope:publication-id}"/>
+             <map:parameter name="module" value="{module:module}"/>
+             <map:parameter name="unid" value="{1}"/>
+           </map:call>
+         </map:match>
+         <map:match pattern="{module:module}/savedata/*">
+            <map:aggregate element="save">
+               <map:part src="content:/INFO/{1}!edit"/>
+               <map:part src="cocoon:/formdata"/>
+            </map:aggregate>
+            <map:transform src="module:///save.xsl">
+               <map:parameter name="unid" value="{1}"/>
+            </map:transform>
+            <map:serialize type="xml"/>
+         </map:match>
+         <map:match pattern="edit/*">
+            <map:act type="resource-exists" src="module://edit/module.xmap">
+               <map:redirect-to uri="/{publication:publication}/edit/{../1}"/>
+            </map:act>
+            <map:mount uri-prefix="" src="module:///edit.xmap"/> 
+            <map:serialize type="html"/>
+         </map:match>
+      </map:pipeline>
+   </map:pipelines>
+</map:sitemap>

Propchange: lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/link/module.xmap
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org