You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/06/14 00:14:48 UTC
svn commit: r413992 - in /lenya/trunk/src:
java/org/apache/lenya/cms/cocoon/components/modules/input/ pubs/default/
pubs/default/lenya/resources/i18n/ pubs/default/xslt/
Author: andreas
Date: Tue Jun 13 15:14:47 2006
New Revision: 413992
URL: http://svn.apache.org/viewvc?rev=413992&view=rev
Log:
Added lastUser and lastDate attributes to WorkflowModule, added footer to default publication which uses these attributes.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java
lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui.xml
lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui_de.xml
lenya/trunk/src/pubs/default/sitemap.xmap
lenya/trunk/src/pubs/default/xslt/page2xhtml.xsl
Modified: lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java?rev=413992&r1=413991&r2=413992&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/WorkflowModule.java Tue Jun 13 15:14:47 2006
@@ -17,6 +17,8 @@
package org.apache.lenya.cms.cocoon.components.modules.input;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
@@ -49,6 +51,19 @@
*/
public static final String VARIABLE_PREFIX = "variable.";
+ /**
+ * The prefix to get the last user who invoked a certain event.
+ */
+ public static final String LAST_USER_PREFIX = "lastUser.";
+
+ /**
+ * The prefix to get the last date at which a certain event was invoked.
+ * @see #DATE_FORMAT
+ */
+ public static final String LAST_DATE_PREFIX = "lastDate.";
+
+ protected static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+
static final String[] PARAMETER_NAMES = { STATE };
/**
@@ -66,7 +81,8 @@
Document document = envelope.getDocument();
if (document != null && document.exists()) {
wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
- Session session = RepositoryUtil.getSession(this.manager, ObjectModelHelper.getRequest(objectModel));
+ Session session = RepositoryUtil.getSession(this.manager,
+ ObjectModelHelper.getRequest(objectModel));
DocumentWorkflowable workflowable = new DocumentWorkflowable(this.manager,
session,
document,
@@ -93,6 +109,18 @@
value = Boolean.valueOf(latestVersion.getValue(variableName));
}
}
+ } else if (name.startsWith(LAST_USER_PREFIX)) {
+ String event = name.substring(LAST_USER_PREFIX.length());
+ Version latestEventVersion = getLatestVersion(workflowable, event);
+ if (latestEventVersion != null) {
+ value = latestEventVersion.getUserId();
+ }
+ } else if (name.startsWith(LAST_DATE_PREFIX)) {
+ String event = name.substring(LAST_DATE_PREFIX.length());
+ Version latestEventVersion = getLatestVersion(workflowable, event);
+ if (latestEventVersion != null) {
+ value = DATE_FORMAT.format(latestEventVersion.getDate());
+ }
} else {
throw new ConfigurationException("The attribute [" + name
+ "] is not supported!");
@@ -109,6 +137,17 @@
}
}
return value;
+ }
+
+ protected Version getLatestVersion(DocumentWorkflowable workflowable, String event) {
+ Version latestEventVersion = null;
+ Version versions[] = workflowable.getVersions();
+ for (int i = versions.length - 1; i > 0; i--) {
+ if (versions[i].getEvent().equals(event)) {
+ latestEventVersion = versions[i];
+ }
+ }
+ return latestEventVersion;
}
/**
Modified: lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui.xml?rev=413992&r1=413991&r2=413992&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui.xml (original)
+++ lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui.xml Tue Jun 13 15:14:47 2006
@@ -17,7 +17,7 @@
limitations under the License.
- $Id: cmsui.xml,v 1.2 2004/03/13 12:24:30 roku Exp $
+ $Id$
-->
@@ -29,4 +29,6 @@
<message key="New language for existing Document">New language for existing Document</message>
<message key="default.createdoc.info.all-language-versions-exists">There are already versions of this document for all languages.</message>
+ <message key="last-published">This page was last published at {0} by {1}.</message>
+ <message key="never-published">This page has not been published yet.</message>
</catalogue>
Modified: lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui_de.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui_de.xml?rev=413992&r1=413991&r2=413992&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui_de.xml (original)
+++ lenya/trunk/src/pubs/default/lenya/resources/i18n/cmsui_de.xml Tue Jun 13 15:14:47 2006
@@ -17,7 +17,7 @@
limitations under the License.
- $Id: cmsui_de.xml,v 1.3 2004/04/17 07:22:45 roku Exp $
+ $Id$
-->
@@ -28,6 +28,9 @@
<message key="Create new language version">Neue Sprachversion anlegen</message>
<message key="New language for existing Document">Neue Sprachversion für existierendes Dokument anlegen</message>
<message key="default.createdoc.info.all-language-versions-exists">Das Dokument existiert bereits in allen notwendigen Sprachen.</message>
+
+ <message key="last-published">Diese Seite wurde zuletzt publiziert am {0} von {1}.</message>
+ <message key="never-published">Diese Seite wurde noch nicht publiziert.</message>
</catalogue>
Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?rev=413992&r1=413991&r2=413992&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Tue Jun 13 15:14:47 2006
@@ -147,6 +147,8 @@
<map:parameter name="language" value="{page-envelope:document-language}"/>
<map:parameter name="contextprefix" value="{request:contextPath}"/>
<map:parameter name="title" value="{dublincore:title}"/>
+ <map:parameter name="lastPublishedUser" value="{workflow:lastUser.publish}"/>
+ <map:parameter name="lastPublishedDate" value="{workflow:lastDate.publish}"/>
</map:transform>
</map:when>
<map:otherwise>
@@ -160,6 +162,8 @@
<map:parameter name="language" value="{page-envelope:document-language}"/>
<map:parameter name="contextprefix" value="{request:contextPath}"/>
<map:parameter name="title" value="{dublincore:title}"/>
+ <map:parameter name="lastPublishedUser" value="{workflow:lastUser.publish}"/>
+ <map:parameter name="lastPublishedDate" value="{workflow:lastDate.publish}"/>
</map:transform>
</map:otherwise>
</map:select>
Modified: lenya/trunk/src/pubs/default/xslt/page2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/xslt/page2xhtml.xsl?rev=413992&r1=413991&r2=413992&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/xslt/page2xhtml.xsl (original)
+++ lenya/trunk/src/pubs/default/xslt/page2xhtml.xsl Tue Jun 13 15:14:47 2006
@@ -24,6 +24,7 @@
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:i18n="http://apache.org/cocoon/i18n/2.1"
exclude-result-prefixes="page xhtml dc lenya"
>
@@ -41,6 +42,9 @@
<xsl:param name="language"/>
<xsl:param name="title"/>
+<xsl:param name="lastPublishedUser"/>
+<xsl:param name="lastPublishedDate"/>
+
<xsl:template match="cmsbody">
<html>
<head>
@@ -87,6 +91,7 @@
<xsl:apply-templates select="xhtml:div[@id = 'breadcrumb']"/>
<xsl:apply-templates select="xhtml:div[@id = 'search']"/>
<xsl:apply-templates select="xhtml:div[@id = 'body']"/>
+ <xsl:call-template name="footer"/>
</div>
</td>
</tr>
@@ -95,6 +100,27 @@
</body>
</html>
</xsl:template>
+
+
+ <xsl:template name="footer">
+ <div id="footer">
+ <p>
+ <xsl:choose>
+ <xsl:when test="$lastPublishedUser != ''">
+ <i18n:translate>
+ <i18n:text>last-published</i18n:text>
+ <i18n:param><i18n:date-time src-pattern="yyyy-MM-dd hh:mm:ss"><xsl:value-of select="$lastPublishedDate"/></i18n:date-time></i18n:param>
+ <i18n:param><xsl:value-of select="$lastPublishedUser"/></i18n:param>
+ </i18n:translate>
+ </xsl:when>
+ <xsl:otherwise>
+ <i18n:text>never-published</i18n:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </p>
+ </div>
+ </xsl:template>
+
<xsl:template match="@*|node()" priority="-1">
<xsl:copy>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org