fragmentBridge.xts 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cpscrn
  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. <!-- Copyright IBM Corp. 2009 2011Rights Reserved. -->
  9. <xts:morphlet version="1.0" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  10. <xts:block id="catalog" processor="XML" type="exec" mode="input"
  11. path="/iwidget/iwidget_catalog.xml"/>
  12. <xts:block id="response" processor="XSLT" type="exec" mode="interpret"
  13. dependency="catalog" nodelist="env,http,cookies,interfaces,catalog">
  14. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  16. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  17. xmlns:xos="http://developer.cognos.com/schemas/xts/output/"
  18. xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget"
  19. xmlns:cpsValidate="java:com.cognos.portal.fragment.validation.ValidationManager"
  20. exclude-result-prefixes="xts xtsext xos iw cpsValidate">
  21. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  22. <xsl:key name="catalog" match="/root/catalog/entry" use="path"/>
  23. <xsl:variable name="interfaceInfo" select="/root/interfaces/interfaceInfo[param[@name = 'name'] = 'iwidget']"/>
  24. <xsl:variable name="remaining" select="$interfaceInfo/param[@name = 'extraInfo']"/>
  25. <xsl:variable name="entry-path" select="substring-after($remaining, '/bridge')"/>
  26. <xsl:variable name="entry" select="key('catalog', $entry-path)"/>
  27. <xsl:variable name="gateway" select="/root/http/param[@name = 'SCRIPT_NAME']"/>
  28. <xsl:variable name="webcontent" select="/root/http/param[@name = 'WEB_CONTENT_ROOT']"/>
  29. <xsl:variable name="http-host" select="/root/http/param[@name = 'HTTP_HOST']"/>
  30. <xsl:variable name="http-protocol" select="/root/http/param[@name = 'SERVER_PROTOCOL']"/>
  31. <xsl:variable name="host">
  32. <xsl:choose>
  33. <xsl:when test="starts-with($http-protocol, 'HTTPS')">https://</xsl:when>
  34. <xsl:otherwise>http://</xsl:otherwise>
  35. </xsl:choose>
  36. <xsl:value-of select="$http-host"/>
  37. </xsl:variable>
  38. <xsl:variable name="bridge-gateway" select="concat($host, $gateway)"/>
  39. <xsl:variable name="bridge-webcontent" select="concat($host, $webcontent)"/>
  40. <xsl:template match="/">
  41. <xts:sequence>
  42. <xts:append select="/root/output">
  43. <xsl:choose>
  44. <xsl:when test="$remaining = '/sample'">
  45. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  46. <xos:entityHeader>
  47. <xos:param name="Content-Type">text/xml</xos:param>
  48. </xos:entityHeader>
  49. <xos:entityBody>
  50. <iw:iwidget name="sample" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget"
  51. allowInstanceContent="true"
  52. supportedModes="view"
  53. mode="view" lang="en">
  54. <iw:content mode="view"><![CDATA[
  55. <div id="FRAG_IWID_content" style="height:100%">
  56. <br><br><br>
  57. <center>
  58. <h2>Sample iWidget</h2>
  59. </center>
  60. <br><br><br>
  61. <a href="javascript:alert(iContext.io)">test</a>
  62. <br><br><br>
  63. </div>]]>
  64. </iw:content>
  65. </iw:iwidget>
  66. </xos:entityBody>
  67. </xos:part>
  68. </xsl:when>
  69. <xsl:when test="$entry">
  70. <!-- iWidget -->
  71. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  72. <xos:entityHeader>
  73. <xos:param name="Content-Type">text/xml</xos:param>
  74. </xos:entityHeader>
  75. <xos:entityBody>
  76. <iw:iwidget name="{ $entry/title }" xmlns:iw="http://www.ibm.com/xmlns/prod/iWidget"
  77. iScope="com.ibm.cognos.bux.fragmentBridge"
  78. allowInstanceContent="true"
  79. supportedModes="view edit"
  80. mode="view" lang="en">
  81. <!-- copy metadata -->
  82. <xsl:copy-of select="$entry/iwidget/*"/>
  83. <iw:event id="com.ibm.bux.widgetchrome.toolbar.init" description="com.ibm.bux.widgetchrome.toolbar.initDesc" published="true" />
  84. <iw:eventDescription id="com.ibm.bux.widgetchrome.toolbar.initDesc" payloadType="any" description="Event to initialize chrome toolbar." />
  85. <iw:event id="com.ibm.bux.widget.toolbar.action" description="com.ibm.bux.widget.toolbar.actionDesc" handled="true" onEvent="onToolbarAction" />
  86. <iw:eventDescription id="com.ibm.bux.widget.toolbar.actionDesc" payloadType="any" description="Event for toolbar actions." />
  87. <iw:event id="com.ibm.bux.widget.refresh" description="com.ibm.bux.widget.refreshDesc" handled="true" onEvent="onWidgetRefresh"/>
  88. <iw:eventDescription id="com.ibm.bux.widget.refreshDesc" payloadType="any" description="Event for refreshing widget."/>
  89. <iw:event id="com.ibm.bux.widget.resize" description="com.ibm.bux.widget.resize" handled="true" onEvent="onWidgetResize"/>
  90. <iw:eventDescription id="com.ibm.bux.widget.resizeDesc" payloadType="any" description="Event for resizing widget."/>
  91. <iw:resource uri="fragmentBridge.js"/>
  92. <iw:content mode="view">
  93. &lt;div id="FRAG_IWID_content" class="cogstyle-portlet-content" style="height:100%"><![CDATA[
  94. <table dojoAttachPoint="loadNode" waiRole="region" tabindex="-1" border="0" cellpadding="0" cellspacing="0" class="widget_loadContainerOuter">
  95. <tr><td class="widget_loadContainer">
  96. <div class="widget_loadContainerInsert">
  97. <div class="dijitInline widget_load"></div>
  98. </div>
  99. </td></tr>
  100. </table>]]>
  101. &lt;script>
  102. iContext.bridgeConfig =
  103. {
  104. fragmentPath: "<xsl:value-of select="substring-after($entry/path, '/dashboard')"/>",
  105. gateway: "<xsl:value-of select="$gateway"/>",
  106. application: "/dashboard",
  107. webContent: "<xsl:value-of select="$webcontent"/>",
  108. bridgeGateway: "<xsl:value-of select="cpsValidate:staticSign(cpsValidate:getInstance(), $bridge-gateway)"/>",
  109. bridgeWebContent: "<xsl:value-of select="cpsValidate:staticSign(cpsValidate:getInstance(), $bridge-webcontent)"/>"
  110. };
  111. &lt;/script>
  112. &lt;/div>
  113. </iw:content>
  114. <iw:content mode="edit"><![CDATA[
  115. <div id="FRAG_IWID_edit_content" fragmentid="FRAG_IWID_" class="cogstyle-portlet-content" style="height:100%">
  116. <table dojoAttachPoint="loadNode" waiRole="region" tabindex="-1" border="0" cellpadding="0" cellspacing="0" class="widget_loadContainerOuter">
  117. <tr><td class="widget_loadContainer">
  118. <div class="widget_loadContainerInsert">
  119. <div class="dijitInline widget_load"></div>
  120. </div>
  121. </td></tr>
  122. </table>
  123. </div>]]>
  124. </iw:content>
  125. </iw:iwidget>
  126. </xos:entityBody>
  127. </xos:part>
  128. </xsl:when>
  129. <xsl:when test="contains($remaining, '.js')">
  130. <!-- javascript -->
  131. <xsl:variable name="document">
  132. <xsl:choose>
  133. <xsl:when test="contains($remaining, 'fragments.js')">
  134. <xsl:text>/iwidget/fragments.js</xsl:text>
  135. </xsl:when>
  136. <xsl:when test="contains($remaining, 'fragments_patch.js')">
  137. <xsl:text>/iwidget/fragments_patch.js</xsl:text>
  138. </xsl:when>
  139. <xsl:otherwise>
  140. <xsl:text>/iwidget/fragmentBridge.js</xsl:text>
  141. </xsl:otherwise>
  142. </xsl:choose>
  143. </xsl:variable>
  144. <xts:request protocol="FILEREAD" target="{ $document }" option="part" mimeType="application/x-javascript"/>
  145. </xsl:when>
  146. <xsl:when test="contains($remaining, '.css')">
  147. <!-- javascript -->
  148. <xsl:variable name="document">/iwidget/cognos_content_portlets.css</xsl:variable>
  149. <xts:request protocol="FILEREAD" target="{ $document }" option="part" mimeType="text/css"/>
  150. </xsl:when>
  151. <xsl:when test="$remaining = '/feed'">
  152. <!-- atom feed -->
  153. <xts:transform processor="XSLT" src="iwidget/catalogFeed.xslt" option="part" mimeType="application/atom+xml">
  154. <root>
  155. <xsl:copy-of select="/root/http | /root/request | /root/catalog"/>
  156. </root>
  157. </xts:transform>
  158. </xsl:when>
  159. <xsl:when test="$remaining = '/test'">
  160. <!-- iWidget -->
  161. <xos:part xmlns:xos="http://developer.cognos.com/schemas/xts/output/">
  162. <xos:entityHeader>
  163. <xos:param name="Content-Type">text/xml</xos:param>
  164. </xos:entityHeader>
  165. <xos:entityBody>
  166. <xsl:copy-of select="/root"/>
  167. </xos:entityBody>
  168. </xos:part>
  169. </xsl:when>
  170. <xsl:otherwise>
  171. <!-- document not found -->
  172. <xos:statusCode>404</xos:statusCode>
  173. </xsl:otherwise>
  174. </xsl:choose>
  175. </xts:append>
  176. </xts:sequence>
  177. </xsl:template>
  178. </xsl:stylesheet>
  179. </xts:block>
  180. </xts:morphlet>