You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by eg...@apache.org on 2003/09/03 16:12:20 UTC
cvs commit: cocoon-lenya/src/webapp/lenya/content/exception missing-language.xsp
egli 2003/09/03 07:12:20
Modified: src/webapp/lenya/xslt/exception missing-language.xsl
src/webapp/lenya/content/exception missing-language.xsp
Added: src/java/org/apache/lenya/cms/publication/xsp
DocumentLanguagesHelper.java
Log:
The missing-language screen now allows the user to directly
click on one of the available languages. In order to do that
the missing-language xsp uses a helper class DocumentLanguagesHelper
which can compute an URL given an objectModel and a language.
Revision Changes Path
1.2 +1 -1 cocoon-lenya/src/webapp/lenya/xslt/exception/missing-language.xsl
Index: missing-language.xsl
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/xslt/exception/missing-language.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- missing-language.xsl 29 Aug 2003 08:51:56 -0000 1.1
+++ missing-language.xsl 3 Sep 2003 14:12:20 -0000 1.2
@@ -31,7 +31,7 @@
<xsl:template match="available-languages/available-language">
<li>
- <xsl:value-of select="."/>
+ <a><xsl:attribute name="href"><xsl:value-of select="url"/></xsl:attribute><xsl:value-of select="language"/></a>
</li>
</xsl:template>
1.1 cocoon-lenya/src/java/org/apache/lenya/cms/publication/xsp/DocumentLanguagesHelper.java
Index: DocumentLanguagesHelper.java
===================================================================
/*
$Id: DocumentLanguagesHelper.java,v 1.1 2003/09/03 14:12:20 egli Exp $
<License>
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Lenya" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Michael Wechner <mi...@apache.org>. For more information on the Apache Soft-
ware Foundation, please see <http://www.apache.org/>.
Lenya includes software developed by the Apache Software Foundation, W3C,
DOM4J Project, BitfluxEditor, Xopus, and WebSHPINX.
</License>
*/
package org.apache.lenya.cms.publication.xsp;
import java.util.Map;
import org.apache.cocoon.ProcessingException;
import org.apache.lenya.cms.publication.DefaultDocumentBuilder;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentBuildException;
import org.apache.lenya.cms.publication.DocumentBuilder;
import org.apache.lenya.cms.publication.PageEnvelope;
import org.apache.lenya.cms.publication.PageEnvelopeException;
import org.apache.lenya.cms.publication.PageEnvelopeFactory;
/**
* Helper class for the policy GUI.
*
* @author andreas
*/
public class DocumentLanguagesHelper {
private PageEnvelope pageEnvelope = null;
/**
* Create a new DocumentlanguageHelper.
*
* @param objectModel the objectModel
*
* @throws ProcessingException if the page envelope could not be created.
*/
public DocumentLanguagesHelper(Map objectModel)
throws ProcessingException {
try {
this.pageEnvelope =
PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
} catch (PageEnvelopeException e) {
throw new ProcessingException(e);
}
}
/**
* Compute the URL for a given language and the parameters given in the contructor.
*
* @param language the language
*
* @return the url for the given language
*
* @throws ProcessingException if the document for the given language could not be created.
*/
public String getUrl(String language) throws ProcessingException {
String url = null;
DocumentBuilder builder = DefaultDocumentBuilder.getInstance();
String canonicalURL =
builder.buildCanonicalUrl(
pageEnvelope.getPublication(),
pageEnvelope.getDocument().getArea(),
pageEnvelope.getDocument().getId(),
language);
Document doc = null;
try {
doc =
builder.buildDocument(
pageEnvelope.getPublication(),
canonicalURL);
} catch (DocumentBuildException e) {
throw new ProcessingException(e);
}
url = pageEnvelope.getContext() + doc.getCompleteURL();
return url;
}
}
1.2 +15 -9 cocoon-lenya/src/webapp/lenya/content/exception/missing-language.xsp
Index: missing-language.xsp
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/content/exception/missing-language.xsp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- missing-language.xsp 29 Aug 2003 08:51:56 -0000 1.1
+++ missing-language.xsp 3 Sep 2003 14:12:20 -0000 1.2
@@ -4,30 +4,36 @@
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:input="http://apache.org/cocoon/xsp/input/1.0"
->
-
+ >
+
<xsp:structure>
<xsp:include>org.apache.lenya.cms.publication.Document</xsp:include>
<xsp:include>org.apache.lenya.cms.publication.DocumentException</xsp:include>
+ <xsp:include>org.apache.lenya.cms.publication.xsp.DocumentLanguagesHelper</xsp:include>
</xsp:structure>
-<missing-language>
-
+ <missing-language>
+
<current-language><input:get-attribute module="page-envelope" as="string" name="document-language"/></current-language>
<available-languages>
<xsp:logic>
Document doc = (Document) <input:get-attribute module="page-envelope" as="object" name="document"/>;
+ DocumentLanguagesHelper helper = new DocumentLanguagesHelper(objectModel);
try {
String[] availableLanguages = doc.getLanguages();
+ String language = null;
for (int i = 0; i < availableLanguages.length; i++) {
- String language = availableLanguages[i];
- <xsp:content>
- <available-language><xsp:expr>language</xsp:expr></available-language>
- </xsp:content>
+ language = availableLanguages[i];
+ <xsp:content>
+ <available-language>
+ <language><xsp:expr>language</xsp:expr></language>
+ <url><xsp:expr>helper.getUrl(language)</xsp:expr></url>
+ </available-language>
+ </xsp:content>
}
} catch (DocumentException e) {}
</xsp:logic>
</available-languages>
-
+
</missing-language>
</xsp:page>
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org