menu.xslt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. BI and PM: qs
  5. (C) Copyright IBM Corp. 2001, 2017
  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" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:xts="http://developer.cognos.com/schemas/xts/" xmlns:pf="http://developer.cognos.com/schemas/xts/pf">
  13. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  14. <pf:variables/>
  15. <xsl:variable name="skin" select="concat($webRoot, '/skins/', /root/user/param[@name='skin'])"/>
  16. <xsl:template match="/">
  17. <xsl:for-each select="/root/ui/insertMenu">
  18. <xsl:call-template name="doMenuDiv">
  19. <xsl:with-param name="selection" select="@alias"/>
  20. </xsl:call-template>
  21. </xsl:for-each>
  22. <xsl:for-each select="/root/ui/menuContent/menu">
  23. <xsl:call-template name="doMenuDiv">
  24. <xsl:with-param name="selection" select="@alias"/>
  25. </xsl:call-template>
  26. </xsl:for-each>
  27. <table id="metadata_menu_closed" name="metadata_menu_panel" class="menuButtonBody" height="100%" width="15" border="0" cellpadding="0" cellspacing="0" style="margin-left:10px; display:none;">
  28. <tr>
  29. <td class="menuButton" onmousedown="expandMenu()">
  30. <img src="{$skin}/viewer/images/menu_expand.gif" height="13" width="13" border="0" style="margin-top:1px;">
  31. <xsl:attribute name="title"><xts:string id="MENU_PANE_EXPAND_TIP"/></xsl:attribute>
  32. </img>
  33. </td>
  34. </tr>
  35. <tr>
  36. <td height="100%" class="menuContentCollapsed" style="border-bottom:0px; border-right:0px">&#160;</td>
  37. </tr>
  38. </table>
  39. </xsl:template>
  40. <xsl:template name="doMenuDiv">
  41. <xsl:param name="selection" select="'edit'"/>
  42. <table id="metadata_menu_{@alias}" name="metadata_menu_panel" class="menuPage" border="0" cellpadding="0" cellspacing="0" style="height:100%;width:100%;display:none;">
  43. <xsl:attribute name="onmousemove">resizeMenuPane(event)</xsl:attribute>
  44. <xsl:attribute name="onmouseup">enableResize(false)</xsl:attribute>
  45. <tr>
  46. <td width="100%" style="padding:0px 5px;">
  47. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  48. <tr>
  49. <td class="menuHeader" valign="bottom">
  50. <xsl:text/><xts:string id="MENU_TITLE"/><xsl:text/>
  51. </td>
  52. <td class="menuHeaderButton" onmousedown="collapseMenu()">
  53. <img src="{$skin}/qs/images/menu_collapse.gif" border="0" style="margin: 1px 0px 0px 1px;">
  54. <xsl:attribute name="title"><xts:string id="MENU_PANE_COLLAPSE_TIP"/></xsl:attribute>
  55. </img>
  56. </td>
  57. </tr>
  58. </table>
  59. </td>
  60. </tr>
  61. <tr style="height:100%;">
  62. <td height="100%">
  63. <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
  64. <!-- spacer -->
  65. <tr>
  66. <td width="100%" style="height:3px;padding:0px 5px;">
  67. <table cellpadding="0" cellspacing="0" border="0" style="height:100%;width:100%;" class="borderCollapse">
  68. <tr>
  69. <td class="menuItemSpacerTop" style="height:100%;width:100%;"/>
  70. </tr>
  71. </table>
  72. </td>
  73. </tr>
  74. <xsl:for-each select="/root/ui/insertMenu">
  75. <xsl:choose>
  76. <xsl:when test="@alias=$selection"><xsl:call-template name="selectedMenu"/></xsl:when>
  77. <xsl:otherwise><xsl:call-template name="unselectedMenu"/></xsl:otherwise>
  78. </xsl:choose>
  79. </xsl:for-each>
  80. <xsl:for-each select="/root/ui/menuContent/menu">
  81. <xsl:choose>
  82. <xsl:when test="@alias=$selection"><xsl:call-template name="selectedMenu"/></xsl:when>
  83. <xsl:otherwise><xsl:call-template name="unselectedMenu"/></xsl:otherwise>
  84. </xsl:choose>
  85. </xsl:for-each>
  86. <tr>
  87. <td width="100%" style="height:3px;padding:0px 5px;">
  88. <table cellpadding="0" cellspacing="0" border="0" style="height:100%;width:100%;" class="borderCollapse">
  89. <tr>
  90. <td class="menuItemSpacer" style="height:100%;width:100%;"/>
  91. </tr>
  92. </table>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td width="100%" height="100%" id="menuContent" class="menuContent" valign="top">
  97. <table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%">
  98. <tr>
  99. <td style="padding:0px; margin:0px; width:100%;" valign="top">
  100. <table cellpadding="0" cellspacing="0" border="0" height="100%" width="100%" style="table-layout:fixed">
  101. <xsl:choose>
  102. <xsl:when test="/root/ui/insertMenu[@alias=$selection]">
  103. <xsl:apply-templates select="/root/ui/insertMenu[@alias=$selection]/content"/>
  104. </xsl:when>
  105. <xsl:otherwise>
  106. <xsl:apply-templates select="/root/ui/menuContent/menu[@alias=$selection]/*[(name()='menuItem' and @id!='') or name()='separator']"/>
  107. <tr height="100%">
  108. <td colspan="2" height="100%"/>
  109. </tr>
  110. </xsl:otherwise>
  111. </xsl:choose>
  112. </table>
  113. </td>
  114. <td style="width:3px; cursor:e-resize;" onmousedown="enableResize(true); return false;" onmousemove="setMenuResizeDirection('ew');resizeMenuPane(event); return false;" onmouseup="enableResize(false)">
  115. <xsl:if test="/root/browserInfo/isIE='true'">
  116. <xsl:attribute name="ondrag">return false;</xsl:attribute>
  117. </xsl:if>
  118. <img border="0" width="3">
  119. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/images/spacer.gif</xsl:attribute>
  120. </img>
  121. </td>
  122. </tr>
  123. </table>
  124. </td>
  125. </tr>
  126. </table>
  127. </td>
  128. </tr>
  129. </table>
  130. </xsl:template>
  131. <xsl:template name="selectedMenu">
  132. <tr>
  133. <td class="menuItemSelected" width="100%">
  134. <xsl:value-of select="./name"/>
  135. </td>
  136. </tr>
  137. </xsl:template>
  138. <xsl:template name="unselectedMenu">
  139. <tr>
  140. <td width="100%" style="padding:0px 5px;">
  141. <div class="menuItem" onmousedown="changeMenu('{@alias}')">
  142. <xsl:if test="/root/browserInfo/isIE='true'">
  143. <xsl:attribute name="style">width:100%;</xsl:attribute>
  144. </xsl:if>
  145. <xsl:value-of select="./name"/>
  146. </div>
  147. </td>
  148. </tr>
  149. </xsl:template>
  150. <xsl:template match="separator">
  151. <tr>
  152. <td>
  153. <img width="16" height="12">
  154. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/images/spacer.gif</xsl:attribute>
  155. </img>
  156. </td>
  157. <td>
  158. <img width="16" height="12">
  159. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/images/spacer.gif</xsl:attribute>
  160. </img>
  161. </td>
  162. </tr>
  163. </xsl:template>
  164. <xsl:template match="menuItem">
  165. <xsl:variable name="menuItemId"><xsl:value-of select="./@id"/></xsl:variable>
  166. <xsl:variable name="menuItemValue"><xsl:value-of select="./@value"/></xsl:variable>
  167. <xsl:for-each select="/root/features/included/feature[@name=$menuItemId]/menuItem[@type='menuItem' and (not(@value) or @value=$menuItemValue)]">
  168. <xsl:variable name="packageCaps">
  169. <xsl:for-each select="../userCapabilities/userCapability">
  170. <xsl:value-of select="/root/userCapabilities/value/item = ."/>
  171. </xsl:for-each>
  172. </xsl:variable>
  173. <xsl:variable name="globalCaps">
  174. <xsl:for-each select="../userCapabilities/globalUserCapability">
  175. <xsl:variable name="currentCapName" select="."/>
  176. <xsl:value-of select="count(/root/session/param[@name='capabilities']/*[local-name() = $currentCapName]) &gt; 0 "/>
  177. </xsl:for-each>
  178. </xsl:variable>
  179. <xsl:variable name="effectivelyHasPackageCap" select="(count(../userCapabilities/userCapability)=0 or contains($packageCaps,'true')) and (../@name!='ReportStudio' or $userCanUseRS)"/>
  180. <xsl:variable name="effectivelyHasGlobalCap" select="(count(../userCapabilities/globalUserCapability)=0 or contains($globalCaps,'true')) and (../@name!='ReportStudio' or $userCanUseRS)"/>
  181. <xsl:if test="$effectivelyHasPackageCap and $effectivelyHasGlobalCap">
  182. <tr>
  183. <td style="width:26px;text-align:left;">
  184. <table border="0" cellpadding="0" cellspacing="0" style="width:100%;height:20px">
  185. <tr>
  186. <td style="height:100%;width:100%;">
  187. <xsl:choose>
  188. <xsl:when test="./icon/active!='' and ./icon/active[@useWebRoot='true']">
  189. <img width="16" height="16">
  190. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/<xsl:value-of select="./icon/active"/></xsl:attribute>
  191. </img>
  192. </xsl:when>
  193. <xsl:when test="./icon/active!=''">
  194. <img src="{./icon/active}" width="16" height="16"/>
  195. </xsl:when>
  196. <xsl:otherwise>
  197. <img width="16" height="16">
  198. <xsl:attribute name="src"><xsl:value-of select="$webRoot"/>/common/images/spacer.gif</xsl:attribute>
  199. </img>
  200. </xsl:otherwise>
  201. </xsl:choose>
  202. </td>
  203. </tr>
  204. </table>
  205. </td>
  206. <td width="100%" class="menuAction" title="{./tooltip}">
  207. <xsl:attribute name="onclick">
  208. <xsl:text/>goApplicationManager.getFeatureManager().launchFeature('<xsl:value-of select="$menuItemId"/>'<xsl:text/>
  209. <xsl:if test="count(./action/parameters/*)&gt;0">
  210. <xsl:text/>, new Array(<xsl:text/>
  211. <xsl:for-each select="./action/parameters/parameter">
  212. <xsl:if test="position()&gt;1"><xsl:text/>, <xsl:text/></xsl:if>
  213. <xsl:choose>
  214. <xsl:when test="@type='string'">
  215. <xsl:text/>'<xsl:value-of select="."/>'<xsl:text/>
  216. </xsl:when>
  217. <xsl:when test="@type='boolean' or @type='numeric'">
  218. <xsl:text/><xsl:value-of select="."/><xsl:text/>
  219. </xsl:when>
  220. </xsl:choose>
  221. </xsl:for-each>
  222. <xsl:text/>)<xsl:text/>
  223. </xsl:if>
  224. <xsl:text/>)<xsl:text/>
  225. </xsl:attribute>
  226. <xsl:value-of select="./label"/>
  227. </td>
  228. </tr>
  229. </xsl:if>
  230. </xsl:for-each>
  231. </xsl:template>
  232. <xsl:template match="content">
  233. <xsl:copy-of select="./*"/>
  234. </xsl:template>
  235. </xsl:stylesheet>