123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cogadmin
- (C) Copyright IBM Corp. 2005, 2017
- 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:ui="http://developer.cognos.com/schemas/ui/presentation/markup/"
- xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:muws2="http://docs.oasis-open.org/wsdm/muws2-2.xsd"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:resource-prop="http://developer.cognos.com/admin/properties"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:admui="http://developer.cognos.com/schemas/xts/admui"
- xmlns:wsrf-rp="http://docs.oasis-open.org/wsrf/rp-2"
- xmlns:nemo="http://developer.cognos.com/nemo"
- exclude-result-prefixes="wsrf-rp resource-prop admui xtsext xsl ui SOAP-ENV muws2 xts nemo">
-
- <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
- <!-- display variables -->
- <admui:variables/>
- <xsl:key name="supported-actions" match="/root/wsrf-rp:GetResourcePropertyResponse/*/resource-prop:Action" use="resource-prop:Name"/>
- <xsl:variable name="metadata" select="/root/metadata/wsrf-rp:GetResourcePropertyResponse/nemo:MetadataDescriptor"/>
- <xsl:template match="/root" priority="2">
- <xsl:variable name="encodedResourceID" select="xtsext:javascriptencode(xtsext:urlencode(string(key('env-param','objResourceID'))))"/>
- <xsl:variable name="jsEncodedMenuName" select="xtsext:javascriptencode(string(key('env-param','menuName')))"/>
- <xsl:variable name="doingGroupActions" select="key('env-param','actionType')='group'"/>
- <!--
- Show the set properties actions if:
- - we're doing an action on a specific resource (i.e. not a group action)
- - the resource has a valid storeID
- - we have a valid objectClass for the resource
- -->
- <xsl:variable name="showSetProperties" select="not($doingGroupActions) and key('env-param','objStoreID') != '' and key('env-param','objectClass') != '' and starts-with(key('env-param','objResourceID'),'cm:')"/>
- <script>
- <!-- build up the action menu definition -->
- <xsl:variable name="menuDefinition">
- <!-- add the set properties action if we're dealing with a cm resource -->
- <xsl:if test="$showSetProperties">
- <!-- construct the url -->
- <xsl:variable name="url" select="concat(/root/configProps/param[@name = 'cps']/property[@name ='gateway']/., '?b_action=xts.run&m=portal/properties_general.xts&m_class=', key('env-param','objectClass'), '&m_path=storeID(%22', /root/storeID, '%22)&m_obj=storeID(%22', key('env-param','objStoreID'), '%22)&backURL=javascript:parent._THIS_callBack();')"/>
-
- {
- title: "<xts:string id="IDS_ADM_ACT_SET_PROPERTIES" encode="javascript"/>",
- <!-- todo, gen the correct image URL once the menu js file has been fixed -->
- image: "<xsl:value-of select="xtsext:javascriptencode(string(concat('/ps/', $common_app, '/images/action_properties.gif')))"/>",
- action: function(evt) { ui_modal_dialog.open('<xsl:value-of select="xtsext:javascriptencode(string($url))"/>',false,true,true); }
- }
- </xsl:if>
- <!-- need to get the action context id depending on if we're doing a resource action or group action -->
- <xsl:variable name="actionContextID">
- <xsl:choose>
- <xsl:when test="$doingGroupActions">
- <xsl:choose>
- <xsl:when test="key('env-param','groupActionContextID') != ''">
- <xsl:value-of select="key('env-param','groupActionContextID')"/>
- </xsl:when>
- <xsl:when test="$metadata/nemo:ActionContexts/nemo:Context[@type='groupAction']">
- <xsl:value-of select="$metadata/nemo:ActionContexts/nemo:Context[@type='groupAction']/@id"/>
- </xsl:when>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="key('env-param','actionContextID') != ''">
- <xsl:value-of select="key('env-param','actionContextID')"/>
- </xsl:when>
- <xsl:when test="$metadata/nemo:ActionContexts/nemo:Context[@type='Action']">
- <xsl:value-of select="$metadata/nemo:ActionContexts/nemo:Context[@type='Action']/@id"/>
- </xsl:when>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- loop through all the actions -->
- <xsl:for-each select="$metadata/nemo:Action[key('supported-actions',nemo:Name) and not(nemo:Context[@id = $actionContextID and @exclude='true'])]">
- <xsl:variable name="encodedAction" select="xtsext:javascriptencode(string(nemo:Name))"/>
- <xsl:variable name="actionContext" select="nemo:Context[@id = $actionContextID]"/>
-
- <xsl:variable name="caption">
- <xsl:choose>
- <!-- check for the overriden caption -->
- <xsl:when test="$actionContext/nemo:Caption != ''">
- <xsl:value-of select="$actionContext/nemo:Caption"/>
- </xsl:when>
- <xsl:when test="nemo:Caption != ''">
- <xsl:value-of select="nemo:Caption"/>
- </xsl:when>
- <xsl:otherwise><xsl:value-of select="resource-prop:Name"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="encodedCaption">
- <xsl:value-of select="xtsext:javascriptencode($caption)"/>
- </xsl:variable>
- <xsl:variable name="confirm">
- <xsl:if test="nemo:Confirm">
- ,confirm:true
- <xsl:if test="nemo:Confirm/nemo:Caption != ''">
- ,confirmMsg:
- <xsl:choose>
- <xsl:when test="nemo:Confirm/nemo:Caption != ''">
- '<xsl:value-of select="xtsext:javascriptencode(nemo:Confirm/nemo:Caption)"/>'
- </xsl:when>
- <xsl:otherwise>
- '<xts:string id="IDS_ACTION_DEFAULT_CONFIRM" encode="javascript"><xts:param name="action"><xsl:value-of select="$encodedCaption"/></xts:param></xts:string>'
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:if>
- </xsl:variable>
-
- <!-- get the target for the action (child, self) -->
- <xsl:variable name="actionTarget">
- <xsl:choose>
- <xsl:when test="$actionContext/nemo:Target">
- <xsl:value-of select="$actionContext/nemo:Target"/>
- </xsl:when>
- <xsl:when test="nemo:Target">
- <xsl:value-of select="nemo:Target"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <!-- Get the queryrelationshipbytype element.. if any -->
- <xsl:variable name="QRBT">
- <xsl:choose>
- <xsl:when test="$actionContext/nemo:QueryRelationshipsByType">
- <xsl:value-of select="$actionContext/nemo:QueryRelationshipsByType"/>
- </xsl:when>
- <xsl:when test="nemo:QueryRelationshipsByType">
- <xsl:value-of select="nemo:QueryRelationshipsByType"/>
- </xsl:when>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:if test="position() = 1 and $showSetProperties">,</xsl:if>
- <!-- generate the jacascript for the menu -->
- {
- title: "<xsl:value-of select="$encodedCaption"/>",
- <xsl:if test="nemo:Icon">
- image: "<xsl:value-of select="xtsext:javascriptencode(string(concat('/', nemo:Icon)))"/>",
- </xsl:if>
- <xsl:variable name="precedingGroup">
- <xsl:value-of select="preceding-sibling::nemo:Action[1]/nemo:Group"/>
- </xsl:variable>
- <xsl:if test="not(string(nemo:Group) = string($precedingGroup))">
- separatorBefore:true,
- </xsl:if>
- <xsl:variable name="capability">
- <xsl:choose>
- <xsl:when test="boolean($doingGroupActions)">http://cognos.com/admin/supportedactions/resourcegroup/</xsl:when>
- <xsl:otherwise>http://cognos.com/admin/supportedactions/resource/</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- action: function(evt) { _THIS_.relationshipsObj.doAction({isGroupAction:<xsl:value-of select="boolean($doingGroupActions)"/>,capability: '<xsl:value-of select="xtsext:javascriptencode($capability)"/>', action:'<xsl:value-of select="$encodedAction"/>', actionLabel:'<xsl:value-of select="$encodedCaption"/>', target:'<xsl:value-of select="xtsext:javascriptencode(string($actionTarget))"/>', qrbt:'<xsl:value-of select="xtsext:javascriptencode(string($QRBT))"/>'<xsl:value-of select="normalize-space($confirm)"/>}); }
- }
- <xsl:if test="position() != last()">,</xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- build up the menu -->
- var <xsl:value-of select="$jsEncodedMenuName"/>=new ui_menu ({id: "<xsl:value-of select="$jsEncodedMenuName"/>", fragment: "_THIS_", title: "<xts:string id="IDS_ADM_TOP_ACTIONS_TOOLTIP" encode="javascript"/>", items:[
- <xsl:choose>
- <xsl:when test="$menuDefinition != ''"><xsl:value-of select="$menuDefinition"/></xsl:when>
- <xsl:otherwise>
- {
- title: "<xts:string id="IDS_ADM_ACT_NO_ACTIONS"/>"
- }
- </xsl:otherwise>
- </xsl:choose>
- ]});
-
- <!--
- Show the menu
- -->
- ui_menuShow(_THIS_.relationshipsObj, <xsl:value-of select="$jsEncodedMenuName"/>);
- </script>
- </xsl:template>
- <xsl:template match="node()" priority="-1">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="text()" priority="-1">
- <xsl:value-of select="."/>
- </xsl:template>
- </xsl:stylesheet>
|