multi-instance.xsl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: ps
  5. (C) Copyright IBM Corp. 2005, 2011
  6. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <!--
  9. Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  10. Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  11. -->
  12. <xsl:stylesheet version="1.0"
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  14. xmlns:out="dummy-uri"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  17. xmlns:mvc="http://developer.cognos.com/schemas/xts/mvc"
  18. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  19. exclude-result-prefixes="mvc xtsext xts cp">
  20. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  21. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  22. <xsl:template match="mvc:instance-vars">
  23. <out:variable name="fragment-id">
  24. <out:choose>
  25. <out:when test="/root/search">
  26. <out:text/>mvcs<out:text/>
  27. </out:when>
  28. <out:otherwise>
  29. <out:choose>
  30. <out:when test="$isMFNav">mvcmf</out:when>
  31. <out:otherwise>mvcpf</out:otherwise>
  32. </out:choose>
  33. </out:otherwise>
  34. </out:choose>
  35. </out:variable>
  36. <out:variable name="rcr-id" select="$rootReply/*/cm:storeID"/>
  37. <out:variable name="cookied-rcr-id">
  38. <out:variable name="cookied-fragstate">
  39. <out:choose>
  40. <out:when test="$mvc-remotePFNav"><out:value-of select="string(/root/cookies/cookie[@name='mvcpfstate'])"/></out:when>
  41. <out:otherwise><out:value-of select="string(/root/cookies/cookie[@name='mvcmfstate'])"/></out:otherwise>
  42. </out:choose>
  43. </out:variable>
  44. <out:choose>
  45. <out:when test="$mvc-remotePFNav"><out:value-of select="translate(substring-before($cookied-fragstate, ':'), '&quot;', '')"/></out:when>
  46. <out:otherwise><out:value-of select="translate(substring-before($cookied-fragstate, ':'), '&quot;', '')"/></out:otherwise>
  47. </out:choose>
  48. </out:variable>
  49. </xsl:template>
  50. <xsl:template match="mvc:instance">
  51. <out:variable name="id" select="{@id}"/>
  52. <script language="javascript">
  53. <!--
  54. * Retrieve the N-1 gateway to set the domain for Javascript to work properly between N and N-1 spaces.
  55. * See also its counterpart: ../portal/mvc/remote/frag-handler.xsl.
  56. -->
  57. <out:variable name="domain">
  58. <out:choose>
  59. <out:when test="$mvc-domain != ''">
  60. <!-- Use the configured domain in 'MVC_domain', if specified -->
  61. <out:value-of select="$mvc-domain"/>
  62. </out:when>
  63. <out:otherwise>
  64. <!-- MVC_domain not specified, parse the gateway -->
  65. <out:call-template name="parseDocumentDomain">
  66. <out:with-param name="url" select="$mvc-remote-gateway"/>
  67. </out:call-template>
  68. </out:otherwise>
  69. </out:choose>
  70. </out:variable>
  71. <out:if test="$domain != ''">
  72. document.domain = "<out:value-of select="$domain"/>"; // N side
  73. </out:if>
  74. </script>
  75. <script language="javascript">
  76. var mvc_frame_id = "<out:value-of select="xtsext:javascriptencode($id)"/>" + "_frame";
  77. var fragment_id = "<out:value-of select="xtsext:javascriptencode($fragment-id)"/>";
  78. var rcr_id = "<out:value-of select="xtsext:javascriptencode($rcr-id)"/>";
  79. function remoteFragmentUnloads(frag_state, isMaintainState) {
  80. var state = null;
  81. if (isMaintainState) {
  82. if (frag_state != null &amp;&amp; frag_state.length > 0) {
  83. state = frag_state;
  84. }
  85. } else {
  86. state = ""; // clear the state
  87. }
  88. if (state != null) {
  89. parent.mvcSetFragmentState(fragment_id + "state", state);
  90. }
  91. }
  92. function clearMVCState(mode) {
  93. var isSearchFragment = (fragment_id.indexOf('mvcs') == 0);
  94. if (mode == "search") {
  95. delCookie("mvcsstate");
  96. if (isSearchFragment &amp;&amp; document.getElementById(mvc_frame_id) != null) {
  97. document.getElementById(mvc_frame_id).contentWindow.clearMVCState();
  98. }
  99. } else {
  100. delCookie("mvcpfstate");
  101. delCookie("mvcmfstate");
  102. if (!isSearchFragment &amp;&amp; document.getElementById(mvc_frame_id) != null) {
  103. document.getElementById(mvc_frame_id).contentWindow.clearMVCState();
  104. }
  105. }
  106. }
  107. function mvcSetFragmentState(name, state) {
  108. if (state != '') {
  109. state = "\"" + rcr_id + ":" + state + "\"";
  110. }
  111. setCookie(name, state);
  112. }
  113. function mvcGetFragmentState(fragment_id) {
  114. var cookied_fragstate = getCookie(fragment_id + "state");
  115. if (cookied_fragstate != null &amp;&amp; cookied_fragstate != "") {
  116. if (cookied_fragstate.indexOf("\"") == 0 &amp;&amp; cookied_fragstate.lastIndexOf("\"") == cookied_fragstate.length-1)
  117. cookied_fragstate = cookied_fragstate.substring(1, cookied_fragstate.length-1);
  118. var cookied_RCRid = "";
  119. var idx = cookied_fragstate.indexOf(":");
  120. if (idx != -1) {
  121. cookied_RCRid = cookied_fragstate.substring(0, idx);
  122. cookied_fragstate = cookied_fragstate.substring(idx+1);
  123. }
  124. if (cookied_RCRid != rcr_id) {
  125. cookied_fragstate = "";
  126. }
  127. } else {
  128. cookied_fragstate = "";
  129. }
  130. return cookied_fragstate;
  131. }
  132. function mvcGetInitialParams() {
  133. var initial_parameters = '<out:value-of select="xtsext:javascriptencode(string({@fragment-params}))"/>';
  134. return initial_parameters;
  135. }
  136. function mvcGetBackURL() {
  137. var mvc_back_url = '<out:value-of select="xtsext:javascriptencode($mvc-back-url)"/>';
  138. return mvc_back_url;
  139. }
  140. function mvcGetEncodedBackURL() {
  141. encoded_mvc_back_url = '<out:value-of select="xtsext:javascriptencode($encoded-mvc-back-url)"/>';
  142. return encoded_mvc_back_url;
  143. }
  144. function mvcSetNavigationId(id) {
  145. g_PS_mvcRemoteFolderContext = id;
  146. }
  147. function mvcGotoCognosRoot() {
  148. <out:variable name="gotourl">
  149. <out:value-of select="concat($gateway,'?b_action=xts.run&amp;m=portal/cc.xts')"/>
  150. <out:text/>&amp;m_folder=<out:text/>
  151. <out:choose>
  152. <out:when test="$isPFNav"><out:value-of select="key('session-param', 'prootid')"/></out:when>
  153. <out:otherwise><out:value-of select="key('session-param', 'mrootid')"/></out:otherwise>
  154. </out:choose>
  155. </out:variable>
  156. if (document.getElementById(mvc_frame_id) != null)
  157. document.getElementById(mvc_frame_id).contentWindow.clearMVCState();
  158. var gotourl = "<out:value-of select="xtsext:javascriptencode($gotourl)"/>";
  159. window.setTimeout("window.location.href='" + gotourl + "';", 10);
  160. }
  161. function mvcNavigateTo(id) {
  162. if (document.getElementById(mvc_frame_id) != null)
  163. document.getElementById(mvc_frame_id).contentWindow.clearMVCState();
  164. mvcSetFragmentState("mvcsstate", "");
  165. mvcSetFragmentState("mvcpfstate", "");
  166. mvcSetFragmentState("mvcmfstate", "");
  167. <out:variable name="navurl">
  168. <out:value-of select="concat($gateway,'?b_action=xts.run&amp;m=portal/cc.xts')"/>
  169. <out:text/>&amp;m_folder=<out:value-of select="xtsext:protect(xtsext:urlencode($rcr-id),'url', concat('NAME', 'rcr-id'),'getdata')"/>
  170. </out:variable>
  171. var navurl = "<out:value-of select="xtsext:javascriptencode($navurl)"/>";
  172. navurl += "&amp;mvc-sfolder=" + id;
  173. window.setTimeout("window.location.href='" + navurl + "';", 10);
  174. }
  175. </script>
  176. <!-- Create the iframe to retrieve remote contents -->
  177. <out:variable name="url">
  178. <out:value-of select="$mvc-remote-gateway"/>
  179. <out:text/>?b_action=xts.run<out:text/>
  180. <out:text/>&amp;m=portal/mvc/remote/<out:value-of select="$id"/>-frame.xts<out:text/>
  181. <out:text/>&amp;mvcfragment-id=<out:value-of select="$fragment-id"/>
  182. </out:variable>
  183. <iframe id="{'{$id}'}_frame" src="{'{$url}'}" width="100%" height="80%" frameborder="0" marginheight="0" marginwidth="2"></iframe>
  184. </xsl:template>
  185. <xsl:template match="*">
  186. <xsl:copy>
  187. <xsl:copy-of select="@*"/>
  188. <xsl:apply-templates/>
  189. </xsl:copy>
  190. </xsl:template>
  191. </xsl:stylesheet>