view.xslt 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. <!--
  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. <!-- $Header: //cpscrn/main/templates/cps4/portlets/utility/portlet-impl/image/view.xslt#1 $ -->
  13. <!-- $DateTime: 2008/10/22 11:12:04 $ -->
  14. <!-- $Change: 25109 $ -->
  15. <xsl:stylesheet version="1.0"
  16. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
  18. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  19. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  20. xmlns:portlet="http://developer.cognos.com/schemas/cps/logic/portlet/1/"
  21. exclude-result-prefixes="ui xts xtsext portlet">
  22. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  23. <xsl:attribute-set name="anchor">
  24. <xsl:attribute name="class">cognos-anchor</xsl:attribute>
  25. <xsl:attribute name="onmouseover">window.status='';return true;</xsl:attribute>
  26. <xsl:attribute name="onmouseout">window.status='';return true;</xsl:attribute>
  27. </xsl:attribute-set>
  28. <ui:property name="target-frame" select="'target'"/>
  29. <xsl:variable name="check-target">
  30. <xsl:choose>
  31. <xsl:when test="$open-links = 'current' and not($ui-is-myportal)">
  32. <xsl:value-of select="'_top'"/>
  33. </xsl:when>
  34. <xsl:when test="($open-links = 'target')">
  35. <xsl:value-of select="$target-frame"/>
  36. </xsl:when>
  37. <xsl:when test="$open-links = 'channel'"></xsl:when>
  38. <xsl:otherwise>
  39. <xsl:value-of select="'_blank'"/>
  40. </xsl:otherwise>
  41. </xsl:choose>
  42. </xsl:variable>
  43. <xsl:attribute-set name="target">
  44. <xsl:attribute name="target">
  45. <xsl:value-of select="$check-target"/>
  46. </xsl:attribute>
  47. </xsl:attribute-set>
  48. <ui:property name="img-target-url" select="'img_target_url'"/>
  49. <ui:property name="img-size" select="'img_size'"/>
  50. <ui:property name="img-tile" select="'img_tile'"/>
  51. <ui:property name="open-links" select="'open_links'"/>
  52. <ui:property name="channel" select="'channel'"/>
  53. <xsl:template match="/">
  54. <xsl:if test="$img-target-url != ''">
  55. <script language="javascript">
  56. function wsrp_rewrite_select(href,e) {
  57. <xsl:choose>
  58. <xsl:when test="$open-links = 'channel'">
  59. document.wsrp_rewrite_form.url.value = href;
  60. document.wsrp_rewrite_form.submit();
  61. if (e.srcElement) {
  62. e.returnValue = false;
  63. } else {
  64. e.preventDefault();
  65. }
  66. </xsl:when>
  67. <xsl:when test="($img-size = 'custom' and $img-tile = 'true')">
  68. window.open(href,'<xsl:value-of select="$check-target"/>',"");
  69. if (e.srcElement) {
  70. e.returnValue = false;
  71. } else {
  72. e.preventDefault();
  73. }
  74. </xsl:when>
  75. <xsl:otherwise></xsl:otherwise>
  76. </xsl:choose>
  77. }
  78. </script>
  79. </xsl:if>
  80. <xsl:if test="$open-links = 'channel'">
  81. <form name="wsrp_rewrite_form" method="post" action="wsrp_rewrite?wsrp-urlType=blockingAction&amp;wsrp-interactionState=set:{ $channel }&amp;wsrp-windowState={ $ui-window-state }/wsrp_rewrite">
  82. <input type="hidden" name="url" value=""/>
  83. </form>
  84. </xsl:if>
  85. <xsl:choose>
  86. <xsl:when test="$img-target-url = '' or ($img-size = 'custom' and $img-tile = 'true')">
  87. <xsl:call-template name="render-image"/>
  88. </xsl:when>
  89. <xsl:otherwise>
  90. <a xsl:use-attribute-sets="anchor target" href="{ $img-target-url }" onclick="wsrp_rewrite_select('{ xtsext:javascriptencode( string($img-target-url) ) }',event)">
  91. <xsl:call-template name="render-image"/>
  92. </a>
  93. </xsl:otherwise>
  94. </xsl:choose>
  95. <ui:preview/>
  96. </xsl:template>
  97. <xsl:template name="render-image">
  98. <ui:property name="img-url" select="'img_url'"/>
  99. <ui:property name="img-width" select="'img_width'"/>
  100. <ui:property name="img-height" select="'img_height'"/>
  101. <ui:property name="img-use-title" select="'img_use_title'"/>
  102. <xsl:variable name="use-title" select="$img-use-title"/>
  103. <xsl:variable name="prefTitle">
  104. <xsl:choose>
  105. <xsl:when test="$img-use-title='true'">
  106. <xsl:variable name="titles" select="$ui-state-params[starts-with( @name, 'title_' ) and .!='']"/>
  107. <portlet:preferred-title-localized-value select="$titles"/>
  108. </xsl:when>
  109. <xsl:otherwise>
  110. <xsl:value-of select="$img-url"/>
  111. </xsl:otherwise>
  112. </xsl:choose>
  113. </xsl:variable>
  114. <xsl:choose>
  115. <xsl:when test="$img-size = 'original'">
  116. <img src="{ $img-url }" border="0" alt="{ $prefTitle }" tabindex="0" role="img" wairole="img"/>
  117. </xsl:when>
  118. <xsl:when test="$img-size = 'custom'">
  119. <xsl:choose>
  120. <xsl:when test="$img-tile = 'true'">
  121. <xsl:variable name="cursor-style">
  122. <xsl:if test="$img-target-url != ''">
  123. <xsl:text>;cursor:hand</xsl:text>
  124. </xsl:if>
  125. </xsl:variable>
  126. <div style="width:{ $img-width }px;height:{ $img-height }px;background-image:url({ $img-url });background-repeat:repeat{ $cursor-style}" tabindex="0" role="img" wairole="img" aria-labelledby="wsrp_rewrite_imageCaption">
  127. <xsl:if test="$img-target-url != ''">
  128. <xsl:attribute name="onclick">
  129. <xsl:text>wsrp_rewrite_select('</xsl:text>
  130. <xsl:value-of select="xtsext:javascriptencode( string($img-target-url) )"/>
  131. <xsl:text>',event)</xsl:text>
  132. </xsl:attribute>
  133. </xsl:if>
  134. <xsl:text>&#160;</xsl:text>
  135. <span style="position: absolute;margin-top: -9999px; " id="wsrp_rewrite_imageCaption"><xsl:value-of select="$prefTitle"/></span>
  136. </div>
  137. </xsl:when>
  138. <xsl:otherwise>
  139. <img src="{ $img-url }" border="0" width="{ $img-width }" height="{ $img-height }" alt="{ $prefTitle }" tabindex="0" role="img" wairole="img"/>
  140. </xsl:otherwise>
  141. </xsl:choose>
  142. </xsl:when>
  143. </xsl:choose>
  144. </xsl:template>
  145. </xsl:stylesheet>