123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- <?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:xtsext="xalan://com.cognos.xts.ext.XTSExt"
- xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
- xmlns:xts="http://developer.cognos.com/schemas/xts/"
- xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
- xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/">
- <xsl:variable name="params" select="/root/interactions/param | /root/state/param | /root/transients/param | /root/customs/param"/>
- <!-- Preferences vars -->
- <xsl:variable name="preferences" select="/root/bus:biBusHeader/bus:userPreferenceVars"/>
- <xsl:variable name="linesPerPage" select="$preferences/item[name = 'linesPerPage']/value"/>
- <xsl:variable name="productLocale" select="$preferences/item[name = 'productLocale']/value"/>
- <xsl:variable name="contentLocale" select="$preferences/item[name = 'contentLocale']/value"/>
- <xsl:variable name="display-separator" select="$preferences/item[name = 'listViewSeparator']/value"/>
- <xsl:variable name="skin">
- <xsl:choose>
- <xsl:when test="string($params[@name='skin']) != ''"><xsl:value-of select="$params[@name='skin']"/></xsl:when>
- <xsl:otherwise><xsl:value-of select="$preferences/item[name = 'skin']/value"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="webRoot">
- <xsl:choose>
- <xsl:when test="string($params[@name='webRoot']) != ''"><xsl:value-of select="$params[@name='webRoot']"/></xsl:when>
- <xsl:otherwise><xsl:call-template name="calculateWebContent"/></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- HTTP env vars -->
- <xsl:variable name="environmentVars" select="/root/bus:biBusHeader/*[local-name() = 'hdrSession']/bus:environmentVars"/>
-
- <xsl:variable name="mvc-virtualRootName"><xts:string id="IDS_MVC_VIRTUALROOT_NAME"/></xsl:variable>
-
- <xsl:attribute-set name="anchor"/>
-
- <xsl:template name="calculateWebContent">
- <xsl:variable name="webContentRoot" select="$environmentVars/item[name = 'WEB_CONTENT_ROOT']/value"/>
- <xsl:variable name="configured-gateway" select="/root//configured-gateway/configuration/property[@name='gateway']"/>
-
- <xsl:choose>
- <xsl:when test="starts-with($webContentRoot, 'http')">
- <xsl:value-of select="$webContentRoot"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="starts-with($webContentRoot, '..')">
- <xsl:variable name="v" select="xtsext:substringBeforeLast($configured-gateway, '/')"/>
- <xsl:value-of select="$v"/>/<xsl:value-of select="$webContentRoot"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="protocol" select="substring-before($configured-gateway, '//')"/>
- <xsl:variable name="after-protocol" select="substring-after($configured-gateway, '//')"/>
- <xsl:variable name="server" select="substring-before($after-protocol, '/')"/>
- <xsl:value-of select="$protocol"/>//<xsl:value-of select="$server"/><xsl:value-of select="$webContentRoot"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="build-url">
- <xsl:param name="action"/>
- <xsl:param name="is-defaultAction"/>
-
- <xsl:variable name="isTraverseAction" select="$action/nav:name = 'traverse'"/>
-
- <xsl:choose>
- <xsl:when test="$isTraverseAction">
- <xsl:text/>_THIS_navigate('<xsl:value-of select="$action/../nav:id"/>')<xsl:text/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="submitMethod">
- <xsl:choose>
- <xsl:when test="$is-defaultAction">GET</xsl:when>
- <xsl:otherwise>POST</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="gateway">
- <xsl:choose>
- <xsl:when test="$action/nav:url and $action/nav:url[@type='external']">
- <xsl:value-of select="xtsext:javascriptencode($action/nav:url[@type='external'])"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="xtsext:javascriptencode($action/nav:urlParts/nav:gateway)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="formParams">
- <xsl:text/>_THIS_formParams('<xsl:value-of select="$submitMethod"/>'<xsl:text/>
- <xsl:for-each select="$action/nav:urlParts/nav:param[@name != 'cv.header']">
- <xsl:text/>,'<xsl:value-of select="@name"/>','<xsl:text/>
- <xsl:choose>
- <xsl:when test="$submitMethod = 'POST'">
- <xsl:value-of select="xtsext:javascriptencode(string(.))"/>
- </xsl:when>
- <xsl:when test="@name='m_path' or @name='m_obj'">
- <xsl:value-of select="xtsext:javascriptencode(xtsext:protect(xtsext:urlencode(string(.)),'url','searchPath','getdata'))"/><xsl:text/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="xtsext:javascriptencode(xtsext:protect(xtsext:urlencode(string(.)),'url','userData','getdata'))"/><xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text/>'<xsl:text/>
- </xsl:for-each>
- <xsl:text/>)<xsl:text/>
- </xsl:variable>
-
- <xsl:text/>javascript:_THIS_run_url(<xsl:text/>
- <xsl:text/>'<xsl:value-of select="$gateway"/>',<xsl:text/>
- <xsl:value-of select="$formParams"/>
- <xsl:choose>
- <xsl:when test="$action/nav:windowProperties">
- <xsl:text/>, '_blank'<xsl:text/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text/>, '_parent'<xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text/>, '<xsl:value-of select="$submitMethod"/>'<xsl:text/>
- <xsl:if test="$action/nav:windowProperties">
- <xsl:text/>, '<xsl:value-of select="$action/nav:windowProperties"/>'<xsl:text/>
- </xsl:if>
- <xsl:text/>)<xsl:text/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="common-include">
- <script language="javascript">
- function _THIS_retrieve(params) {
- var webRoot = '<xsl:value-of select="xtsext:javascriptencode(xtsext:urlencode($webRoot))"/>';
- var skin = '<xsl:value-of select="xtsext:javascriptencode(xtsext:urlencode($skin))"/>';
- var env_params = "&webRoot=" + webRoot + "&skin=" + skin;
-
- _THIS_.retrieve(params + env_params);
- }
-
- function _THIS_goto(from, to) {
- if (isNaN(from) || parseInt(from, 10) <= 0) {
- alert("<xts:string id="IDS_MVC_ERR_FROM_INVALID" encode="javascript"/>");
- return false;
- }
-
- if (isNaN(to) || parseInt(to, 10) <= 0) {
- alert("<xts:string id="IDS_MVC_ERR_TO_INVALID" encode="javascript"/>");
- return false;
- }
-
- from = parseInt(from, 10);
- to = parseInt(to, 10);
-
- if (from > to) {
- window.alert('<xts:string id="IDS_MVC_ERR_FIRST_BIGGER_SECOND" encode="javascript"/>');
- return false;
- }
-
- var skip = from - 1;
- var maxobjs = to - from + 1;
- _THIS_retrieve('skip=' + skip + '&maxobjs=' + maxobjs);
- }
-
- function _THIS_sort(category, currentSort) {
- var sort = "";
-
- if (currentSort.indexOf(category + '_') == 0) {
- if (currentSort.indexOf("_a") != -1) {
- sort = category + "_d";
- } else if (currentSort.indexOf("_d") != -1) {
- sort = "";
- } else {
- sort = category + "_a";
- }
- } else {
- sort= category + "_a";
- }
- _THIS_retrieve('sort=' + encodeURIComponent(sort));
- }
- </script>
-
- <!-- Scripts to handle running report, editing on objects in remote system -->
- <script language="javascript">
- var _THIS_post_window_name = "_self";
- var _THIS_post_window_uid = 0;
- function _THIS_run_url(gateway, paramsArray, name, submitMethod, properties) {
- if (name == null || name == "" || name == "_blank") {
- if (properties == null || properties == "") {
- name = "_blank";
- } else {
- name= "_THIS_post_window" + _THIS_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", "_THIS_post_window_form");
- formElement.setAttribute("method", submitMethod);
- formElement.setAttribute("target", name);
-
- formElement.setAttribute("action", gateway);
-
- for (i = 0; i < paramsArray.length; i+=2) {
- var name = paramsArray[i];
- var value = paramsArray[i+1];
-
- if (submitMethod == "GET") {
- value = decodeURIComponent(value);
- }
-
- var hiddenElement = document.createElement("input");
- hiddenElement.setAttribute("type","hidden");
- hiddenElement.setAttribute("name", name);
- hiddenElement.setAttribute("value", value);
- formElement.appendChild(hiddenElement);
- }
-
- document.body.appendChild(formElement);
- formElement.submit();
- document.body.removeChild(formElement);
- formElement = null;
- }
-
- function _THIS_formParams(submitMethod) {
- var paramsArray = new Array();
-
- for (i = 1; i < arguments.length; i+=2) {
- var name = arguments[i];
- var value = arguments[i+1];
-
- paramsArray[i-1] = name;
- if (value == "navrewritebackurl" || value == "navrewriteabsolutebackurl") {
- paramsArray[i] = _THIS_rewriteBackUrlHelper(submitMethod);
- } else {
- paramsArray[i] = value;
- }
- }
-
- return paramsArray;
- }
-
- <!-- rewrite of backURL -->
- function _THIS_rewriteBackUrlHelper(submitMethod) {
- var backURL;
-
- if (submitMethod == "POST" && typeof _THIS_.mvc_back_url != 'undefined') {
- backURL = _THIS_.mvc_back_url;
- } else if (submitMethod == "GET" && typeof _THIS_.encoded_mvc_back_url != 'undefined') {
- backURL = _THIS_.encoded_mvc_back_url;
- } else {
- backURL = "javascript:window.close();";
- }
-
- return backURL;
- }
-
- <!-- DOM helpers -->
- function _THIS_getElementText(element) {
- if (element.childNodes && element.childNodes.length > 1) {
- return element.childNodes[1].nodeValue;
- } else if(element.firstChild) {
- return element.firstChild.nodeValue;
- } else {
- return "";
- }
- }
- function _THIS_getSingleElementByTagName(element,tagName) {
- var results = element.getElementsByTagName(tagName);
- if (results) {
- if (results.length > 0) {
- return results[0];
- }
- }
- return null;
- }
- function _THIS_getvalueOfSingleElementByTagName(element,tagName) {
- var e = _THIS_getSingleElementByTagName(element, tagName);
- if (e) {
- return _THIS_getElementText(e);
- }
- return "";
- }
- </script>
- </xsl:template>
- </xsl:stylesheet>
|