updateSharedPagesList.xslt 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  15. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  16. xmlns:xts="http://developer.cognos.com/schemas/xts/">
  17. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  18. <xsl:key name="sequence-parm" match="/root/env/param[@name='sharedPageSequence']" use="substring-before(.,',')"/>
  19. <xsl:key name="sharedPages-idLookup" match="/root/sharedPagesListForDisplay/pagelet" use="cm:storeID"/>
  20. <xsl:variable name="publicFolder" select="/root/cm:queryResponse/cm:queryReply[2]/*"/>
  21. <xsl:variable name="privateFolder" select="/root/cm:queryResponse/cm:queryReply[3]/*"/>
  22. <xsl:template match="/">
  23. <xts:sequence>
  24. <xts:delete select="/root/env/param[@name='sharedPageSequence']"/>
  25. <xts:delete select="/root/env/param[@name='sharedPagesChanged']"/>
  26. <!-- delete the pager selection -->
  27. <xts:delete select="/root/env/param[starts-with(@name,'sharedPage_select')]"/>
  28. <xsl:variable name="changeOp"><xsl:value-of select="/root/env/param[@name='sharedPagesChanged']"/></xsl:variable>
  29. <xsl:if test="$changeOp = 'addPagelet'">
  30. <xts:append>
  31. <AddPageletResponse/>
  32. </xts:append>
  33. </xsl:if>
  34. <xsl:choose>
  35. <!-- this is the case when we choose add current page -->
  36. <xsl:when test="$changeOp = 'add'">
  37. <xsl:variable name="addSearchID"><xsl:value-of select="/root/env/param[@name='m_selectedPage']"/></xsl:variable>
  38. <!-- only add the page in if it is not already in the portalPages -->
  39. <xsl:if test="not(key('sharedPages-idLookup', $addSearchID))">
  40. <xts:append select="/root/sharedPagesListForDisplay">
  41. <pagelet>
  42. <cm:storeID xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"><xsl:value-of select="$addSearchID"/></cm:storeID>
  43. </pagelet>
  44. </xts:append>
  45. </xsl:if>
  46. </xsl:when>
  47. <!-- in this case we have added pages using the addpage dialog -->
  48. <xsl:when test="(./root/newEntries)">
  49. <!-- lets first check to see if we have duplicate entries -->
  50. <xsl:for-each select="/root/newEntries/cm:pagelet | /root/newEntries/cm:folder | /root/newEntries/cm:content">
  51. <xsl:variable name='currentId'><xsl:value-of select="cm:storeID"/></xsl:variable>
  52. <xsl:choose>
  53. <xsl:when test="key('sharedPages-idLookup', $currentId)">
  54. <xts:append>
  55. <duplicateEntry/>
  56. </xts:append>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <xts:append select='/root/sharedPagesListForDisplay'>
  60. <pagelet>
  61. <xsl:copy-of select="cm:objectClass"/>
  62. <xsl:copy-of select="cm:defaultName"/>
  63. <xsl:copy-of select="cm:permissions"/>
  64. <xsl:copy-of select="cm:searchPath"/>
  65. <xsl:copy-of select="cm:storeID"/>
  66. <xsl:copy-of select="cm:ancestors"/>
  67. </pagelet>
  68. </xts:append>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. </xsl:for-each>
  72. </xsl:when>
  73. <!-- we have canceled from the add paged dialog -->
  74. <xsl:when test="(./root/env/param[@name = 'addPageletsMode']) and (./root/morphletResponse/canceled)" >
  75. <xts:append>
  76. <AddPageletCancel/>
  77. </xts:append>
  78. </xsl:when>
  79. <!-- reset the sequence to the pages to a new sequence -->
  80. <xsl:when test="$changeOp = 'resequence'">
  81. <xts:delete select="/root/sharedPagesListForDisplay"/>
  82. <xts:append>
  83. <sharedPagesListForDisplay>
  84. <xsl:for-each select="/root/env/param[@name='sharedPageSequence']">
  85. <xsl:variable name="currentId"><xsl:value-of select="substring-after(key('sequence-parm',position()),',')"/></xsl:variable>
  86. <xsl:copy-of select="/root/sharedPagesListForDisplay/pagelet[cm:storeID = $currentId]"/>
  87. </xsl:for-each>
  88. </sharedPagesListForDisplay>
  89. </xts:append>
  90. </xsl:when>
  91. <xsl:when test="$changeOp = 'remove'">
  92. <xsl:variable name="removeSearchID"><xsl:value-of select="/root/env/param[@name='m_selectedPage']"/></xsl:variable>
  93. <xsl:choose>
  94. <xsl:when test="$removeSearchID != ''">
  95. <xts:delete select="/root/sharedPagesListForDisplay/pagelet[./*[local-name() = 'storeID' and text() = '{$removeSearchID}']]"/>
  96. </xsl:when>
  97. <xsl:otherwise>
  98. <!-- in this case we have a bunch of pages to delete. Since we only have the indexes of the pages the user selected to be delete
  99. we must first create a list of id's to delete and then do the delete -->
  100. <xsl:variable name="removeIds">
  101. <xsl:for-each select="/root/env/param[starts-with(@name,'sharedPage_select_')]">
  102. <xsl:variable name="pageNumber"><xsl:value-of select="number(substring-after(@name,'sharedPage_select_'))"/></xsl:variable>
  103. <xsl:value-of select="/root/sharedPagesListForDisplay/pagelet[number($pageNumber)]/cm:storeID"/>,<xsl:text/>
  104. </xsl:for-each>
  105. </xsl:variable>
  106. <xts:delete select="/root/sharedPagesListForDisplay/pagelet[contains('{$removeIds}', ./*[local-name() ='storeID'])]"/>
  107. </xsl:otherwise>
  108. </xsl:choose>
  109. </xsl:when>
  110. <xsl:when test="$changeOp = 'addprivate'">
  111. <xts:append select='/root/sharedPagesListForDisplay'>
  112. <pagelet>
  113. <xsl:copy-of select="$privateFolder/cm:storeID"/>
  114. <!-- the values below are for display purposes only and do not get stored in CM -->
  115. <!-- the only value used by cm for pagelets is storeID -->
  116. <xsl:copy-of select="$privateFolder/cm:objectClass"/>
  117. <!-- add private is only called from the admin pages. In this case we display "Personal Folder" for the the My folders -->
  118. <!-- so that the administrator gets a consistent view of the user or profile's my folders tab -->
  119. <cm:defaultName xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"><xts:string id="IDS_MYPAGES_PERSONAL_FOLDER"/></cm:defaultName>
  120. <xsl:copy-of select="$privateFolder/cm:permissions"/>
  121. <xsl:copy-of select="$privateFolder/cm:searchPath"/>
  122. <xsl:copy-of select="$privateFolder/cm:ancestors"/>
  123. </pagelet>
  124. </xts:append>
  125. </xsl:when>
  126. <xsl:when test="$changeOp = 'addpublic'">
  127. <xts:append select='/root/sharedPagesListForDisplay'>
  128. <pagelet>
  129. <xsl:copy-of select="$publicFolder/*"/>
  130. </pagelet>
  131. </xts:append>
  132. </xsl:when>
  133. </xsl:choose>
  134. </xts:sequence>
  135. </xsl:template>
  136. </xsl:stylesheet>