logo       

svn commit: r290956 - in /lenya/trunk/src: java/org/apache/lenya/cms/public: msg#00050

Subject: svn commit: r290956 - in /lenya/trunk/src: java/org/apache/lenya/cms/publication/ java/org/apache/lenya/cms/site/usecases/ webapp/lenya/pubs/default/lenya/usecases/site/
Author: chestnut
Date: Thu Sep 22 07:55:05 2005
New Revision: 290956

URL: http://svn.apache.org/viewcvs?rev=290956&view=rev
Log:
Added ability to have multiple samples for a module (doc type).
Extra sample choices can be added by adding the sample uri to the modules 
module.xconf file like so (notice the extra name attribute):

<sample-name>fallback://lenya/modules/xhtml/samples/xhtml.xml</sample-name>
<sample-name name="Two Column 
Layout">fallback://lenya/modules/xhtml/samples/xhtml-2col.xml</sample-name>

Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceType.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
    lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/site/create.jx

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceType.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceType.java?rev=290956&r1=290955&r2=290956&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceType.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceType.java Thu 
Sep 22 07:55:05 2005
@@ -32,6 +32,8 @@
  */
 package org.apache.lenya.cms.publication;
 
+import java.util.Set;
+
 import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.apache.lenya.xml.Schema;
 
@@ -64,10 +66,21 @@
     String[] getLinkAttributeXPaths();
 
     /**
+     * Returns the a sample contents and their names for this type
+     * @return A set of the sample names
+     */
+    String[] getSampleNames();
+    
+    /**
      * Returns the location of sample contents for this type
      * @return A string value.
      */
     String getSampleURI();
