edit.xslt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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, 2013
  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: //cps4/main/src/cps/templates/cps4/portlets/samples/portlet-impl/xmlviewer/edit.xslt#2 $ -->
  13. <!-- $DateTime: 2004/04/18 10:35:04 $ -->
  14. <!-- $Change: 8570 $ -->
  15. <xsl:stylesheet
  16. exclude-result-prefixes="xts xtsext ui utml"
  17. version="1.0"
  18. xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
  19. xmlns:utml="http://developer.cognos.com/schemas/cps/logic/form/1/"
  20. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  21. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  22. xmlns:trustedSession="java:com.cognos.portal.utils.TrustedSessionHelper"
  23. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  24. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  25. <!--
  26. declare global variables...
  27. -->
  28. <xsl:variable name="app" select="/root/Application"/>
  29. <xsl:variable name="sdk-params" select="$app/Param[@Cps = 'true']"/>
  30. <xsl:variable name="hidden-params" select="$app/Param[not(@Cps = 'true')]"/>
  31. <xsl:variable name="is-web" select="$app/@Component = 'CPSWEB'"/>
  32. <xsl:variable name="rewrite-functions" select="$app/@namespaceFunctions"/>
  33. <xsl:variable name="scope" select="$app/@scope"/>
  34. <xsl:variable name="features" select="$app/@features"/>
  35. <xsl:variable name="consumer-escape" select="$ui-registration-params[@name = 'consumerEscape']"/>
  36. <utml:variables/>
  37. <!--
  38. create portal variable: $ui-consumer-info
  39. -->
  40. <ui:consumer/>
  41. <xsl:variable name="alias">
  42. <xsl:choose>
  43. <xsl:when test="$ui-navigational-params[@name = 'p_alias'] != ''">
  44. <xsl:value-of select="$ui-navigational-params[@name = 'p_alias']"/>
  45. </xsl:when>
  46. <xsl:otherwise>
  47. <xsl:value-of select="$ui-state-params[@name = 'alias']"/>
  48. </xsl:otherwise>
  49. </xsl:choose>
  50. </xsl:variable>
  51. <xsl:variable name="prev-alias">
  52. <xsl:choose>
  53. <xsl:when test="key('utml-key-params', 'tmp_prev_alias')">
  54. <xsl:value-of select="key('utml-key-params', 'tmp_prev_alias')"/>
  55. </xsl:when>
  56. <xsl:otherwise>
  57. <xsl:value-of select="$alias"/>
  58. </xsl:otherwise>
  59. </xsl:choose>
  60. </xsl:variable>
  61. <xsl:variable name="reset" select="string($alias) != string($prev-alias)"/>
  62. <xsl:template match="/">
  63. <script language="javascript">
  64. function wsrp_rewrite_validate() {
  65. return true;
  66. }
  67. </script>
  68. <script language="javascript">
  69. function wsrp_rewrite_chooseApplication() {
  70. <utml:form-submit
  71. utml:formName="wsrp_rewrite_form"
  72. utml:targetPage="listapps"
  73. utml:operation="push"
  74. utml:validate="false"/>
  75. }
  76. <xsl:if test="$utml-mode = 'cps:config'">
  77. function wsrp_rewrite_editCommands(cmd) {
  78. var cForm = document.wsrp_rewrite_form;
  79. cForm.p_admin_customized.value = cmd;
  80. <xsl:if test="string( $alias ) != $ui-state-params[@name = 'alias']">
  81. if (cForm.tmp_prev_alias != null) {
  82. cForm.tmp_prev_alias.value = "";
  83. }
  84. </xsl:if>
  85. <utml:form-submit
  86. utml:formName="wsrp_rewrite_form"
  87. utml:targetPage="edit"
  88. utml:operation="maintain"
  89. utml:validate="false"/>
  90. }
  91. </xsl:if>
  92. </script>
  93. <ui:about/>
  94. <ui:help/>
  95. <utml:form name="wsrp_rewrite_form" action="wsrp_rewrite?wsrp-urlType=blockingAction/wsrp_rewrite" method="post" utml:escape-prefix="$consumer-escape" utml:maintainPrevNavState="true">
  96. <utml:exclude-prefix>p_sdk_</utml:exclude-prefix>
  97. <utml:exclude>jsessionid</utml:exclude>
  98. <utml:input type="hidden" name="cps-authToken" utml:update="false">
  99. <utml:value>
  100. <xsl:value-of select="trustedSession:staticGenerateAuthToken(string(/root/cookies/cookie[@name='usersessionid']))"/>
  101. </utml:value>
  102. </utml:input>
  103. <utml:input type="hidden" name="p_isWeb" utml:update="false">
  104. <utml:value>
  105. <xsl:value-of select="$is-web"/>
  106. </utml:value>
  107. </utml:input>
  108. <utml:input type="hidden" name="p_features" utml:update="false">
  109. <utml:value>
  110. <xsl:value-of select="$features"/>
  111. </utml:value>
  112. </utml:input>
  113. <utml:input type="hidden" name="p_scope" utml:update="false">
  114. <utml:value>
  115. <xsl:value-of select="$scope"/>
  116. </utml:value>
  117. </utml:input>
  118. <utml:input type="hidden" name="p_rewriteFunctions" utml:update="false">
  119. <utml:value>
  120. <xsl:value-of select="$rewrite-functions"/>
  121. </utml:value>
  122. </utml:input>
  123. <utml:input type="hidden" name="p_alias" utml:update="false">
  124. <utml:value>
  125. <xsl:value-of select="$alias"/>
  126. </utml:value>
  127. </utml:input>
  128. <utml:input type="hidden" name="p_url" utml:update="false">
  129. <utml:value>
  130. <xsl:value-of select="$app/Url"/>
  131. </utml:value>
  132. </utml:input>
  133. <utml:input type="hidden" name="tmp_prev_alias" utml:update="false">
  134. <utml:value>
  135. <xsl:value-of select="$alias"/>
  136. </utml:value>
  137. </utml:input>
  138. <xsl:if test="$utml-mode != 'cps:config'">
  139. <xsl:for-each select="$hidden-params">
  140. <utml:input type="hidden" name="p_sdk_{@Name}" utml:update="false" utml:escape="true">
  141. <utml:value>
  142. <xsl:call-template name="get-param-value">
  143. <xsl:with-param name="param" select="current()"/>
  144. </xsl:call-template>
  145. </utml:value>
  146. </utml:input>
  147. </xsl:for-each>
  148. <utml:input name="p_admin_customized" type="hidden" utml:update="false">
  149. <utml:value>
  150. <xsl:value-of select="$ui-state-params[@name = 'admin_customized']"/>
  151. </utml:value>
  152. </utml:input>
  153. </xsl:if>
  154. <ui:page>
  155. <table border="0" cellspacing="0" cellpadding="2" width="100%">
  156. <tr>
  157. <td class="portlet-form-field-label" valign="top">
  158. <xts:string id="IDS_SDK_EDT_LABEL_NAME"/>
  159. </td>
  160. </tr>
  161. <tr>
  162. <td class="portlet-form-field" valign="top">
  163. <xsl:choose>
  164. <xsl:when test="$app">
  165. <xsl:value-of select="$app/@Title"/>
  166. </xsl:when>
  167. <xsl:otherwise>
  168. <i><xts:string id="IDS_SDK_EDT_LABEL_NO_APP_SELECTED"/></i>
  169. </xsl:otherwise>
  170. </xsl:choose>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td class="portlet-form-field">
  175. <a class="cognos-anchor" href="javascript:wsrp_rewrite_chooseApplication();"><xts:string id="IDS_SDK_EDT_LINK_SELECT_APP"/></a>
  176. <br/><br/>
  177. </td>
  178. </tr>
  179. <xsl:if test="$sdk-params">
  180. <!--
  181. render all parameters, except checkboxes, if any.
  182. -->
  183. <tr>
  184. <td>
  185. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  186. <tr>
  187. <td class="portlet-form-field-label" nowrap="nowrap"><xts:string id="IDS_SDK_EDT_GROUP_VIEWING_OPTIONS"/>&#160;</td>
  188. <td width="100%"><hr size="1"/></td>
  189. </tr>
  190. </table>
  191. </td>
  192. </tr>
  193. <tr>
  194. <td>
  195. <table border="0" cellspacing="0" cellpadding="2">
  196. <xsl:for-each select="$sdk-params[@Type != 'boolean']">
  197. <xsl:call-template name="render-param">
  198. <xsl:with-param name="param" select="."/>
  199. </xsl:call-template>
  200. </xsl:for-each>
  201. <!--
  202. if any checkboxes, render them in two columns
  203. -->
  204. <xsl:if test="$sdk-params[@Type = 'boolean']">
  205. <tr>
  206. <td>
  207. <table border="0" cellpadding="0" cellspacing="0">
  208. <tr>
  209. <xsl:for-each select="$sdk-params[@Type = 'boolean']">
  210. <xsl:call-template name="render-param-boolean">
  211. <xsl:with-param name="param" select="."/>
  212. </xsl:call-template>
  213. <td>
  214. <xsl:text>&#160;&#160;&#160;</xsl:text>
  215. </td>
  216. <!--
  217. close a row, and open a new one
  218. -->
  219. <xsl:if test="(position() mod 2) = 0">
  220. <xsl:text disable-output-escaping="yes">&lt;/tr&gt;&lt;tr&gt;</xsl:text>
  221. </xsl:if>
  222. </xsl:for-each>
  223. <!--
  224. add the missing TD if needed
  225. -->
  226. <xsl:if test="(count( $sdk-params[@Type = 'boolean'] ) mod 2) = 1">
  227. <td colspan="2">
  228. <xsl:text>&#160;</xsl:text>
  229. </td>
  230. </xsl:if>
  231. </tr>
  232. </table>
  233. </td>
  234. </tr>
  235. </xsl:if>
  236. </table>
  237. </td>
  238. </tr>
  239. </xsl:if>
  240. <xsl:if test="($utml-mode = 'cps:config') and ($app/Param[not(@Cps = 'true')])">
  241. <!--
  242. render all the application's parameters, if any. excluding the cps parameters.
  243. -->
  244. <tr>
  245. <td class="portlet-form-field-label">
  246. <br/>
  247. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  248. <tr>
  249. <td class="portlet-form-field-label" nowrap="nowrap"><xts:string id="IDS_SDK_EDT_APP_EXEC_PARAMS"/>&#160;</td>
  250. <td width="100%"><hr size="1"/></td>
  251. </tr>
  252. </table>
  253. </td>
  254. </tr>
  255. <tr>
  256. <td>
  257. <xsl:variable name="override">
  258. <xsl:choose>
  259. <xsl:when test="key('utml-key-params', 'p_admin_customized')">
  260. <!--
  261. already loaded, check the flag only
  262. -->
  263. <xsl:choose>
  264. <xsl:when test="( key('utml-key-params', 'p_admin_customized') = 'true' ) and ( not($reset) or ( key('utml-key-params', 'tmp_prev_alias') = '' ) )">
  265. <xsl:value-of select="true()"/>
  266. </xsl:when>
  267. <xsl:otherwise>
  268. <xsl:value-of select="false()"/>
  269. </xsl:otherwise>
  270. </xsl:choose>
  271. </xsl:when>
  272. <xsl:when test="$ui-state-params[@name = 'admin_customized'] != ''">
  273. <xsl:value-of select="$ui-state-params[@name = 'admin_customized']"/>
  274. </xsl:when>
  275. <!--
  276. first time the page is loaded
  277. -->
  278. <xsl:otherwise>
  279. <xsl:value-of select="false()"/>
  280. </xsl:otherwise>
  281. </xsl:choose>
  282. </xsl:variable>
  283. <utml:input name="p_admin_customized" type="hidden" utml:update="false">
  284. <utml:value>
  285. <xsl:value-of select="$override"/>
  286. </utml:value>
  287. </utml:input>
  288. <table border="0" cellspacing="0" cellpadding="2">
  289. <xsl:choose>
  290. <xsl:when test="$override = 'true'">
  291. <xsl:for-each select="$app/Param[not(@Cps = 'true')]">
  292. <xsl:call-template name="render-param">
  293. <xsl:with-param name="param" select="current()"/>
  294. </xsl:call-template>
  295. </xsl:for-each>
  296. <tr>
  297. <td class="portlet-form-field" colspan="3">
  298. <a class="cognos-anchor" href="javascript:wsrp_rewrite_editCommands('false')"><xts:string id="IDS_SDK_EDT_LINK_REMOVE_CUSTOMIZATION"/></a>
  299. </td>
  300. </tr>
  301. </xsl:when>
  302. <xsl:otherwise>
  303. <xsl:for-each select="$app/Param[not(@Cps = 'true')]">
  304. <xsl:call-template name="render-param-read-only">
  305. <xsl:with-param name="param" select="current()"/>
  306. </xsl:call-template>
  307. </xsl:for-each>
  308. <tr>
  309. <td class="portlet-form-field" colspan="3">
  310. <a class="cognos-anchor" href="javascript:wsrp_rewrite_editCommands('true')"><xts:string id="IDS_SDK_EDT_LINK_EDIT_COMMANDS"/></a>
  311. </td>
  312. </tr>
  313. </xsl:otherwise>
  314. </xsl:choose>
  315. </table>
  316. </td>
  317. </tr>
  318. </xsl:if>
  319. <!--
  320. SAP-HACK-START
  321. -->
  322. <ui:admin-settings/>
  323. <!--
  324. SAP-HACK-END
  325. -->
  326. </table>
  327. </ui:page>
  328. </utml:form>
  329. </xsl:template>
  330. <xsl:template name="render-param">
  331. <xsl:param name="param" select="current()"/>
  332. <tr title="{$param/@Description}">
  333. <td class="portlet-form-field-label" valign="top" nowrap="nowrap">
  334. <xsl:value-of select="$param/@Label"/>
  335. </td>
  336. </tr>
  337. <tr>
  338. <td class="portlet-form-field">
  339. <xsl:choose>
  340. <xsl:when test="$param/@Type = 'textarea'">
  341. <xsl:variable name="rows">
  342. <xsl:choose>
  343. <xsl:when test="$param/@Rows">
  344. <xsl:value-of select="$param/@Rows"/>
  345. </xsl:when>
  346. <xsl:otherwise>3</xsl:otherwise>
  347. </xsl:choose>
  348. </xsl:variable>
  349. <utml:textarea class="portlet-form-input-field" cols="80" rows="{ $rows }" name="p_sdk_{ $param/@Name }" utml:escape="true" utml:escape-prefix="$consumer-escape">
  350. <utml:value>
  351. <xsl:call-template name="get-param-value">
  352. <xsl:with-param name="param" select="$param"/>
  353. </xsl:call-template>
  354. </utml:value>
  355. </utml:textarea>
  356. </xsl:when>
  357. <xsl:when test="$param/@Type = 'enum'">
  358. <utml:select class="portlet-form-input-field" name="p_sdk_{ $param/@Name }">
  359. <utml:default-value>
  360. <xsl:call-template name="get-param-value">
  361. <xsl:with-param name="param" select="$param"/>
  362. </xsl:call-template>
  363. </utml:default-value>
  364. <xsl:for-each select="Value">
  365. <utml:option>
  366. <utml:value>
  367. <xsl:value-of select="@Name"/>
  368. </utml:value>
  369. <xsl:value-of select="."/>
  370. </utml:option>
  371. </xsl:for-each>
  372. </utml:select>
  373. </xsl:when>
  374. <xsl:otherwise>
  375. <xsl:variable name="size">
  376. <xsl:choose>
  377. <xsl:when test="$param/@Size">
  378. <xsl:value-of select="$param/@Size"/>
  379. </xsl:when>
  380. <xsl:otherwise>20</xsl:otherwise>
  381. </xsl:choose>
  382. </xsl:variable>
  383. <utml:input class="portlet-form-input-field" type="text" size="{$size}" name="p_sdk_{ $param/@Name }" utml:escape="true" utml:escape-prefix="$consumer-escape">
  384. <utml:value>
  385. <xsl:call-template name="get-param-value">
  386. <xsl:with-param name="param" select="$param"/>
  387. </xsl:call-template>
  388. </utml:value>
  389. </utml:input>
  390. </xsl:otherwise>
  391. </xsl:choose>
  392. </td>
  393. </tr>
  394. </xsl:template>
  395. <xsl:template name="render-param-read-only">
  396. <xsl:param name="param" select="current()"/>
  397. <tr title="{$param/@Description}">
  398. <td class="portlet-form-field" valign="top" nowrap="nowrap">
  399. <b>
  400. <xsl:value-of select="$param/@Label"/>
  401. </b>
  402. </td>
  403. <td class="portlet-form-field">
  404. <xsl:text>&#160;&#160;</xsl:text>
  405. </td>
  406. <td class="portlet-form-input-field">
  407. <xsl:choose>
  408. <xsl:when test="$param/@Type = 'textarea' or $param/@Type = 'text'">
  409. <xsl:choose>
  410. <xsl:when test="$param/child::node()">
  411. <xsl:value-of select="$param/child::node()"/>
  412. </xsl:when>
  413. <xsl:otherwise>
  414. <xsl:value-of select="$param/@Default"/>
  415. </xsl:otherwise>
  416. </xsl:choose>
  417. </xsl:when>
  418. <xsl:when test="$param/@Type = 'enum'">
  419. <xsl:variable name="enum-value">
  420. <xsl:choose>
  421. <xsl:when test="$param/@Value">
  422. <xsl:value-of select="$param/@Value"/>
  423. </xsl:when>
  424. <xsl:otherwise>
  425. <xsl:value-of select="$param/@Default"/>
  426. </xsl:otherwise>
  427. </xsl:choose>
  428. </xsl:variable>
  429. <xsl:value-of select="Value[normalize-space($param/@Name) = normalize-space($enum-value)]"/>
  430. </xsl:when>
  431. </xsl:choose>
  432. <utml:input type="hidden" name="p_sdk_{$param/@Name}" utml:update="false" utml:escape-prefix="$consumer-escape" utml:escape="true">
  433. <utml:value>
  434. <xsl:call-template name="get-param-value">
  435. <xsl:with-param name="param" select="$param"/>
  436. <xsl:with-param name="param-reset" select="key('utml-key-params', 'p_admin_customized') != 'true'"/>
  437. </xsl:call-template>
  438. </utml:value>
  439. </utml:input>
  440. </td>
  441. </tr>
  442. </xsl:template>
  443. <xsl:template name="render-param-boolean">
  444. <xsl:param name="param" select="current()"/>
  445. <td class="portlet-form-field" valign="top" title="{$param/@Description}">
  446. <utml:input type="checkbox" name="p_sdk_{ $param/@Name }" value="true">
  447. <utml:default-value>
  448. <xsl:call-template name="get-param-value">
  449. <xsl:with-param name="param" select="$param"/>
  450. </xsl:call-template>
  451. </utml:default-value>
  452. </utml:input>
  453. <xsl:value-of select="$param/@Label"/>
  454. </td>
  455. </xsl:template>
  456. <xsl:template name="get-param-value">
  457. <xsl:param name="param"/>
  458. <xsl:param name="param-reset" select="$reset"/>
  459. <xsl:variable name="sdk-name" select="concat( 'sdk_', $param/@Name )"/>
  460. <xsl:variable name="p-sdk-name" select="concat( 'p_sdk_', $param/@Name )"/>
  461. <xsl:choose>
  462. <xsl:when test="not($param-reset) and key( 'utml-key-params', string( $p-sdk-name ) )">
  463. <xsl:value-of select="key( 'utml-key-params', string( $p-sdk-name ) )"/>
  464. </xsl:when>
  465. <!--
  466. checkboxes don't return a value when they are unchecked
  467. -->
  468. <xsl:when test="not($param-reset) and (key( 'utml-key-params', 'edit_visited') = 'true') and ($param/@Type = 'boolean') and not( key( 'utml-key-params', $p-sdk-name ) )">
  469. <xsl:value-of select="'false'"/>
  470. </xsl:when>
  471. <xsl:when test="not($param-reset) and $ui-state-params[@name = $sdk-name]">
  472. <xsl:value-of select="$ui-state-params[@name = $sdk-name]"/>
  473. </xsl:when>
  474. <!--
  475. CPS 1.0 compatibility: convert cps_xxxx to sdk_cps_xxxx
  476. -->
  477. <xsl:when test="not($param-reset) and $ui-state-params[@name = $param/@Name]">
  478. <xsl:value-of select="$ui-state-params[@name = $param/@Name]"/>
  479. </xsl:when>
  480. <!--
  481. missing checkbox's value when an application is selected, use false
  482. -->
  483. <xsl:when test="not($param-reset) and ($alias != '') and ($param/@Type = 'boolean') and not($ui-state-params[@name = $sdk-name])">
  484. <xsl:value-of select="'false'"/>
  485. </xsl:when>
  486. <xsl:when test="$param/text() and not($param/*)">
  487. <xsl:value-of select="$param/."/>
  488. </xsl:when>
  489. <xsl:when test="$param/@Value">
  490. <xsl:value-of select="$param/@Value"/>
  491. </xsl:when>
  492. <xsl:otherwise>
  493. <xsl:value-of select="$param/@Default"/>
  494. </xsl:otherwise>
  495. </xsl:choose>
  496. </xsl:template>
  497. </xsl:stylesheet>
  498. <!-- This file was formated by XML Formatter (Cognos Inc.) on Aug 17, 2005 2:56:27 PM -->