123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429 |
- <?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).
- -->
- <!-- $Header: //cpscrn/main/templates/cps4/portlets/nav/includes/nav-common-include.xslt#1 $ -->
- <!-- $DateTime: 2008/10/22 11:12:04 $ -->
- <!-- $Change: 25109 $ -->
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
- <xsl:attribute-set name="anchor">
- <xsl:attribute name="class">cognos-anchor</xsl:attribute>
- <xsl:attribute name="onmouseover">window.status='';return true;</xsl:attribute>
- <xsl:attribute name="onmouseout">window.status='';return true;</xsl:attribute>
- </xsl:attribute-set>
- <xsl:variable name="href-prefix">
- <xsl:text>wsrp_rewrite?wsrp-urlType=render&wsrp-windowState=</xsl:text>
- <xsl:choose>
- <xsl:when test="$display-maximize = 'true'">wsrp:maximized</xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$ui-window-state"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>&wsrp-navigationalState=</xsl:text>
- </xsl:variable>
- <xsl:variable name="href-suffix">/wsrp_rewrite</xsl:variable>
-
- <xsl:variable name="path-root" select="/root/portlet/consumer/layout/path/start"/>
- <xsl:variable name="path-separator" select="/root/portlet/consumer/layout/path/separator"/>
- <xsl:template name="nav-script-openWindow">
- <xsl:param name="redirectURL"/>
-
- <xsl:variable name="state-open-links" select="$ui-state-params[@name = 'open_links']"/>
-
- <!--
- This variable will decide whether the client side nav rewriting is enabled.
- We rewrite urls if we are in cc and "open links" is set to current window
- -->
- <xsl:variable name="is-client-rewrite-enabled" select="$state-open-links='current' and $ui-is-cognos-connection"/>
-
- <xsl:if test="$is-client-rewrite-enabled">
- <script language="javascript" src="{$ui-webcontent}cr1/caf.js"/>
- </xsl:if>
-
-
- <script language="javascript">
-
- <xsl:if test="$is-client-rewrite-enabled">
- <!--
- This javascript method is used when open-links is set to current and the portal agent is CC.
- It is used to insert the back url in a given url.
- -->
- <xsl:variable name="navState">
- <xsl:for-each select="$ui-navigational-params">
- <xsl:call-template name="gen-param">
- <xsl:with-param name="name" select="@name"/>
- <xsl:with-param name="value" select="."/>
- </xsl:call-template>
- </xsl:for-each>
- </xsl:variable>
-
- <xsl:value-of select="xtsext:cafaction('get_jsconfig', '')"/>
-
- <!--This rewritable url contains the "cps-rewrite-flags=p0" parameter telling the assembler not to protect it -->
- var wsrp_rewrite_backUrl_no_protect = "wsrp_rewrite?wsrp-urlType=render&cps-rewrite-flags=p0/wsrp_rewrite";
- var wsrp_rewrite_backUrl = "wsrp_rewrite?wsrp-urlType=render/wsrp_rewrite";
- <!--ask for rewritabe urls with no back url, in case the regular one breaks the url length limit, we can use this shorter version-->
- var wsrp_rewrite_backUrl_no_protect_nb = "wsrp_rewrite?wsrp-urlType=render&cps-rewrite-flags=p0b0/wsrp_rewrite";
- var wsrp_rewrite_backUrl_nb = "wsrp_rewrite?wsrp-urlType=render&cps-rewrite-flags=b0/wsrp_rewrite";
- function wsrp_rewrite_getBackUrlParam(shortVersion)
- {
- var backParam = "";
- if (shortVersion == 0){
- backParam = encodeURIComponent(wsrp_rewrite_backUrl);
- } else if (shortVersion == 1){
- backParam = encodeURIComponent(wsrp_rewrite_backUrl_nb);
- }
- return backParam;
- }
-
- function wsrp_rewrite_getAbsoluteBackUrlParam(shortVersion){
-
- var currentWindowWithoutParams = document.location.href;
- if (currentWindowWithoutParams.indexOf("?") != -1){
- currentWindowWithoutParams = currentWindowWithoutParams.substring(0, currentWindowWithoutParams.indexOf("?"));
- }
-
- var url = "";
- if (wsrp_rewrite_backUrl.indexOf("?") != -1){
- if (shortVersion == 0 ){
- url = currentWindowWithoutParams + wsrp_rewrite_backUrl_no_protect.substring(wsrp_rewrite_backUrl.indexOf("?"));
- } else if (shortVersion == 1 ){
- url = currentWindowWithoutParams + wsrp_rewrite_backUrl_no_protect_nb.substring(wsrp_rewrite_backUrl.indexOf("?"));
- }
- }
- return encodeURIComponent(url);
- }
-
- function wsrp_rewrite_rewriteBackUrlHelper(url, shortVersion)
- {
- if (url.indexOf("navrewritebackurlnoprotect") != -1){
- var backurl = wsrp_rewrite_getBackUrlParam(shortVersion);
- url = url.replace("navrewritebackurlnoprotect",backurl);
- }
- else if (url.indexOf("navrewritebackurl") != -1){
- var backurl = wsrp_rewrite_getBackUrlParam(shortVersion);
- // protect the back url
- if (CAFXSSEncode){
- backurl = CAFXSSEncode(backurl);
- }
- url = url.replace("navrewritebackurl",backurl);
- }
- else if (url.indexOf("navrewriteabsolutebackurl") != -1){
- var absolute_backurl = wsrp_rewrite_getAbsoluteBackUrlParam(shortVersion);
- url = url.replace("navrewriteabsolutebackurl",absolute_backurl);
- if (CAFS7XSSEncodeURL){
- url = CAFS7XSSEncodeURL(url);
- }
- }
- return url;
- }
-
- function wsrp_rewrite_rewriteBackUrl(url)
- {
- var r_url = wsrp_rewrite_rewriteBackUrlHelper(url, 0);
- if (r_url.length > 2048){
- // length exceeds the limit, use a short version of the back url ( one without a back url )
- r_url = wsrp_rewrite_rewriteBackUrlHelper(url, 1);
- if (r_url.length > 2048){
- // we again exceeded the limit, use a blank backurl
- r_url = wsrp_rewrite_rewriteBackUrlHelper(url, 2);
- }
- }
- return r_url;
- }
-
- </xsl:if>
-
-
- function wsrp_rewrite_openWindow( url, name, properties, e, redirect )
- {
- var targetUrl = encodeURIComponent(url);
-
- if ( redirect != null ) {
- wsrp_rewrite_post_window_open( redirect + targetUrl, name, properties );
- } else {
- wsrp_rewrite_post_window_open( "<xsl:value-of select="xtsext:javascriptencode(string($redirectURL))"/>" + targetUrl, name, properties );
- }
- // stop event propagation, no one above us needs to know about this.
- if ( e.srcElement ) {
- e.returnValue = false;
- } else {
- e.preventDefault();
- }
- }
- var wsrp_rewrite_post_window_uid = 0;
- function wsrp_rewrite_post_window_open(url, name, properties) {
- if (name==null || name=="" || name=="_blank") {
- if (properties==null || properties=="") {
- name = "_blank";
- } else {
- name= "wsrp_rewrite_post_window" + wsrp_rewrite_post_window_uid++;
- }
- }
- if (! (name=="_top" || name=="_parent" || name=="_self" || name=="_blank")) {
- window.open("about:blank",name,properties);
- }
-
- var formElement = document.createElement("form");
- formElement.setAttribute("name","wsrp_rewrite_post_window_form");
- formElement.setAttribute("method","POST");
- formElement.setAttribute("target", name);
-
- var qm_index = url.indexOf("?");
- var action = (qm_index==-1) ? url : url.substring(0, qm_index);
- formElement.setAttribute("action", action);
-
- if (qm_index != -1) {
- var paramString = url.substring(qm_index+1);
- var params = paramString.split("&");
- var i;
- for (i=0; i < params.length; ++i) {
- if (params[i].length>0) {
- var hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- var eq_index = params[i].indexOf("=");
- if (eq_index != -1) {
- hiddenElement.setAttribute("name",decodeURIComponent(params[i].substring(0,eq_index)));
- hiddenElement.setAttribute("value",decodeURIComponent(params[i].substring(eq_index+1)));
- } else {
- hiddenElement.setAttribute("name",decodeURIComponent(params[i]));
- hiddenElement.setAttribute("value","");
- }
- formElement.appendChild(hiddenElement);
- }
- }
- }
- document.body.appendChild(formElement);
- formElement.submit();
- document.body.removeChild(formElement);
- formElement = null;
- }
- </script>
- </xsl:template>
- <xsl:template name="nav-script-keyPressed">
- <xsl:param name="browser"/>
- <xsl:param name="submit" select="'wsrp_rewrite_submit()'"/>
- <xsl:choose>
- <xsl:when test="$browser = 'ie' or $browser = 'safari'">
- function wsrp_rewrite_keyPressed()
- {
- if (13 == window.event.keyCode) {
- <xsl:value-of select="$submit"/>;
- event.returnValue = false;
- }
- return true;
- }
- </xsl:when>
- <xsl:otherwise>
- window.captureEvents(Event.KEYPRESS);
- function wsrp_rewrite_keyPressed(e)
- {
- if (e.which == 13) {
- <xsl:value-of select="$submit"/>;
- return false;
- }
- return true;
- }
- window.onkeypress=wsrp_rewrite_keyPressed;
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template name="gen-param">
- <xsl:param name="name" select="@name"/>
- <xsl:param name="value" select="."/>
- <xsl:text><param name="</xsl:text>
- <xsl:value-of select="$name"/>
- <xsl:text>"></xsl:text>
- <xsl:value-of select="xtsext:xmlencode(string($value))"/>
- <xsl:text></param></xsl:text>
- </xsl:template>
- <xsl:template name="gen-anchor-attr">
- <xsl:param name="url" select="nav:url"/>
- <xsl:param name="window-properties" select="nav:windowProperties"/>
- <xsl:param name="redirectURL"/>
- <xsl:param name="open-links" select="'new'"/>
- <xsl:param name="channel-onclick"/>
- <xsl:param name="reset-channel-onclick"/>
- <xsl:param name="target"/>
-
- <xsl:variable name="check-redirect-url">
- <xsl:choose>
- <xsl:when test="nav:redirectURL != ''">
- <xsl:value-of select="nav:redirectURL"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$redirectURL"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="new-window-override" select="$window-properties != ''"/>
- <xsl:variable name="p2pc-override" select="self::nav:container or nav:viewable='false' or self::nav:shortcut/nav:container or self::nav:shortcut/nav:item/nav:viewable = 'false'"/>
-
- <xsl:variable name="check-target">
- <xsl:choose>
- <xsl:when test="($open-links = 'current') and not($new-window-override) and not($ui-is-myportal)">
- <xsl:value-of select="'_self'"/>
- </xsl:when>
- <xsl:when test="($open-links = 'target') and not($new-window-override)">
- <xsl:value-of select="$target"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="'_blank'"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!--
- When this template is called the current element could be the actual nav item or the nav action itself.
- If the current object is the nav item, the context should be the default action element, otherwise it's the action itself.
- -->
- <xsl:variable name="context" select="(self::nav:action | self::*/nav:defaultAction)[1]"/>
- <xsl:choose>
- <!--
- - p2pc is enabled
- - The object support p2pc (e.g. a container do not support p2pc)
- -->
- <xsl:when test="$channel-onclick != '' and not($p2pc-override)">
- <xsl:attribute name="href">#</xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:value-of select="$channel-onclick"/>
- </xsl:attribute>
- </xsl:when>
- <!--
- "Open in current window" is enabled, the url is not external and we are in CC.
- We need to add a back url using javscript
- -->
- <xsl:when test="$check-target = '_self' and not($url/@type = 'external') and $ui-is-cognos-connection">
- <xsl:attribute name="href">#</xsl:attribute>
- <xsl:choose>
- <xsl:when test="$check-redirect-url != ''">
- <xsl:attribute name="onclick">
- <xsl:text>wsrp_rewrite_openWindow(wsrp_rewrite_rewriteBackUrl('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($url))"/>
- <xsl:text>'),'</xsl:text>
- <xsl:value-of select="$check-target"/>
- <xsl:text>','',event</xsl:text>
- <xsl:if test="nav:redirectURL != ''">
- <xsl:text>,wsrp_rewrite_rewriteBackUrl('</xsl:text>
- <xsl:value-of select="nav:redirectURL"/>
- <xsl:text>')</xsl:text>
- </xsl:if>
- <xsl:text>)</xsl:text>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="onclick">
- <xsl:text>document.location=wsrp_rewrite_rewriteBackUrl('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($url))"/>
- <xsl:text>');</xsl:text>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <!--
- We have a redirect url and the url is not external.
- -->
- <xsl:when test="$check-redirect-url != '' and not($url/@type = 'external')">
- <xsl:attribute name="href">#</xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:text>wsrp_rewrite_openWindow('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($url))"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$check-target"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$window-properties"/>
- <xsl:text>',event</xsl:text>
- <xsl:if test="nav:redirectURL != ''">
- <xsl:text>,'</xsl:text>
- <xsl:value-of select="nav:redirectURL"/>
- <xsl:text>'</xsl:text>
- </xsl:if>
- <xsl:text>)</xsl:text>
- <xsl:if test="$reset-channel-onclick != '' ">
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$reset-channel-onclick"/>
- </xsl:if>
- </xsl:attribute>
- </xsl:when>
- <!--
- We do not have a redirect url but we explicitly asked for POST
- -->
- <xsl:when test="$context/nav:usePost = 'true' ">
- <xsl:attribute name="href">#</xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:text>wsrp_rewrite_post_window_open('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode($url)"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$check-target"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$window-properties"/>
- <xsl:text>')</xsl:text>
- <xsl:if test="$reset-channel-onclick != '' ">
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$reset-channel-onclick"/>
- </xsl:if>
- </xsl:attribute>
- </xsl:when>
- <!-- We do not have a redirect url but we have a window properties-->
- <xsl:when test="$window-properties != ''">
- <xsl:attribute name="href">#</xsl:attribute>
- <xsl:attribute name="onclick">
- <xsl:text>window.open('</xsl:text>
- <xsl:value-of select="xtsext:javascriptencode(string($url))"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$check-target"/>
- <xsl:text>','</xsl:text>
- <xsl:value-of select="$window-properties"/>
- <xsl:text>')</xsl:text>
- <xsl:if test="$reset-channel-onclick != '' ">
- <xsl:text>;</xsl:text>
- <xsl:value-of select="$reset-channel-onclick"/>
- </xsl:if>
- </xsl:attribute>
- </xsl:when>
- <!-- default -->
- <xsl:otherwise>
- <xsl:attribute name="href">
- <xsl:value-of select="$url"/>
- </xsl:attribute>
- <xsl:attribute name="target">
- <xsl:value-of select="$check-target"/>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|