+    
+    /**
+     * @param name The name attrib of the sample 
+     */
+    void setSampleURI(String name);
     
     /**
      * @return The creator.

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java?rev=290956&r1=290955&r2=290956&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/ResourceTypeImpl.java 
Thu Sep 22 07:55:05 2005
@@ -21,6 +21,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Iterator;
 
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
@@ -33,7 +34,6 @@
 import org.apache.lenya.cms.authoring.DefaultBranchCreator;
 import org.apache.lenya.cms.authoring.NodeCreatorInterface;
 import org.apache.lenya.xml.Schema;
-import org.xml.sax.ErrorHandler;
 
 /**
  * Resource type.
@@ -49,6 +49,7 @@
     protected static final String ELEMENT_REWRITE_ATTRIBUTE = "link-attribute";
     protected static final String ATTRIBUTE_XPATH = "xpath";
     protected static final String SAMPLE_NAME = "sample-name";
+    protected static final String SAMPLE_NAME_ATTRIBUTE = "name";
     protected static final String ELEMENT_FORMAT = "format";
     protected static final String ATTRIBUTE_URI = "uri";
     protected static final String ATTRIBUTE_NAME = "name";
@@ -56,6 +57,8 @@
 
     private Schema schema = null;
     private String sampleUri = null;
+    private String defaultSampleUri = null;
+    private Map sampleUris = new HashMap();
     private String[] linkAttributeXPaths;
     private NodeCreatorInterface creator;
 
@@ -85,11 +88,16 @@
                 creator = new DefaultBranchCreator();
             }
 
-            // determine the sample content location.
+            // determine the sample content locations.
             if (creatorConf != null) {
-                Configuration sampleConf = creatorConf.getChild(SAMPLE_NAME, 
false);
-                if (sampleConf != null) {
-                    this.sampleUri = sampleConf.getValue();
+                Configuration[] samplesConf = 
creatorConf.getChildren(SAMPLE_NAME);
+                for(int i=0; i<samplesConf.length; i++) {
+                  if (samplesConf[i].getAttributeNames().length > 0)
+                    
this.sampleUris.put(samplesConf[i].getAttribute(SAMPLE_NAME_ATTRIBUTE),samplesConf[i].getValue());
                   
+                  else { //default sample doesn't have name attribute
+                    this.sampleUri = samplesConf[i].getValue();
+                    this.defaultSampleUri = samplesConf[i].getValue();
+                  }
                 }
             }
 
@@ -131,6 +139,23 @@
         return this.linkAttributeXPaths;
     }
 
+    public String[] getSampleNames() {
+       String[] names = new String[this.sampleUris.size()];
+       Iterator it = this.sampleUris.keySet().iterator();
+        int count=0;
+       while (it.hasNext()) {
+            names[count++] = (String) it.next();
+        }
+       return names;
+    }
+    
+    public void setSampleURI(String name) {
+        if (name.length() > 0 && this.sampleUris.containsKey(name)) 
+          this.sampleUri = (String) this.sampleUris.get(name);                 
+        else
+          this.sampleUri = new String(this.defaultSampleUri);
+    }
+    
     public String getSampleURI() {
         return this.sampleUri;
     }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java?rev=290956&r1=290955&r2=290956&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/Create.java Thu Sep 
22 07:55:05 2005
@@ -59,6 +59,10 @@
     protected static final String DOCUMENT_ID = "documentId";
     
     protected static final String VISIBLEINNAV = "visibleInNav";
+    
+    protected static final String SAMPLE = "sample";
+    protected static final String SAMPLES = "samples";
+    protected static final String SAMPLES_COUNT = "samplesCount";
 
     /**
      * Ctor.
@@ -123,9 +127,12 @@
             Document initialDocument = getInitialDocument();
             if (initialDocument == null) {
                 selector = (ServiceSelector) 
this.manager.lookup(ResourceType.ROLE + "Selector");
-                resourceType = (ResourceType) 
selector.select(getDocumentTypeName()); 
+                resourceType = (ResourceType) 
selector.select(getDocumentTypeName());  
+                if (getParameterAsString(SAMPLE)!=null && 
getParameterAsString(SAMPLE).length() > 0)
+                  resourceType.setSampleURI(getParameterAsString(SAMPLE));
                 documentManager.add(document, resourceType,
                         getParameterAsString(DublinCore.ELEMENT_TITLE), 
getVisibleInNav(), null);
+                resourceType.setSampleURI(""); //reset to default sample
             } else {
                 documentManager.add(document, initialDocument,
                         getParameterAsString(DublinCore.ELEMENT_TITLE), 
getVisibleInNav(), null);
@@ -223,6 +230,23 @@
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
         setParameter(DublinCore.ELEMENT_DATE, format.format(new 
GregorianCalendar().getTime()));
 
+        ServiceSelector selector = null;
+        ResourceType resourceType = null;
+        try {
+                selector = (ServiceSelector) 
this.manager.lookup(ResourceType.ROLE + "Selector");
+                resourceType = (ResourceType) 
selector.select(getDocumentTypeName());
+                setParameter(SAMPLES, resourceType.getSampleNames());
+                setParameter(SAMPLES_COUNT, new 
Integer(resourceType.getSampleNames().length));    
+        } catch(Exception e) {
+            throw new RuntimeException(e);
+        }  finally {
+            if (selector != null) {
+                if (resourceType != null) {
+                    selector.release(resourceType);
+                }
+                this.manager.release(selector);
+            }
+        }
     }
 
     /**

Modified: 
lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/site/create.jx
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/site/create.jx?rev=290956&r1=290955&r2=290956&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/site/create.jx 
(original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/lenya/usecases/site/create.jx Thu 
Sep 22 07:55:05 2005
@@ -142,6 +142,17 @@
                   <input class="lenya-form-element" type="text" name="rights" 
value="${usecase.getParameter('rights')}"/>
                 </td>
               </tr>
+              <jx:if test="${usecase.getParameter('samplesCount') &gt; 0}">
+                <tr>
+                  <td class="lenya-entry-caption">
+                    <label for="sample"><i18n:text>Page 
Layout</i18n:text>:</label></td>
+                  <td>
+                    <jx:forEach var="item" 
items="${usecase.getParameter('samples')}">
+                      <input type="radio" name="sample" 
value="${item}"/>${item}<br />
+                    </jx:forEach>
+                  </td>
+                </tr>
+              </jx:if>  
               <tr>
                 <td class="lenya-entry-caption">* <i18n:text>required 
fields</i18n:text>
                 </td>


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    politics.lenini...    audio.emagic.ex...    tex.texinfo.gen...    handhelds.linux...    ietf.sipping/20...    lang.erlang.gen...    cygwin.talk/200...    yellowdog.gener...    mozilla.devel.l...    xfree86.newbie/...    openbsd.ports/2...    db.oracle.devel...    kde.kalyxo.deve...    user-groups.lin...    bbc.cvs/2003-04...    gnu.libtool.bug...    redhat.k12osn/2...    emulators.wine....    freebsd.devel.d...    search.xapian.g...    java.izpack.use...    network.mrtg.us...    windows.total-c...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe