123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cpscrn
- (C) Copyright IBM Corp. 2005, 2011
- US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- -->
- <!--
- Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
- Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
- -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- exclude-result-prefixes="SOAP-ENV nav xtsext">
- <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
- <xsl:variable name="navresult" select="/root/navresult"/>
- <xsl:variable name="root-container" select="$navresult/SOAP-ENV:Envelope/SOAP-ENV:Body/nav:getContainerResponse/nav:container"/>
- <xsl:variable name="action-item" select="$navresult/SOAP-ENV:Envelope/SOAP-ENV:Body/nav:getItemResponse/*[ self::nav:container | self::nav:item | self::nav:shortcut ]"/>
- <xsl:variable name="param-actions" select="/root/env/param[@name = 'actions']"/>
- <xsl:variable name="container-id" select="/root/env/param[@name = 'container']"/>
- <xsl:variable name="open-root" select="/root/env/param[@name = 'openRoot']"/>
- <xsl:variable name="container-margin" select="/root/env/param[@name = 'margin']"/>
- <xsl:variable name="open-id">
- <xsl:if test="not($action-item) and not($container-id) and $open-root = 'true'">
- <xsl:value-of select="$root-container/nav:id"/>
- </xsl:if>
- </xsl:variable>
-
- <xsl:template match="/">
- <xsl:choose>
- <xsl:when test="$action-item">
- <xsl:call-template name="actions"/>
- </xsl:when>
- <xsl:when test="$container-id">
- <xsl:call-template name="fragment"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="mainpage"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="mainpage">
- <script>
- var WEBCONTENT_URI = "_THIS?frag-resource=/fragments/navtree/THIS_";
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- // Tree code
- // - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // Preload images
- var _THIS_containerImgNames =
- [
- // 0 - single root
- [
- "tv_Lplus_top.gif",
- "tv_Lminus_top.gif"
- ],
- // 1 - multiple root top
- [
- "tv_Tplus_top.gif",
- "tv_Tminus_top.gif"
- ],
- // 2 - middle container
- [
- "tv_Tplus.gif",
- "tv_Tminus.gif"
- ],
- // 3 - last container
- [
- "tv_Lplus.gif",
- "tv_Lminus.gif"
- ]
- ];
- // preload container images
- var _THIS_imgContainer = new Array(_THIS_containerImgNames.length);
- for (var i = 0; i < _THIS_containerImgNames.length; i++)
- {
- _THIS_imgContainer[i] = new Array(2);
- for (var j = 0; j < 2; j++)
- {
- _THIS_imgContainer[i][j] = new Image(19, 20);
- _THIS_imgContainer[i][j].src = WEBCONTENT_URI + "/images/" + _THIS_containerImgNames[i][j];
- }
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // open/close folders
- var _THIS_containers = { };
- <xsl:if test="$open-id != ''">
- _THIS_containers["<xsl:value-of select="$open-id"/>"] = true;
- </xsl:if>
- function _THIS_toggleFolder(sId, sMargin, nIndex)
- {
- var img = $('_THIS_img_' + sId);
- var div = $('_THIS_content_' + sId);
-
- if (div.style.display == "none")
- {
- img.src = _THIS_imgContainer[nIndex][1].src;
- div.style.display = "block";
-
- if (!_THIS_containers[sId])
- {
- _THIS_.retrieve('container=' + sId + '&margin=' + sMargin, div);
- _THIS_containers[sId] = true;
- }
- }
- else
- {
- img.src = _THIS_imgContainer[nIndex][0].src;
- div.style.display = "none";
- }
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - -
- // item selection
- var _THIS_currentItem = "";
- function _THIS_getItemSpan(sId)
- {
- var item = $("dragitem_" + sId + "_THIS_");
- var span = xGetElementsByTagName("SPAN", item);
- if (span.length > 0)
- {
- span[0].style.backgroundColor = background;
- span[0].style.color = color;
- }
- }
-
- function _THIS_colorItem(sId, color, background)
- {
- var item = $("dragitem_" + sId + "_THIS_");
- var span = xGetElementsByTagName("SPAN", item);
- if (span.length > 0)
- {
- span[0].style.backgroundColor = background;
- span[0].style.color = color;
- }
- }
-
- function _THIS_selectItem(sType, sTitle, sId)
- {
- if (_THIS_currentItem)
- {
- _THIS_colorItem(_THIS_currentItem, "black", "white");
- _THIS_currentItem = "";
- }
-
- if (sId)
- {
- _THIS_colorItem(sId, "white", "blue");
- _THIS_currentItem = sId;
- var payload = [ sType, sTitle, sId ];
- _THIS_.raiseEvent("cognos.view", payload, "application");
- }
- }
- // - - - - - - - - - - - - - - - - - - - - - - - - - - -
- </script>
- <xsl:apply-templates select="$root-container">
- <xsl:with-param name="content" select="$root-container/nav:content/*[$open-root = 'true']"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template name="fragment">
- <xsl:apply-templates select="$navresult//nav:container[nav:id = $container-id][1]/nav:content/*">
- <xsl:with-param name="margin" select="$container-margin"/>
- </xsl:apply-templates>
- </xsl:template>
- <xsl:template name="actions">
- <xsl:apply-templates select="$action-item" mode="actions"/>
- </xsl:template>
-
- <!--
- nav:container
- -->
- <xsl:template match="nav:container">
- <xsl:param name="margin"/>
- <xsl:param name="content"/>
-
- <xsl:variable name="index">
- <xsl:call-template name="calc-index"/>
- </xsl:variable>
- <xsl:variable name="has-children" select="boolean(nav:hasChildren[. = 'true' or . = '1'])"/>
-
- <xsl:choose>
- <xsl:when test="$has-children">
- <xsl:variable name="new-margin">
- <xsl:value-of select="$margin"/>
- <xsl:choose>
- <xsl:when test="position() = last()">
- <xsl:text>O</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>I</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <div id="dragitem_{ nav:id }_THIS_" dragtype="{ nav:type }" payload="{ nav:id }" itemtitle="{ nav:name }"
- style="height: 20px; border: 0; cursor: default; white-space: nowrap">
- <xsl:call-template name="render-margin">
- <xsl:with-param name="margin" select="$margin"/>
- </xsl:call-template>
- <xsl:variable name="img-name">
- <xsl:call-template name="container-image">
- <xsl:with-param name="index" select="$index"/>
- <xsl:with-param name="is-open" select="boolean($content)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <img id="_THIS_img_{ nav:id }" src="_THIS?frag-resource=/fragments/navtree/images/{ $img-name }/THIS_" style="vertical-align: middle;" width="19" height="20" alt=""
- onclick="_THIS_toggleFolder('{ nav:id }', '{ $new-margin }', '{ $index }')" />
- <xsl:call-template name="render-name"/>
- </div>
- <div id="_THIS_content_{ nav:id }">
- <xsl:choose>
- <xsl:when test="$content">
- <xsl:apply-templates select="$content">
- <xsl:with-param name="margin" select="$new-margin"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style">display: none</xsl:attribute>
- <xsl:call-template name="render-margin">
- <xsl:with-param name="margin" select="$new-margin"/>
- </xsl:call-template>
- <img src="_THIS?frag-resource=/fragments/navtree/images/tv_loading.gif/THIS_" width="19" height="20" style="vertical-align: bottom" alt=""/>
- <span style="height: 20px; vertical-align: middle">
- <xsl:text> Loading...</xsl:text>
- </span>
- </xsl:otherwise>
- </xsl:choose>
- </div>
- </xsl:when>
- <xsl:otherwise>
- <div id="dragitem_{ nav:id }_THIS_" dragtype="{ nav:type }" payload="{ nav:id }" itemtitle="{ nav:name }"
- style="height: 20px; margin: 2px; border: 0; cursor: default; white-space: nowrap">
- <xsl:call-template name="render-margin">
- <xsl:with-param name="margin" select="$margin"/>
- </xsl:call-template>
- <xsl:variable name="img-name">
- <xsl:call-template name="item-image">
- <xsl:with-param name="index" select="$index"/>
- </xsl:call-template>
- </xsl:variable>
- <img src="_THIS?frag-resource=/fragments/navtree/images/{ $img-name }/THIS_" width="19" height="20" style="vertical-align: bottom" alt=""/>
- <xsl:call-template name="render-name"/>
- </div>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="nav:item | nav:shortcut">
- <xsl:param name="margin"/>
- <div id="dragitem_{ nav:id }_THIS_" dragtype="{ nav:type }" payload="{ nav:id }" itemtitle="{ nav:name }"
- style="height: 20px; border: 0; cursor: default; white-space: nowrap"
- onclick="_THIS_selectItem('{ nav:type }', '{ nav:name }', '{ nav:id }')">
- <xsl:call-template name="render-margin">
- <xsl:with-param name="margin" select="$margin"/>
- </xsl:call-template>
- <xsl:variable name="index">
- <xsl:call-template name="calc-index"/>
- </xsl:variable>
-
- <xsl:variable name="img-name">
- <xsl:call-template name="item-image">
- <xsl:with-param name="index" select="$index"/>
- </xsl:call-template>
- </xsl:variable>
-
- <img src="_THIS?frag-resource=/fragments/navtree/images/{ $img-name }/THIS_" width="19" height="20" style="vertical-align: bottom" alt=""/>
- <xsl:call-template name="render-name"/>
- </div>
- </xsl:template>
- <xsl:template name="render-name">
- <img id="icon__THIS_{ nav:id }" style="vertical-align: middle" src="{ nav:imgURL }" alt="{ nav:type }"/>
- <xsl:text>  </xsl:text>
- <span style="height: 20px; line-height: 20px; vertical-align: bottom">
- <xsl:value-of select="nav:name"/>
- </span>
- </xsl:template>
- <!--
- <xsl:template name="render-name">
- <xsl:variable name="resource-url">
- <xslText>http://localhost/series8/cgi-bin/cognos.cgi?m=/cps4/portlets/designer/portlet-impl/navtree/getMarkup.xts&id=</xslText>
- <xsl:value-of select="nav:id"/>
- <xsl:text>&actions=true</xsl:text>
- </xsl:variable>
-
- <xsl:variable name="rewritable-url">
- <xsl:text>_THIS?wsrp-urlType=resource&wsrp-url=</xsl:text>
- <xsl:value-of select="xtsext:urlencode($resource-url)"/>
- <xsl:text>&wsrp-requiresRewrite=true/THIS_</xsl:text>
- </xsl:variable>
-
- <img id="icon__THIS_{ nav:id }" style="vertical-align: middle" src="{ nav:imgURL }" alt="{ nav:type }"/>
- <xsl:text>  </xsl:text>
- <span style="height: 20px; line-height: 20px; vertical-align: bottom" oncontextmenu="_THIS_contextMenu('{ $rewritable-url }', this); return false" onclick="_THIS_onview('{ nav:id }', '{ nav:type }', '{ nav:name }')">
- <xsl:value-of select="nav:name"/>
- </span>
- </xsl:template>
- -->
- <xsl:template name="calc-index">
- <xsl:choose>
- <!-- not root -->
- <xsl:when test="ancestor::nav:container[1]">
- <xsl:choose>
- <xsl:when test="position() = last()">
- <xsl:text>3</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>2</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!-- root -->
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="position() = 1 and position() = last()">
- <xsl:text>0</xsl:text>
- </xsl:when>
- <xsl:when test="position() = 1">
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="position() = last()">
- <xsl:text>3</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>2</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="container-image">
- <xsl:param name="index"/>
- <xsl:param name="is-open"/>
- <xsl:choose>
- <xsl:when test="$index = '0'">
- <xsl:choose>
- <xsl:when test="$is-open">
- <xsl:text>tv_Lminus_top.gif</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>tv_Lplus_top.gif</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$index = '1'">
- <xsl:choose>
- <xsl:when test="$is-open">
- <xsl:text>tv_Tminus_top.gif</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>tv_Tplus_top.gif</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$index = '2'">
- <xsl:choose>
- <xsl:when test="$is-open">
- <xsl:text>tv_Tminus.gif</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>tv_Tplus.gif</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="$index = '3'">
- <xsl:choose>
- <xsl:when test="$is-open">
- <xsl:text>tv_Lminus.gif</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>tv_Lplus.gif</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="item-image">
- <xsl:param name="index"/>
- <xsl:choose>
- <xsl:when test="$index = '0'">
- <xsl:text>tv_L_top.gif</xsl:text>
- </xsl:when>
- <xsl:when test="$index = '1'">
- <xsl:text>tv_T_top.gif</xsl:text>
- </xsl:when>
- <xsl:when test="$index = '2'">
- <xsl:text>tv_T.gif</xsl:text>
- </xsl:when>
- <xsl:when test="$index = '3'">
- <xsl:text>tv_L.gif</xsl:text>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="margin-image">
- <xsl:param name="type"/>
- <xsl:choose>
- <xsl:when test="$type = 'I'">
- <xsl:text>tv_I.gif</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>tv_white.gif</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="render-margin">
- <xsl:param name="margin"/>
-
- <xsl:if test="$margin != ''">
- <xsl:variable name="type" select="substring($margin, 1, 1)"/>
- <xsl:variable name="image">
- <xsl:call-template name="margin-image">
- <xsl:with-param name="type" select="$type"/>
- </xsl:call-template>
- </xsl:variable>
- <img src="_THIS?frag-resource=/fragments/navtree/images/{ $image }/THIS_" width="19" height="20" style="vertical-align: bottom" alt=""/>
- <xsl:call-template name="render-margin">
- <xsl:with-param name="margin" select="substring($margin, 2)"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="*" mode="actions">
- <xsl:for-each select="nav:action">
- <xsl:call-template name="render-menuitem">
- <xsl:with-param name="id" select="../../nav:id"/>
- <xsl:with-param name="name" select="nav:name"/>
- <xsl:with-param name="alt" select="nav:alt"/>
- <xsl:with-param name="img" select="nav:imgName"/>
- <xsl:with-param name="url" select="nav:url"/>
- </xsl:call-template>
- </xsl:for-each>
- <!-- hr/ -->
- <xsl:call-template name="render-menuitem">
- <xsl:with-param name="id" select="nav:id"/>
- <xsl:with-param name="name" select="'More...'"/>
- <xsl:with-param name="alt" select="''"/>
- <xsl:with-param name="img">_THIS?frag-resource=/fragments/navtree/images/space.gif/THIS_</xsl:with-param>
- <xsl:with-param name="url" select="nav:actionsURL"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template name="render-menuitem">
- <xsl:param name="id"/>
- <xsl:param name="name"/>
- <xsl:param name="alt"/>
- <xsl:param name="img"/>
- <xsl:param name="url"/>
- <div id="_THIS_menuitem_{ $id }_{ position() }" style="padding-left:5px; padding-right:5px; height: 20px; width: 150px; white-space: nowrap" url="{ $url }">
- <img style="vertical-align: middle" width="16" height="16" src="{ $img }" alt="{ $alt }"/>
- <span style="vertical-align: middle; width: 100%">
- <xsl:text>  </xsl:text>
- <xsl:value-of select="$name"/>
- <xsl:text>    </xsl:text>
- </span>
- </div>
- </xsl:template>
- </xsl:stylesheet>
|