123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed Materials - Property of IBM
- IBM Cognos Products: cogadmin
- (C) Copyright IBM Corp. 2005, 2014
- 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).
- -->
- <!-- This stylesheet defines global portal variables and templates. -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:out="dummy-uri"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:uic="http://developer.cognos.com/schemas/uic/presentation/markup/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
- xmlns:admui="http://developer.cognos.com/schemas/xts/admui"
- xmlns:cogadminext="xalan://com.cognos.admin.xts.ext.XTSExt"
- exclude-result-prefixes="xsl xtsext xts admui nav uic">
-
- <xsl:output method="xml" encoding="UTF-8" indent="no"/>
- <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
- <!--
- a set of standard variables.
- -->
- <xsl:template match="admui:variables">
- <out:key name="system-param" match="/root/system/param" use="@name"/>
- <out:key name="env-param" match="/root/env/param" use="@name"/>
- <out:key name="session-param" match="/root/session/param" use="@name"/>
- <out:key name="user-param" match="/root/user/param" use="@name"/>
-
- <!-- Application variables -->
- <out:variable name="app" select="key('system-param', 'app')"/>
- <out:variable name="common_app" select="key('system-param','common_app')"/>
-
- <!-- Build a list of UI elements that we want to hide from the current user. -->
- <out:variable name="ui_black_list">
- <!-- System-based list -->
- <out:for-each select="key('system-param', 'ui_hide')/*">
- <out:variable name="s" select="concat(' ', @show, ' ')"/>
- <out:value-of select="' '"/><out:value-of select="local-name()"/><out:value-of select="' '"/>
- </out:for-each>
- </out:variable>
-
- <!-- todo: change this once CPS give us a better way to get the gateway -->
- <out:variable name="gateway" select="/root/configProps/param[@name = 'cps']/property[@name ='gateway']/."/>
-
- <out:variable name="webRoot">
- <out:choose>
- <out:when test="/root/http/param[@name='WEB_CONTENT_ROOT']">
- <out:value-of select="string(/root/http/param[@name='WEB_CONTENT_ROOT'])"/>
- </out:when>
- <!-- No official config param is present. Make this relative. -->
- <out:otherwise>..</out:otherwise>
- </out:choose>
- </out:variable>
- <!-- browser -->
- <out:variable name="user-agent" select="string(/root/http/param[@name='HTTP_USER_AGENT'])"/>
- <out:variable name="browser">
- <out:choose>
- <out:when test="contains($user-agent , 'MSIE')">ie</out:when> <!-- IE 4.xx and above -->
- <out:when test="contains($user-agent , 'Safari')">safari</out:when> <!-- Safari -->
- <out:when test="contains($user-agent , 'Mozilla/5.0')">moz</out:when> <!-- NS 6.xx and 7.xx -->
- <out:when test="string-length($user-agent) = 0">undefined</out:when>
- <out:otherwise>other</out:otherwise>
- </out:choose>
- </out:variable>
- <!-- locales -->
- <out:variable name="productLocale">
- <out:value-of select="key('user-param','productLocale')"/>
- </out:variable>
-
- <out:variable name="contentLocale">
- <out:value-of select="key('user-param','contentLocale')"/>
- </out:variable>
- <out:variable name="timeZone">
- <out:value-of select="key('user-param','timeZoneID')"/>
- </out:variable>
- <!-- CAPABILITIES calculations: Added as needed. Refer to portal.xsl logicsheet for capabilities mappings -->
- <!-- Administration capability -->
- <out:variable name="hasAdminCapability" select="boolean(key('session-param','capabilities')/canUseAdministrationPortal)"/>
- <!-- Scheduling Access capability-->
- <out:variable name="hasSchedCapability" select="boolean(key('session-param', 'capabilities')/canUseScheduling)"/>
- <!-- Scheduling Priority capability-->
- <out:variable name="hasSchedPriorityCapability" select="boolean(key('session-param', 'capabilities')/canUseSchedulingPriority)"/>
- <!-- Monitor Activity tool -->
- <out:variable name="hasMonitorActivityToolCapability" select="boolean(key('session-param', 'capabilities')/canUseMonitorActivityTool)"/>
- <!-- Run with Options capability-->
- <out:variable name="hasRWOCapability" select="boolean(key('session-param', 'capabilities')/canUseCognosViewerRunWithOptions)"/>
- </xsl:template>
- <!--
- Creates a set of standard pager variables to be used in queries.
- @pagerName: The name that was given to the pager
- Note: Needs env, session and system for nodelist
- -->
- <xsl:template match="admui:pagerVariables">
- <xsl:variable name="pagerName">
- <xsl:if test="@pagerName"><xsl:value-of select="@pagerName"/></xsl:if>
- </xsl:variable>
- <!-- pager name -->
- <out:variable name="pagerName">
- <xsl:if test="@pagerName"><out:value-of select="'{@pagerName}'"/></xsl:if>
- </out:variable>
-
- <!-- lines per page by default -->
- <out:variable name="linesPerPage">
- <out:choose>
- <out:when test="key('session-param','linesPerPage')">
- <out:value-of select="key('session-param','linesPerPage')"/>
- </out:when>
- <out:when test="key('system-param','defaultPortalPreferences')/pref[@name='lines']">
- <out:value-of select="key('system-param','defaultPortalPreferences')/pref[@name='lines']"/>
- </out:when>
- <out:otherwise>15</out:otherwise>
- </out:choose>
- </out:variable>
- <!-- get the start and end positions -->
- <out:variable name="startPosition">
- <out:choose>
- <out:when test="key('env-param','{$pagerName}_from') != ''"><out:value-of select="key('env-param','{$pagerName}_from')"/></out:when>
- <!-- if we don't have a start, try and calculate it using the end position if it's available -->
- <out:when test="key('env-param','{$pagerName}_to') != ''">
- <out:choose>
- <out:when test="number(key('env-param','{$pagerName}_to')) < number($linesPerPage)">1</out:when>
- <out:otherwise><out:value-of select="number(key('env-param','{$pagerName}_to')) - number($linesPerPage)"/></out:otherwise>
- </out:choose>
- </out:when>
- </out:choose>
- </out:variable>
- <out:variable name="endPosition">
- <out:choose>
- <out:when test="key('env-param','{$pagerName}_to') != ''"><out:value-of select="key('env-param','{$pagerName}_to')"/></out:when>
- <out:when test="$startPosition != ''">
- <out:value-of select="$startPosition + $linesPerPage"/>
- </out:when>
- </out:choose>
- </out:variable>
- <!-- how many objects should be displayed in the pager -->
- <out:variable name="maxObjects">
- <out:choose>
- <out:when test="$endPosition !='' and $startPosition !=''">
- <out:value-of select="($endPosition - $startPosition) + 1"/>
- </out:when>
- <out:otherwise><out:value-of select="$linesPerPage"/></out:otherwise>
- </out:choose>
- </out:variable>
-
- <!-- how many objects should we be skipping -->
- <out:variable name="skipObjects">
- <out:choose>
- <out:when test="key('env-param','{$pagerName}_skip') != ''">
- <out:value-of select="key('env-param','{$pagerName}_skip')"/>
- </out:when>
- <out:otherwise>0</out:otherwise>
- </out:choose>
- </out:variable>
- </xsl:template>
-
- <!--
- Common set of params used in nav requests
- Note: needs http in the nodelist
- -->
- <xsl:template match="admui:commonNavParams">
- <nav:param name="gatewayURL"><out:value-of select="$gateway"/></nav:param>
- <nav:param name="webContentURL"></nav:param>
- <nav:param name="portalAgent">cognos</nav:param>
- <nav:param name="browserAgent"><out:value-of select="$browser"/></nav:param>
- </xsl:template>
-
- <!-- CM predicate for handling hidden objects -->
- <xsl:template match="admui:object-predicates">
- <out:variable name="hidden-objects-predicate">[@shown='true']</out:variable>
- <out:variable name="visibility-predicate" select="concat(/root/system/param[@name='visible'],$hidden-objects-predicate)"/>
- </xsl:template>
- <xsl:template match="admui:imageURL" name="admui:imageURL">
- <out:variable name="image">
- <xsl:choose>
- <xsl:when test="@image != ''"><xsl:value-of select="@image"/></xsl:when>
- <xsl:when test="admui:image"><xsl:apply-templates select="admui:image"/></xsl:when>
- </xsl:choose>
- </out:variable>
- <out:variable name="webcontentPath">
- <xsl:choose>
- <xsl:when test="@type = 'cogadmin'">
- <out:value-of select="concat('/ps/', $app, '/images/')"/>
- </xsl:when>
- <xsl:when test="@type = 'common'">
- <out:value-of select="concat('/ps/', $common_app, '/images/')"/>
- </xsl:when>
- <xsl:when test="@type = 'server'"><xsl:value-of select="'/ps/'"/></xsl:when>
- <xsl:when test="@type = 'nav'"><!-- Do nothing nav fills in the pieces for us --></xsl:when>
- <xsl:when test="starts-with(@type,'skin')">
- <out:variable name="user_skin">
- <out:choose>
- <out:when test="key('user-param', 'skin') != ''">
- <out:value-of select="key('user-param', 'skin')"/>
- </out:when>
- <out:otherwise>
- <out:value-of select="key('system-param', 'defaultPortalPreferences')/pref[@name='skin']"/>
- </out:otherwise>
- </out:choose>
- </out:variable>
- <out:variable name="portal_or_shared">
- <xsl:choose>
- <xsl:when test="@type = 'skin_shared'">
- <out:value-of select="key('system-param','skin_shared_images')"/>
- </xsl:when>
- <xsl:otherwise>
- <out:value-of select="$common_app"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
- <out:value-of select="concat('/skins/', $user_skin, '/', $portal_or_shared, '/images/')"/>
- </xsl:when>
- </xsl:choose>
- </out:variable>
- <out:variable name="image-encoded-path"><out:value-of select="cogadminext:urlencode($image)"/></out:variable>
- <out:value-of select="concat('_THIS?frag-resource=', $webcontentPath, $image-encoded-path, '/THIS_')"/>
- </xsl:template>
- <!--
- admui:gen-runnable-icon: generates the icons for runnable classes
- @objectClass or admui:objectClass - The class of the object
- @iconURI or admui:iconURI - property on the runnable to override the icon
- -->
- <xsl:template match="admui:gen-runnable-icon">
- <out:variable name="objectClass">
- <xsl:choose>
- <xsl:when test="@objectClass != ''"><xsl:value-of select="@objectClass"/></xsl:when>
- <xsl:when test="admui:objectClass"><xsl:apply-templates select="admui:objectClass"/></xsl:when>
- </xsl:choose>
- </out:variable>
-
- <out:variable name="defaultName">
- <out:choose>
- <out:when test="/root/runnables/class[@name = string($objectClass)]/displayName != ''"><out:apply-templates select="/root/runnables/class[@name = string($objectClass)]/displayName"/></out:when>
- <out:otherwise>
- <xsl:if test="admui:defaultName"><xsl:apply-templates select="admui:defaultName"/></xsl:if>
- </out:otherwise>
- </out:choose>
- </out:variable>
-
- <out:variable name="screenTip">
- <xsl:choose>
- <xsl:when test="admui:screenTip"><xsl:apply-templates select="admui:screenTip"/></xsl:when>
- </xsl:choose>
- </out:variable>
-
- <out:variable name="icon">
- <xsl:choose>
- <xsl:when test="@iconURI != ''"><xsl:value-of select="@iconURI"/></xsl:when>
- <xsl:when test="admui:iconURI != ''"><xsl:apply-templates select="admui:iconURI"/></xsl:when>
- <xsl:otherwise>
- <out:choose>
- <out:when test="/root/runnables/class[@name = string($objectClass)]/icon">
- <out:value-of select="/root/runnables/class[@name = string($objectClass)]/icon"/>
- </out:when>
- <out:otherwise>
- <out:value-of select="'icon_unknown.gif'"/>
- </out:otherwise>
- </out:choose>
- </xsl:otherwise>
- </xsl:choose>
- </out:variable>
-
- <out:variable name="disabled">
- <xsl:choose>
- <xsl:when test="admui:disabled"><xsl:apply-templates select="admui:disabled"/></xsl:when>
- </xsl:choose>
- </out:variable>
- <uic:icon uic:noSpace="true">
- <out:attribute name="disabled">
- <out:value-of select="$disabled"/>
- </out:attribute>
- <uic:src>
- <out:choose>
- <!-- the specification icon is from cogadmin -->
- <out:when test="$objectClass = 'specification' ">
- <out:value-of select="concat('_THIS?frag-resource=/ps/', $app, '/images/icon_preview.gif', '/THIS_')"/>
- </out:when>
- <!-- all other runnable icons come the ps images directory -->
- <out:otherwise>
- <out:value-of select="concat('_THIS?frag-resource=/ps/', $common_app, '/images/', $icon, '/THIS_')"/>
- </out:otherwise>
- </out:choose>
- </uic:src>
- <uic:tooltip>
- <out:choose>
- <out:when test="$screenTip != ''">
- <out:value-of select="concat($defaultName, ' - ', $screenTip)"/>
- </out:when>
- <out:otherwise>
- <out:value-of select="$defaultName"/>
- </out:otherwise>
- </out:choose>
- <out:if test="$disabled = 'true'"> - <xts:string id="IDS_ADM_HIDDEN_OBJECT"/></out:if>
- </uic:tooltip>
- </uic:icon>
- </xsl:template>
-
- <xsl:template match="uic:column[not(ancestor::uic:table[1]/uic:features/uic:hideTenant='true') and position()=last() and parent::uic:row]">
- <xsl:variable name="colCopy">
- <xsl:copy-of select="."/>
- </xsl:variable>
- <xsl:apply-templates select="$colCopy"/>
- <out:if test="//root/session/param[@name='e_showTenantInfo']='true'">
- <xsl:choose>
- <xsl:when test="local-name(../..)='header'">
- <xsl:variable name="colTenant">
- <uic:column nowrap="nowrap">
- <uic:text><xts:string id="IDS_ADM_TENANT"/></uic:text>
- </uic:column>
- </xsl:variable>
- <xsl:apply-templates select="$colTenant"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="colTenant">
- <uic:column nowrap="nowrap">
- <!--TODO: Change this if applicable for various xts-->
- <uic:text><out:value-of select="*[local-name()='tenantName']"/></uic:text>
- </uic:column>
- </xsl:variable>
- <xsl:apply-templates select="$colTenant"/>
- </xsl:otherwise>
- </xsl:choose>
- </out:if>
- </xsl:template>
-
- <xsl:template match="*">
- <xsl:copy>
- <xsl:copy-of select="@*"/>
- <xsl:apply-templates/>
- </xsl:copy>
- </xsl:template>
- </xsl:stylesheet>
|