Author: andreas
Date: Thu Aug 23 04:13:24 2007
New Revision: 568933
URL: http://svn.apache.org/viewvc?rev=568933&view=rev
Log:
Improved Ajax menubar generation (load single menus on demand)
Added:
lenya/trunk/src/modules/menubar/xslt/emptyMenu.xml
lenya/trunk/src/modules/menubar/xslt/selectSingleMenu.xsl
lenya/trunk/src/webapp/lenya/xslt/menu/menubar2xhtml.xsl
Modified:
lenya/trunk/src/modules/menubar/resources/javascript/loadmenu.js
lenya/trunk/src/modules/menubar/sitemap.xmap
lenya/trunk/src/modules/menubar/xslt/menu2xslt-ajax.xsl
lenya/trunk/src/webapp/global-sitemap.xmap
lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl
Modified: lenya/trunk/src/modules/menubar/resources/javascript/loadmenu.js
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/menubar/resources/javascript/loadmenu.js?rev=568933&r1=568932&r2=568933&view=diff
==============================================================================
--- lenya/trunk/src/modules/menubar/resources/javascript/loadmenu.js (original)
+++ lenya/trunk/src/modules/menubar/resources/javascript/loadmenu.js Thu Aug 23 04:13:24 2007
@@ -19,15 +19,22 @@
dojo.require("dojo.event.*");
dojo.require("dojo.io.*");
-function loadMenu(e) {
+function loadMenu(event) {
+ var menuNumber = event.target.id.substring("nav".length);
var menuFunction = {
- url: MENU_URL + "&lenya.module=menubar",
+ url: MENU_URL + "&lenya.module=menubar&lenya.menu=" + menuNumber,
load: function(type, data, evt) {
- var placeholderElement = document.getElementById("lenyaMenuPlaceholder");
- var menuElement = document.getElementById("lenyaMenuContainer");
- menuElement.removeChild(placeholderElement);
- menuElement.appendChild(data.documentElement);
- initialize();
+ var docElement = data.documentElement
+ var attrValue = docElement.getAttribute("id");
+ var menuNumber = attrValue.substring("menu".length);
+ var element = document.getElementById("menu" + menuNumber);
+ var placeholderElement = document.getElementById("menuPlaceholder" + menuNumber);
+ element.removeChild(placeholderElement);
+ var children = docElement.childNodes;
+ for (var i = 0; i < children.length; i++) {
+ element.appendChild(children[i].cloneNode(true));
+ }
+ dojo.event.disconnect(dojo.byId("nav" + menuNumber), "onclick", "loadMenu");
},
error: function(type, error) {
dojo.log.error(error.message);
@@ -42,7 +49,10 @@
* Customize this method for event-based loading.
*/
function initAjax() {
- dojo.event.connect(dojo.byId("dojotest"), "onclick", "loadMenu");
+ var menuNumber = 5;
+ for (var i = 1; i <= menuNumber; i++) {
+ dojo.event.connect(dojo.byId("nav" + i), "onclick", "loadMenu");
+ }
}
-dojo.addOnLoad(loadMenu);
+dojo.addOnLoad(initAjax);
Modified: lenya/trunk/src/modules/menubar/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/menubar/sitemap.xmap?rev=568933&r1=568932&r2=568933&view=diff
==============================================================================
--- lenya/trunk/src/modules/menubar/sitemap.xmap (original)
+++ lenya/trunk/src/modules/menubar/sitemap.xmap Thu Aug 23 04:13:24 2007
@@ -25,7 +25,20 @@
<map:pipeline internal-only="true">
<map:match pattern="ajaxmenu/*/*/**">
- <map:generate src="fallback://lenya/content/util/empty.xml"/>
+ <map:generate src="xslt/emptyMenu.xml"/>
+ <map:transform src="fallback://lenya/xslt/menu/menubar2xhtml.xsl">
+ <map:parameter name="publicationid" value="{1}"/>
+ <map:parameter name="area" value="{2}"/>
+ <map:parameter name="documenturl" value="{page-envelope:document-url}"/>
+ <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+ <map:parameter name="userid" value="{access-control:user-id}"/>
+ <map:parameter name="servertime" value="{date-i18n:currentDate}"/>
+ <map:parameter name="workflowstate" value="{workflow:state}"/>
+ <map:parameter name="islive" value="{workflow:variable.is_live}"/>
+ <map:parameter name="usecase" value="{request-param:lenya.usecase}"/>
+ <map:parameter name="tabGroup" value="{usecase:tabGroup:{request-param:lenya.usecase}}"/>
+ <map:parameter name="newMessages" value="{inbox:newMessageCount}"/>
+ </map:transform>
<map:transform src="xslt/menu2xslt-ajax.xsl">
<map:parameter name="contextPrefix" value="{request:contextPath}"/>
<map:parameter name="publicationid" value="{1}"/>
@@ -33,6 +46,9 @@
<map:parameter name="documenturl" value="{page-envelope:document-url}"/>
<map:parameter name="queryString" value="{request:queryString}"/>
</map:transform>
+ <map:transform type="i18n">
+ <map:parameter name="locale" value="{request:locale}"/>
+ </map:transform>
<map:serialize type="xml"/>
</map:match>
@@ -87,6 +103,11 @@
<map:transform src="fallback://lenya/xslt/menu/merge-menus.xsl"/>
+
+ <map:transform src="xslt/selectSingleMenu.xsl">
+ <map:parameter name="menu" value="{request-param:lenya.menu}"/>
+ </map:transform>
+
<map:transform src="fallback://lenya/xslt/menu/filter-menu.xsl">
<map:parameter name="tabGroup" value="{usecase:tabGroup:{request-param:lenya.usecase}}"/>
</map:transform>
@@ -106,6 +127,7 @@
<map:parameter name="usecase" value="{request-param:lenya.usecase}"/>
<map:parameter name="tabGroup" value="{usecase:tabGroup:{request-param:lenya.usecase}}"/>
<map:parameter name="newMessages" value="{inbox:newMessageCount}"/>
+ <map:parameter name="position" value="{request-param:lenya.menu}"/>
</map:transform>
<map:transform type="i18n">
Added: lenya/trunk/src/modules/menubar/xslt/emptyMenu.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/menubar/xslt/emptyMenu.xml?rev=568933&view=auto
==============================================================================
--- lenya/trunk/src/modules/menubar/xslt/emptyMenu.xml (added)
+++ lenya/trunk/src/modules/menubar/xslt/emptyMenu.xml Thu Aug 23 04:13:24 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: menu2xslt.xsl 520418 2007-03-20 15:03:34Z andreas $ -->
+
+<menu:menu xmlns:menu="http://apache.org/cocoon/lenya/menubar/1.0"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
+ <menu:menus>
+ <menu:menu name="File" i18n:attr="name"/>
+ <menu:menu name="Edit" i18n:attr="name"/>
+ <menu:menu name="Workflow" i18n:attr="name"/>
+ <menu:menu name="Help" i18n:attr="name"/>
+ <menu:menu name="Development" i18n:attr="name"/>
+ </menu:menus>
+</menu:menu>
Modified: lenya/trunk/src/modules/menubar/xslt/menu2xslt-ajax.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/menubar/xslt/menu2xslt-ajax.xsl?rev=568933&r1=568932&r2=568933&view=diff
==============================================================================
--- lenya/trunk/src/modules/menubar/xslt/menu2xslt-ajax.xsl (original)
+++ lenya/trunk/src/modules/menubar/xslt/menu2xslt-ajax.xsl Thu Aug 23 04:13:24 2007
@@ -80,15 +80,11 @@
<body>
<xso:apply-templates select="xhtml:html/xhtml:body/@*"/>
<xsl:apply-templates select="xhtml:div[@id = 'lenya-logo']"/>
- <div id="lenyaMenuContainer">
- <div id="lenyaMenuPlaceholder"/>
- </div>
+ <xsl:apply-templates select="xhtml:div/xhtml:div[@id = 'lenya-menus']"/>
<div id="lenya-cmsbody">
<xso:apply-templates select="xhtml:html/xhtml:body/node()"/>
</div>
- <!--
- <script type="text/javascript"> initialize(); </script>
- -->
+ <script type="text/javascript"> initialize(); </script>
</body>
</html>
</xso:template>
@@ -127,21 +123,22 @@
</xsl:template>
+
+ <xsl:template match="xhtml:li[starts-with(@id, 'nav')]">
+ <xsl:copy>
+ <xsl:copy-of select="@*|node()"/>
+ <ul id="menu{position()}">
+ <li id="menuPlaceholder{position()}"><img src="/modules/menubar/images/indicator.gif"/></li>
+ </ul>
+ </xsl:copy>
+ </xsl:template>
+
+
<xsl:template match="xhtml:*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
- </xsl:template>
-
-
- <!-- add only first message as title attribute -->
- <xsl:template match="menu:message[preceding-sibling::menu:message]"/>
-
- <xsl:template match="menu:message">
- <xsl:attribute name="title">
- <xsl:value-of select="."/>
- </xsl:attribute>
</xsl:template>
Added: lenya/trunk/src/modules/menubar/xslt/selectSingleMenu.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/menubar/xslt/selectSingleMenu.xsl?rev=568933&view=auto
==============================================================================
--- lenya/trunk/src/modules/menubar/xslt/selectSingleMenu.xsl (added)
+++ lenya/trunk/src/modules/menubar/xslt/selectSingleMenu.xsl Thu Aug 23 04:13:24 2007
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: menu2xslt.xsl 520418 2007-03-20 15:03:34Z andreas $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:menu="http://apache.org/cocoon/lenya/menubar/1.0"
+ >
+
+ <xsl:param name="menu"/>
+
+ <xsl:template match="menu:menus">
+ <xsl:copy>
+ <xsl:apply-templates select="menu:menu[position() = $menu]"/>
+ </xsl:copy>
+ </xsl:template>
+
+
+ <xsl:template match="@*|node()" priority="-1">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+
+</xsl:stylesheet>
Modified: lenya/trunk/src/webapp/global-sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/global-sitemap.xmap?rev=568933&r1=568932&r2=568933&view=diff
==============================================================================
--- lenya/trunk/src/webapp/global-sitemap.xmap (original)
+++ lenya/trunk/src/webapp/global-sitemap.xmap Thu Aug 23 04:13:24 2007
@@ -189,7 +189,7 @@
</map:transform>
</map:when>
<map:otherwise>
- <map:transform src="fallback://lenya/xslt/menu/menu2xhtml.xsl">
+ <map:transform src="fallback://lenya/xslt/menu/menubar2xhtml.xsl">
<map:parameter name="publicationid" value="{1}"/>
<map:parameter name="area" value="{2}"/>
<map:parameter name="documenturl" value="{page-envelope:document-url}"/>
Modified: lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl?rev=568933&r1=568932&r2=568933&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl (original)
+++ lenya/trunk/src/webapp/lenya/xslt/menu/menu2xhtml.xsl Thu Aug 23 04:13:24 2007
@@ -39,191 +39,16 @@
<xsl:param name="tabGroup"/>
<xsl:param name="newMessages"/>
-<xsl:variable name="currentTab">
- <xsl:choose>
- <xsl:when test="$tabGroup != ''"><xsl:value-of select="$tabGroup"/></xsl:when>
- <xsl:otherwise>authoring</xsl:otherwise>
- </xsl:choose>
-</xsl:variable>
-
-<xsl:variable name="image-prefix"><xsl:value-of select="$contextprefix"/>/lenya/menu/images</xsl:variable>
-
-<xsl:template match="/menu:menu">
-
- <div>
-
- <!-- Lenya graphic -->
- <div id="lenya-logo">
- <img src="{$image-prefix}/lenya-logo.gif" alt="Lenya" />
- </div>
-
- <div id="lenya-menus">
-
- <!-- The main tabs for the different areas of Lenya -->
- <div id="lenya-areas">
- <ul>
-
- <!-- ADMIN TAB -->
- <xsl:if test="not(menu:tabs/menu:tab[@label = 'admin']/@show = 'false')">
- <xsl:call-template name="area-tab">
- <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
- <xsl:with-param name="tabName">admin</xsl:with-param>
- <xsl:with-param name="queryString">?lenya.usecase=admin.users</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
-
- <xsl:if test="not(menu:tabs/menu:tab[@label = 'info']/@show = 'false')">
- <xsl:call-template name="area-tab">
- <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
- <xsl:with-param name="queryString">?lenya.usecase=tab.overview</xsl:with-param>
- <xsl:with-param name="tabName">site</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
-
- <!-- AUTHORING TAB -->
- <xsl:call-template name="area-tab">
- <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
- <xsl:with-param name="tabName"><xsl:value-of select="$area"/></xsl:with-param>
- </xsl:call-template>
-
- <!-- STAGING TAB -->
- <xsl:if test="menu:tabs/menu:tab[@label = 'staging']/@show = 'true'">
- <xsl:call-template name="area-tab">
- <xsl:with-param name="tab-area">staging</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
-
- <!-- LIVE TAB -->
- <xsl:if test="not(menu:tabs/menu:tab[@label = 'live']/@show = 'false')">
- <xsl:call-template name="area-tab">
- <xsl:with-param name="tab-area">live</xsl:with-param>
- <xsl:with-param name="target">_blank</xsl:with-param>
- <xsl:with-param name="tabName">live</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
-
- </ul>
- </div>
-
- <!-- General information about the state of the page, etc. -->
- <div id="lenya-info">
- <ul>
- <xsl:if test="$workflowstate != ''">
- <xsl:call-template name="workflow"/>
- </xsl:if>
- <li id="info-user"><i18n:text>User</i18n:text>: <span id="logged-user"><xsl:value-of select="$userid"/></span></li>
- <li id="info-messages">
- <a href="?lenya.usecase=notification.inbox">
- <xsl:choose>
- <xsl:when test="$newMessages = '0'">
- <i18n:text>Inbox</i18n:text>
- </xsl:when>
- <xsl:when test="$newMessages = '1'">
- <i18n:text>unread-message</i18n:text>
- </xsl:when>
- <xsl:otherwise>
- <i18n:translate>
- <i18n:text>unread-messages</i18n:text>
- <i18n:param><xsl:value-of select="$newMessages"/></i18n:param>
- </i18n:translate>
- </xsl:otherwise>
- </xsl:choose>
- </a>
- </li>
- <li id="info-time"><i18n:text>Server Time</i18n:text>: <span id="server-time"><xsl:value-of select="$servertime"/></span></li>
- </ul>
- </div>
-
- <!-- drop down menus for area options -->
- <div id="lenya-options">
- <ul>
- <xsl:apply-templates select="menu:menus/menu:menu" mode="nav"/>
- </ul>
- </div>
-
- </div>
-
- </div>
-
-</xsl:template>
-
-
- <xsl:template name="area-tab">
- <xsl:param name="tab-area"/>
- <xsl:param name="tab-area-prefix" select="$tab-area"/>
- <xsl:param name="target" select="'_self'"/>
- <xsl:param name="queryString"/>
- <xsl:param name="tabName"/>
-
- <xsl:variable name="tab-documenturl">
- <xsl:choose>
- <!--
- Document URLs are not meaningful in some areas. In that case, set the URL to
- "/". The publication sitemap currently takes care of mapping that to a default page (index.html).
- FIXME: that solution is sub-optimal, because it breaks when a user deletes the /index page.
- There should be a mapper from "/" to "first entry in sitetree", and if that does not exist, to a
- "create document?" message.
- -->
- <!-- from or to the admin area, there's no concept of "document" (it's all usecases) -->
- <xsl:when test="$tab-area = 'admin' or $area = 'admin'">/</xsl:when>
- <!-- FIXME: what is documentid? -->
- <xsl:when test="($currentTab = 'site') and $documentid = '/'">/</xsl:when>
- <!-- catch missing trailing slash in urls with just the area: -->
- <xsl:when test="not($documenturl)">/</xsl:when>
- <!-- the default case is: use the current $documenturl for the new tab link. -->
- <xsl:otherwise><xsl:value-of select="$documenturl"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="$tabName = $currentTab">
- <!--
- FIXME: why do we normalize-space here? fiddling with uris is none of our business.
- Looks like a workaround for a real bug that should be fixed. Sure, we don't allow spaces
- in document URLs, but that policy decision is made elsewhere.
- -->
- <li id="area-{$tab-area}-active" class="area-active"><a href="/{$publicationid}/{$tab-area}{normalize-space($tab-documenturl)}{$queryString}" target="{$target}"><span><i18n:text><xsl:value-of select="$tabName"/></i18n:text></span></a></li>
- </xsl:when>
- <xsl:otherwise>
- <li id="area-{$tab-area}" class="area-inactive"><a href="/{$publicationid}/{$tab-area}{normalize-space($tab-documenturl)}{$queryString}" target="{$target}"><span><i18n:text><xsl:value-of select="$tabName"/></i18n:text></span></a></li>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <xsl:template name="workflow">
- <li id="info-state"><i18n:text>Workflow State</i18n:text>: <span name="workflow-state" id="workflow-state"><i18n:text><xsl:value-of select="$workflowstate"/></i18n:text></span></li>
- <li id="info-live">
- <xsl:choose>
- <xsl:when test="$islive = 'false'">
- <i18n:text>not live</i18n:text>
- </xsl:when>
- <xsl:otherwise>
- <i18n:text>live</i18n:text>
- </xsl:otherwise>
- </xsl:choose>
- </li>
- </xsl:template>
+ <xsl:param name="position"></xsl:param>
- <xsl:template match="menu:menu" mode="nav">
- <li id="nav{position()}"><i18n:text><xsl:value-of select="@name"/></i18n:text>
- <ul id="menu{position()}">
- <xsl:apply-templates select="menu:block"/>
- </ul>
- </li>
- </xsl:template>
- <xsl:template match="menu:menu//menu:menu">
- <li class="lenya-menu-title"><xsl:value-of select="@name"/></li>
- <xsl:apply-templates select="*"/>
+ <xsl:template match="/menu:menu">
+ <ul id="menu{$position}">
+ <xsl:apply-templates select="menu:menus/menu:menu/menu:block"/>
+ </ul>
</xsl:template>
- <xsl:template match="menu:menu[not(*)]" mode="nav">
- <li id="nav{position()}" class="disabled">
- <xsl:value-of select="@name"/>
- </li>
- </xsl:template>
-
+
<xsl:template match="menu:block">
<xsl:apply-templates select="menu:title"/>
<xsl:apply-templates select="menu:menu | menu:item"/>
@@ -273,6 +98,7 @@
<xsl:value-of select="@href"/>
<xsl:apply-templates select="@*[local-name() != 'href']"/>
<xsl:text/>
+ <!--
<xsl:if test="$currentTab = 'site'">
<xsl:choose>
<xsl:when test="contains(@href, '?')">
@@ -283,6 +109,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:if>
+ -->
</xsl:attribute>
<span><xsl:apply-templates select="i18n:*|text()"/></span>
</a></li>
Added: lenya/trunk/src/webapp/lenya/xslt/menu/menubar2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/webapp/lenya/xslt/menu/menubar2xhtml.xsl?rev=568933&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/menu/menubar2xhtml.xsl (added)
+++ lenya/trunk/src/webapp/lenya/xslt/menu/menubar2xhtml.xsl Thu Aug 23 04:13:24 2007
@@ -0,0 +1,228 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id: menu2xhtml.xsl 568636 2007-08-22 14:54:40Z andreas $ -->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+ xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
+ xmlns:menu="http://apache.org/cocoon/lenya/menubar/1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ >
+
+ <xsl:import href="menu2xhtml.xsl"/>
+
+<xsl:param name="contextprefix"/>
+<xsl:param name="publicationid"/>
+<xsl:param name="area"/>
+<xsl:param name="documenturl"/>
+<xsl:param name="documentid"/>
+<xsl:param name="userid"/>
+<xsl:param name="servertime"/>
+<xsl:param name="workflowstate"/>
+<xsl:param name="islive"/>
+<xsl:param name="usecase"/>
+<xsl:param name="tabGroup"/>
+<xsl:param name="newMessages"/>
+
+<xsl:variable name="currentTab">
+ <xsl:choose>
+ <xsl:when test="$tabGroup != ''"><xsl:value-of select="$tabGroup"/></xsl:when>
+ <xsl:otherwise>authoring</xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+
+<xsl:variable name="image-prefix"><xsl:value-of select="$contextprefix"/>/lenya/menu/images</xsl:variable>
+
+<xsl:template match="/menu:menu">
+
+ <div>
+
+ <!-- Lenya graphic -->
+ <div id="lenya-logo">
+ <img src="{$image-prefix}/lenya-logo.gif" alt="Lenya" />
+ </div>
+
+ <div id="lenya-menus">
+
+ <!-- The main tabs for the different areas of Lenya -->
+ <div id="lenya-areas">
+ <ul>
+
+ <!-- ADMIN TAB -->
+ <xsl:if test="not(menu:tabs/menu:tab[@label = 'admin']/@show = 'false')">
+ <xsl:call-template name="area-tab">
+ <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
+ <xsl:with-param name="tabName">admin</xsl:with-param>
+ <xsl:with-param name="queryString">?lenya.usecase=admin.users</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="not(menu:tabs/menu:tab[@label = 'info']/@show = 'false')">
+ <xsl:call-template name="area-tab">
+ <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
+ <xsl:with-param name="queryString">?lenya.usecase=tab.overview</xsl:with-param>
+ <xsl:with-param name="tabName">site</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+
+ <!-- AUTHORING TAB -->
+ <xsl:call-template name="area-tab">
+ <xsl:with-param name="tab-area"><xsl:value-of select="$area"/></xsl:with-param>
+ <xsl:with-param name="tabName"><xsl:value-of select="$area"/></xsl:with-param>
+ </xsl:call-template>
+
+ <!-- STAGING TAB -->
+ <xsl:if test="menu:tabs/menu:tab[@label = 'staging']/@show = 'true'">
+ <xsl:call-template name="area-tab">
+ <xsl:with-param name="tab-area">staging</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+
+ <!-- LIVE TAB -->
+ <xsl:if test="not(menu:tabs/menu:tab[@label = 'live']/@show = 'false')">
+ <xsl:call-template name="area-tab">
+ <xsl:with-param name="tab-area">live</xsl:with-param>
+ <xsl:with-param name="target">_blank</xsl:with-param>
+ <xsl:with-param name="tabName">live</xsl:with-param>
+ </xsl:call-template>
+ </xsl:if>
+
+ </ul>
+ </div>
+
+ <!-- General information about the state of the page, etc. -->
+ <div id="lenya-info">
+ <ul>
+ <xsl:if test="$workflowstate != ''">
+ <xsl:call-template name="workflow"/>
+ </xsl:if>
+ <li id="info-user"><i18n:text>User</i18n:text>: <span id="logged-user"><xsl:value-of select="$userid"/></span></li>
+ <li id="info-messages">
+ <a href="?lenya.usecase=notification.inbox">
+ <xsl:choose>
+ <xsl:when test="$newMessages = '0'">
+ <i18n:text>Inbox</i18n:text>
+ </xsl:when>
+ <xsl:when test="$newMessages = '1'">
+ <i18n:text>unread-message</i18n:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <i18n:translate>
+ <i18n:text>unread-messages</i18n:text>
+ <i18n:param><xsl:value-of select="$newMessages"/></i18n:param>
+ </i18n:translate>
+ </xsl:otherwise>
+ </xsl:choose>
+ </a>
+ </li>
+ <li id="info-time"><i18n:text>Server Time</i18n:text>: <span id="server-time"><xsl:value-of select="$servertime"/></span></li>
+ </ul>
+ </div>
+
+ <!-- drop down menus for area options -->
+ <div id="lenya-options">
+ <ul>
+ <xsl:apply-templates select="menu:menus/menu:menu" mode="nav"/>
+ </ul>
+ </div>
+
+ </div>
+
+ </div>
+
+</xsl:template>
+
+
+ <xsl:template name="area-tab">
+ <xsl:param name="tab-area"/>
+ <xsl:param name="tab-area-prefix" select="$tab-area"/>
+ <xsl:param name="target" select="'_self'"/>
+ <xsl:param name="queryString"/>
+ <xsl:param name="tabName"/>
+
+ <xsl:variable name="tab-documenturl">
+ <xsl:choose>
+ <!--
+ Document URLs are not meaningful in some areas. In that case, set the URL to
+ "/". The publication sitemap currently takes care of mapping that to a default page (index.html).
+ FIXME: that solution is sub-optimal, because it breaks when a user deletes the /index page.
+ There should be a mapper from "/" to "first entry in sitetree", and if that does not exist, to a
+ "create document?" message.
+ -->
+ <!-- from or to the admin area, there's no concept of "document" (it's all usecases) -->
+ <xsl:when test="$tab-area = 'admin' or $area = 'admin'">/</xsl:when>
+ <!-- FIXME: what is documentid? -->
+ <xsl:when test="($currentTab = 'site') and $documentid = '/'">/</xsl:when>
+ <!-- catch missing trailing slash in urls with just the area: -->
+ <xsl:when test="not($documenturl)">/</xsl:when>
+ <!-- the default case is: use the current $documenturl for the new tab link. -->
+ <xsl:otherwise><xsl:value-of select="$documenturl"/></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$tabName = $currentTab">
+ <!--
+ FIXME: why do we normalize-space here? fiddling with uris is none of our business.
+ Looks like a workaround for a real bug that should be fixed. Sure, we don't allow spaces
+ in document URLs, but that policy decision is made elsewhere.
+ -->
+ <li id="area-{$tab-area}-active" class="area-active"><a href="/{$publicationid}/{$tab-area}{normalize-space($tab-documenturl)}{$queryString}" target="{$target}"><span><i18n:text><xsl:value-of select="$tabName"/></i18n:text></span></a></li>
+ </xsl:when>
+ <xsl:otherwise>
+ <li id="area-{$tab-area}" class="area-inactive"><a href="/{$publicationid}/{$tab-area}{normalize-space($tab-documenturl)}{$queryString}" target="{$target}"><span><i18n:text><xsl:value-of select="$tabName"/></i18n:text></span></a></li>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <xsl:template name="workflow">
+ <li id="info-state"><i18n:text>Workflow State</i18n:text>: <span name="workflow-state" id="workflow-state"><i18n:text><xsl:value-of select="$workflowstate"/></i18n:text></span></li>
+ <li id="info-live">
+ <xsl:choose>
+ <xsl:when test="$islive = 'false'">
+ <i18n:text>not live</i18n:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <i18n:text>live</i18n:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </li>
+ </xsl:template>
+
+ <!--
+ <xsl:template match="menu:menu//menu:menu">
+ <li class="lenya-menu-title"><xsl:value-of select="@name"/></li>
+ <xsl:apply-templates select="*"/>
+ </xsl:template>
+ -->
+
+ <xsl:template match="menu:menu" mode="nav">
+ <li id="nav{position()}"><i18n:text><xsl:value-of select="@name"/></i18n:text>
+ <xsl:if test="*">
+ <ul id="menu{position()}">
+ <xsl:apply-templates select="menu:block"/>
+ </ul>
+ </xsl:if>
+ </li>
+ </xsl:template>
+
+
+</xsl:stylesheet>
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.