admin.xslt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed Materials - Property of IBM
  4. IBM Cognos Products: cogadmin
  5. (C) Copyright IBM Corp. 2005, 2014
  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. <!-- This stylesheet defines global portal variables and templates. -->
  13. <xsl:stylesheet version="1.0"
  14. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  15. xmlns:out="dummy-uri"
  16. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  17. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  18. xmlns:uic="http://developer.cognos.com/schemas/uic/presentation/markup/"
  19. xmlns:nav="http://developer.cognos.com/schemas/cps/navigation/1/"
  20. xmlns:admui="http://developer.cognos.com/schemas/xts/admui"
  21. xmlns:cogadminext="xalan://com.cognos.admin.xts.ext.XTSExt"
  22. exclude-result-prefixes="xsl xtsext xts admui nav uic">
  23. <xsl:output method="xml" encoding="UTF-8" indent="no"/>
  24. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  25. <!--
  26. a set of standard variables.
  27. -->
  28. <xsl:template match="admui:variables">
  29. <out:key name="system-param" match="/root/system/param" use="@name"/>
  30. <out:key name="env-param" match="/root/env/param" use="@name"/>
  31. <out:key name="session-param" match="/root/session/param" use="@name"/>
  32. <out:key name="user-param" match="/root/user/param" use="@name"/>
  33. <!-- Application variables -->
  34. <out:variable name="app" select="key('system-param', 'app')"/>
  35. <out:variable name="common_app" select="key('system-param','common_app')"/>
  36. <!-- Build a list of UI elements that we want to hide from the current user. -->
  37. <out:variable name="ui_black_list">
  38. <!-- System-based list -->
  39. <out:for-each select="key('system-param', 'ui_hide')/*">
  40. <out:variable name="s" select="concat(' ', @show, ' ')"/>
  41. <out:value-of select="' '"/><out:value-of select="local-name()"/><out:value-of select="' '"/>
  42. </out:for-each>
  43. </out:variable>
  44. <!-- todo: change this once CPS give us a better way to get the gateway -->
  45. <out:variable name="gateway" select="/root/configProps/param[@name = 'cps']/property[@name ='gateway']/."/>
  46. <out:variable name="webRoot">
  47. <out:choose>
  48. <out:when test="/root/http/param[@name='WEB_CONTENT_ROOT']">
  49. <out:value-of select="string(/root/http/param[@name='WEB_CONTENT_ROOT'])"/>
  50. </out:when>
  51. <!-- No official config param is present. Make this relative. -->
  52. <out:otherwise>..</out:otherwise>
  53. </out:choose>
  54. </out:variable>
  55. <!-- browser -->
  56. <out:variable name="user-agent" select="string(/root/http/param[@name='HTTP_USER_AGENT'])"/>
  57. <out:variable name="browser">
  58. <out:choose>
  59. <out:when test="contains($user-agent , 'MSIE')">ie</out:when> <!-- IE 4.xx and above -->
  60. <out:when test="contains($user-agent , 'Safari')">safari</out:when> <!-- Safari -->
  61. <out:when test="contains($user-agent , 'Mozilla/5.0')">moz</out:when> <!-- NS 6.xx and 7.xx -->
  62. <out:when test="string-length($user-agent) = 0">undefined</out:when>
  63. <out:otherwise>other</out:otherwise>
  64. </out:choose>
  65. </out:variable>
  66. <!-- locales -->
  67. <out:variable name="productLocale">
  68. <out:value-of select="key('user-param','productLocale')"/>
  69. </out:variable>
  70. <out:variable name="contentLocale">
  71. <out:value-of select="key('user-param','contentLocale')"/>
  72. </out:variable>
  73. <out:variable name="timeZone">
  74. <out:value-of select="key('user-param','timeZoneID')"/>
  75. </out:variable>
  76. <!-- CAPABILITIES calculations: Added as needed. Refer to portal.xsl logicsheet for capabilities mappings -->
  77. <!-- Administration capability -->
  78. <out:variable name="hasAdminCapability" select="boolean(key('session-param','capabilities')/canUseAdministrationPortal)"/>
  79. <!-- Scheduling Access capability-->
  80. <out:variable name="hasSchedCapability" select="boolean(key('session-param', 'capabilities')/canUseScheduling)"/>
  81. <!-- Scheduling Priority capability-->
  82. <out:variable name="hasSchedPriorityCapability" select="boolean(key('session-param', 'capabilities')/canUseSchedulingPriority)"/>
  83. <!-- Monitor Activity tool -->
  84. <out:variable name="hasMonitorActivityToolCapability" select="boolean(key('session-param', 'capabilities')/canUseMonitorActivityTool)"/>
  85. <!-- Run with Options capability-->
  86. <out:variable name="hasRWOCapability" select="boolean(key('session-param', 'capabilities')/canUseCognosViewerRunWithOptions)"/>
  87. </xsl:template>
  88. <!--
  89. Creates a set of standard pager variables to be used in queries.
  90. @pagerName: The name that was given to the pager
  91. Note: Needs env, session and system for nodelist
  92. -->
  93. <xsl:template match="admui:pagerVariables">
  94. <xsl:variable name="pagerName">
  95. <xsl:if test="@pagerName"><xsl:value-of select="@pagerName"/></xsl:if>
  96. </xsl:variable>
  97. <!-- pager name -->
  98. <out:variable name="pagerName">
  99. <xsl:if test="@pagerName"><out:value-of select="'{@pagerName}'"/></xsl:if>
  100. </out:variable>
  101. <!-- lines per page by default -->
  102. <out:variable name="linesPerPage">
  103. <out:choose>
  104. <out:when test="key('session-param','linesPerPage')">
  105. <out:value-of select="key('session-param','linesPerPage')"/>
  106. </out:when>
  107. <out:when test="key('system-param','defaultPortalPreferences')/pref[@name='lines']">
  108. <out:value-of select="key('system-param','defaultPortalPreferences')/pref[@name='lines']"/>
  109. </out:when>
  110. <out:otherwise>15</out:otherwise>
  111. </out:choose>
  112. </out:variable>
  113. <!-- get the start and end positions -->
  114. <out:variable name="startPosition">
  115. <out:choose>
  116. <out:when test="key('env-param','{$pagerName}_from') != ''"><out:value-of select="key('env-param','{$pagerName}_from')"/></out:when>
  117. <!-- if we don't have a start, try and calculate it using the end position if it's available -->
  118. <out:when test="key('env-param','{$pagerName}_to') != ''">
  119. <out:choose>
  120. <out:when test="number(key('env-param','{$pagerName}_to')) &lt; number($linesPerPage)">1</out:when>
  121. <out:otherwise><out:value-of select="number(key('env-param','{$pagerName}_to')) - number($linesPerPage)"/></out:otherwise>
  122. </out:choose>
  123. </out:when>
  124. </out:choose>
  125. </out:variable>
  126. <out:variable name="endPosition">
  127. <out:choose>
  128. <out:when test="key('env-param','{$pagerName}_to') != ''"><out:value-of select="key('env-param','{$pagerName}_to')"/></out:when>
  129. <out:when test="$startPosition != ''">
  130. <out:value-of select="$startPosition + $linesPerPage"/>
  131. </out:when>
  132. </out:choose>
  133. </out:variable>
  134. <!-- how many objects should be displayed in the pager -->
  135. <out:variable name="maxObjects">
  136. <out:choose>
  137. <out:when test="$endPosition !='' and $startPosition !=''">
  138. <out:value-of select="($endPosition - $startPosition) + 1"/>
  139. </out:when>
  140. <out:otherwise><out:value-of select="$linesPerPage"/></out:otherwise>
  141. </out:choose>
  142. </out:variable>
  143. <!-- how many objects should we be skipping -->
  144. <out:variable name="skipObjects">
  145. <out:choose>
  146. <out:when test="key('env-param','{$pagerName}_skip') != ''">
  147. <out:value-of select="key('env-param','{$pagerName}_skip')"/>
  148. </out:when>
  149. <out:otherwise>0</out:otherwise>
  150. </out:choose>
  151. </out:variable>
  152. </xsl:template>
  153. <!--
  154. Common set of params used in nav requests
  155. Note: needs http in the nodelist
  156. -->
  157. <xsl:template match="admui:commonNavParams">
  158. <nav:param name="gatewayURL"><out:value-of select="$gateway"/></nav:param>
  159. <nav:param name="webContentURL"></nav:param>
  160. <nav:param name="portalAgent">cognos</nav:param>
  161. <nav:param name="browserAgent"><out:value-of select="$browser"/></nav:param>
  162. </xsl:template>
  163. <!-- CM predicate for handling hidden objects -->
  164. <xsl:template match="admui:object-predicates">
  165. <out:variable name="hidden-objects-predicate">[@shown='true']</out:variable>
  166. <out:variable name="visibility-predicate" select="concat(/root/system/param[@name='visible'],$hidden-objects-predicate)"/>
  167. </xsl:template>
  168. <xsl:template match="admui:imageURL" name="admui:imageURL">
  169. <out:variable name="image">
  170. <xsl:choose>
  171. <xsl:when test="@image != ''"><xsl:value-of select="@image"/></xsl:when>
  172. <xsl:when test="admui:image"><xsl:apply-templates select="admui:image"/></xsl:when>
  173. </xsl:choose>
  174. </out:variable>
  175. <out:variable name="webcontentPath">
  176. <xsl:choose>
  177. <xsl:when test="@type = 'cogadmin'">
  178. <out:value-of select="concat('/ps/', $app, '/images/')"/>
  179. </xsl:when>
  180. <xsl:when test="@type = 'common'">
  181. <out:value-of select="concat('/ps/', $common_app, '/images/')"/>
  182. </xsl:when>
  183. <xsl:when test="@type = 'server'"><xsl:value-of select="'/ps/'"/></xsl:when>
  184. <xsl:when test="@type = 'nav'"><!-- Do nothing nav fills in the pieces for us --></xsl:when>
  185. <xsl:when test="starts-with(@type,'skin')">
  186. <out:variable name="user_skin">
  187. <out:choose>
  188. <out:when test="key('user-param', 'skin') != ''">
  189. <out:value-of select="key('user-param', 'skin')"/>
  190. </out:when>
  191. <out:otherwise>
  192. <out:value-of select="key('system-param', 'defaultPortalPreferences')/pref[@name='skin']"/>
  193. </out:otherwise>
  194. </out:choose>
  195. </out:variable>
  196. <out:variable name="portal_or_shared">
  197. <xsl:choose>
  198. <xsl:when test="@type = 'skin_shared'">
  199. <out:value-of select="key('system-param','skin_shared_images')"/>
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <out:value-of select="$common_app"/>
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. </out:variable>
  206. <out:value-of select="concat('/skins/', $user_skin, '/', $portal_or_shared, '/images/')"/>
  207. </xsl:when>
  208. </xsl:choose>
  209. </out:variable>
  210. <out:variable name="image-encoded-path"><out:value-of select="cogadminext:urlencode($image)"/></out:variable>
  211. <out:value-of select="concat('_THIS?frag-resource=', $webcontentPath, $image-encoded-path, '/THIS_')"/>
  212. </xsl:template>
  213. <!--
  214. admui:gen-runnable-icon: generates the icons for runnable classes
  215. @objectClass or admui:objectClass - The class of the object
  216. @iconURI or admui:iconURI - property on the runnable to override the icon
  217. -->
  218. <xsl:template match="admui:gen-runnable-icon">
  219. <out:variable name="objectClass">
  220. <xsl:choose>
  221. <xsl:when test="@objectClass != ''"><xsl:value-of select="@objectClass"/></xsl:when>
  222. <xsl:when test="admui:objectClass"><xsl:apply-templates select="admui:objectClass"/></xsl:when>
  223. </xsl:choose>
  224. </out:variable>
  225. <out:variable name="defaultName">
  226. <out:choose>
  227. <out:when test="/root/runnables/class[@name = string($objectClass)]/displayName != ''"><out:apply-templates select="/root/runnables/class[@name = string($objectClass)]/displayName"/></out:when>
  228. <out:otherwise>
  229. <xsl:if test="admui:defaultName"><xsl:apply-templates select="admui:defaultName"/></xsl:if>
  230. </out:otherwise>
  231. </out:choose>
  232. </out:variable>
  233. <out:variable name="screenTip">
  234. <xsl:choose>
  235. <xsl:when test="admui:screenTip"><xsl:apply-templates select="admui:screenTip"/></xsl:when>
  236. </xsl:choose>
  237. </out:variable>
  238. <out:variable name="icon">
  239. <xsl:choose>
  240. <xsl:when test="@iconURI != ''"><xsl:value-of select="@iconURI"/></xsl:when>
  241. <xsl:when test="admui:iconURI != ''"><xsl:apply-templates select="admui:iconURI"/></xsl:when>
  242. <xsl:otherwise>
  243. <out:choose>
  244. <out:when test="/root/runnables/class[@name = string($objectClass)]/icon">
  245. <out:value-of select="/root/runnables/class[@name = string($objectClass)]/icon"/>
  246. </out:when>
  247. <out:otherwise>
  248. <out:value-of select="'icon_unknown.gif'"/>
  249. </out:otherwise>
  250. </out:choose>
  251. </xsl:otherwise>
  252. </xsl:choose>
  253. </out:variable>
  254. <out:variable name="disabled">
  255. <xsl:choose>
  256. <xsl:when test="admui:disabled"><xsl:apply-templates select="admui:disabled"/></xsl:when>
  257. </xsl:choose>
  258. </out:variable>
  259. <uic:icon uic:noSpace="true">
  260. <out:attribute name="disabled">
  261. <out:value-of select="$disabled"/>
  262. </out:attribute>
  263. <uic:src>
  264. <out:choose>
  265. <!-- the specification icon is from cogadmin -->
  266. <out:when test="$objectClass = 'specification' ">
  267. <out:value-of select="concat('_THIS?frag-resource=/ps/', $app, '/images/icon_preview.gif', '/THIS_')"/>
  268. </out:when>
  269. <!-- all other runnable icons come the ps images directory -->
  270. <out:otherwise>
  271. <out:value-of select="concat('_THIS?frag-resource=/ps/', $common_app, '/images/', $icon, '/THIS_')"/>
  272. </out:otherwise>
  273. </out:choose>
  274. </uic:src>
  275. <uic:tooltip>
  276. <out:choose>
  277. <out:when test="$screenTip != ''">
  278. <out:value-of select="concat($defaultName, ' - ', $screenTip)"/>
  279. </out:when>
  280. <out:otherwise>
  281. <out:value-of select="$defaultName"/>
  282. </out:otherwise>
  283. </out:choose>
  284. <out:if test="$disabled = 'true'"> - <xts:string id="IDS_ADM_HIDDEN_OBJECT"/></out:if>
  285. </uic:tooltip>
  286. </uic:icon>
  287. </xsl:template>
  288. <xsl:template match="uic:column[not(ancestor::uic:table[1]/uic:features/uic:hideTenant='true') and position()=last() and parent::uic:row]">
  289. <xsl:variable name="colCopy">
  290. <xsl:copy-of select="."/>
  291. </xsl:variable>
  292. <xsl:apply-templates select="$colCopy"/>
  293. <out:if test="//root/session/param[@name='e_showTenantInfo']='true'">
  294. <xsl:choose>
  295. <xsl:when test="local-name(../..)='header'">
  296. <xsl:variable name="colTenant">
  297. <uic:column nowrap="nowrap">
  298. <uic:text><xts:string id="IDS_ADM_TENANT"/></uic:text>
  299. </uic:column>
  300. </xsl:variable>
  301. <xsl:apply-templates select="$colTenant"/>
  302. </xsl:when>
  303. <xsl:otherwise>
  304. <xsl:variable name="colTenant">
  305. <uic:column nowrap="nowrap">
  306. <!--TODO: Change this if applicable for various xts-->
  307. <uic:text><out:value-of select="*[local-name()='tenantName']"/></uic:text>
  308. </uic:column>
  309. </xsl:variable>
  310. <xsl:apply-templates select="$colTenant"/>
  311. </xsl:otherwise>
  312. </xsl:choose>
  313. </out:if>
  314. </xsl:template>
  315. <xsl:template match="*">
  316. <xsl:copy>
  317. <xsl:copy-of select="@*"/>
  318. <xsl:apply-templates/>
  319. </xsl:copy>
  320. </xsl:template>
  321. </xsl:stylesheet>