cps-ui-ext.xslt 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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, 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. <!-- $Header: //cpscrn/main/templates/cps4/producer/logicsheets/cps-ui-ext.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:out="dummy-uri"
  18. xmlns:xts="http://developer.cognos.com/schemas/xts/"
  19. xmlns:ui="http://developer.cognos.com/schemas/cps/logic/ui/1/"
  20. xmlns:uix="http://developer.cognos.com/schemas/cps/logic/ui-ext/1/"
  21. xmlns:utml="http://developer.cognos.com/schemas/cps/logic/form/1/">
  22. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  23. <xsl:namespace-alias stylesheet-prefix="out" result-prefix="xsl"/>
  24. <!--
  25. List of supported tags (see each template for details):
  26. uix:script-isValidURL
  27. uix:script-isValidChannel
  28. uix:script-isValidNumber
  29. uix:script-isValidBoundary
  30. uix:title
  31. uix:section-divider
  32. uix:open-links
  33. -->
  34. <xsl:template match="xsl:stylesheet" priority="1">
  35. <xsl:copy>
  36. <xsl:apply-templates select="@*"/>
  37. <out:attribute-set name="anchor">
  38. <out:attribute name="class">cognos-anchor</out:attribute>
  39. <out:attribute name="onmouseover">window.status='';return true;</out:attribute>
  40. <out:attribute name="onmouseout">window.status='';return true;</out:attribute>
  41. </out:attribute-set>
  42. <xsl:apply-templates select="*|text()|processing-instruction()"/>
  43. </xsl:copy>
  44. </xsl:template>
  45. <xsl:template match="uix:script-trim" priority="1">
  46. <script language="javascript">
  47. <![CDATA[
  48. //-- Removes leading and trailing spaces
  49. function wsrp_rewrite_trim(s)
  50. {
  51. var j = s.length;
  52. for (var i = 0; i < j; i++)
  53. if (s.charAt(i) != ' ')
  54. break;
  55. if (i < j - 1)
  56. for (; j > i; j--)
  57. if (s.charAt(j - 1) != ' ')
  58. break;
  59. return s.substring(i, j);
  60. }
  61. ]]>
  62. </script>
  63. </xsl:template>
  64. <xsl:template match="uix:script-isValidURL" priority="1">
  65. <script language="javascript">
  66. <![CDATA[
  67. function wsrp_rewrite_isValidURL(url, mandatory, checkBadChars)
  68. {
  69. if (url.length == 0 && mandatory == false) {
  70. // a blank is fine only if the option is not selected
  71. return true;
  72. }
  73. var sep = url.indexOf("//");
  74. var protocol = url.substring(0, sep).toLowerCase();
  75. var badChars = false;
  76. if (checkBadChars) {
  77. for (i = 0; i < url.length; i++) {
  78. var n = url.charCodeAt(i);
  79. if ( n <= 32 || n > 127 ) {
  80. badChars = true;
  81. break;
  82. }
  83. }
  84. }
  85. return ( ( (protocol == "http:") || (protocol == "https:") ) && (!badChars) && (url.length > sep + 2) );
  86. }
  87. ]]>
  88. </script>
  89. </xsl:template>
  90. <xsl:template match="uix:script-isValidChannel" priority="1">
  91. <script language="javascript">
  92. <![CDATA[
  93. function wsrp_rewrite_isValidChannel(channel, mandatory)
  94. {
  95. if (channel.length == 0 && mandatory == false) {
  96. // a blank is fine only if the option is not selected
  97. return true;
  98. }
  99. return (channel.length > 0) && (channel.length < 129) && (channel.match(new RegExp("[^A-Za-z0-9_]")) == null);
  100. }
  101. ]]>
  102. </script>
  103. </xsl:template>
  104. <xsl:template match="uix:script-isValidNumber" priority="1">
  105. <script language="javascript">
  106. <![CDATA[
  107. function wsrp_rewrite_isValidNumber(value, percentage)
  108. {
  109. var pct = false;
  110. var l = value.length;
  111. if (value.charAt(l - 1) == '%' && (percentage == true)) {
  112. // percentage validation
  113. pct = true;
  114. value = value.substring(0, l - 1);
  115. }
  116. // validate the number
  117. var n = Math.round(new Number(value));
  118. if (new Number(n).toString() != value) {
  119. return false;
  120. }
  121. if (pct && (n < 1 || n > 100)) {
  122. return false;
  123. }
  124. return true;
  125. }
  126. ]]>
  127. </script>
  128. </xsl:template>
  129. <xsl:template match="uix:script-isValidBoundary" priority="1">
  130. <script language="javascript">
  131. <![CDATA[
  132. function wsrp_rewrite_isValidBoundary(value, min, max,allowSpace)
  133. {
  134. if (value == "" && allowSpace){
  135. return true;
  136. }
  137. var n = Math.round(new Number(value));
  138. if (new Number(n).toString() == value && n >= min && n <= max) {
  139. return true;
  140. }
  141. return false;
  142. }
  143. ]]>
  144. </script>
  145. </xsl:template>
  146. <xsl:template match="uix:title" priority="1">
  147. <utml:exclude-prefix>p_title_</utml:exclude-prefix>
  148. <out:variable name="locales" select="/root/configuration/property[@name='contentLocales']/locale"/>
  149. <script language="javascript">
  150. <![CDATA[
  151. function wsrp_rewrite_setlang(x)
  152. {
  153. var cForm = document.wsrp_rewrite_form;
  154. var selectedLang = x.options[x.selectedIndex].value;
  155. if (selectedLang == "-") {
  156. x.selectedIndex = 0;
  157. selectedLang = x.options[0].value;
  158. }
  159. if (selectedLang != "-") {
  160. cForm.tmp_title.disabled = false;
  161. var curTitleLang = cForm["p_title_" + selectedLang];
  162. if ( curTitleLang != null ) {
  163. cForm.tmp_title.value = curTitleLang.value;
  164. }
  165. } else {
  166. cForm.tmp_title.disabled = true;
  167. }
  168. }
  169. function wsrp_rewrite_savelang(x)
  170. {
  171. var cForm = document.wsrp_rewrite_form;
  172. var sep,i,j;
  173. for (i=0; i<cForm.tmp_lang.options.length; i++) {
  174. if (cForm.tmp_lang.options[i].value == "-") {
  175. sep = cForm.tmp_lang.options[i];
  176. break;
  177. }
  178. }
  179. var curOption = cForm.tmp_lang.options[cForm.tmp_lang.selectedIndex];
  180. var selectedLang = curOption.value;
  181. cForm["p_title_" + selectedLang].value = x.value;
  182. if (cForm.tmp_lang.selectedIndex > i) {
  183. cForm.tmp_lang.removeChild(curOption);
  184. for (j=0; j<i; j++) {
  185. if (cForm.tmp_lang.options[j].text > curOption.text) {
  186. cForm.tmp_lang.insertBefore(curOption, cForm.tmp_lang.options[j]);
  187. cForm.tmp_lang.selectedIndex = j;
  188. return;
  189. }
  190. }
  191. cForm.tmp_lang.insertBefore(curOption, sep);
  192. cForm.tmp_lang.selectedIndex = i;
  193. }
  194. }
  195. function wsrp_rewrite_removelang()
  196. {
  197. var cForm = document.wsrp_rewrite_form;
  198. var curOption = cForm.tmp_lang.options[cForm.tmp_lang.selectedIndex];
  199. var selectedLang = curOption.value;
  200. if (selectedLang != "-") {
  201. cForm["p_title_" + selectedLang].value = "";
  202. cForm.tmp_title.value = "";
  203. var sep;
  204. for (i=0; i<cForm.tmp_lang.options.length;i++) {
  205. if (sep != null) {
  206. if (cForm.tmp_lang.options[i].text > curOption.text) {
  207. var insertPoint = cForm.tmp_lang.options[i];
  208. cForm.tmp_lang.removeChild(curOption);
  209. cForm.tmp_lang.insertBefore(curOption,insertPoint);
  210. break;
  211. }
  212. } else if (cForm.tmp_lang.options[i].value == "-") {
  213. sep = cForm.tmp_lang.options[i];
  214. }
  215. }
  216. cForm.tmp_lang.selectedIndex = 0;
  217. wsrp_rewrite_setlang(cForm.tmp_lang);
  218. }
  219. }
  220. ]]>
  221. </script>
  222. <out:variable name="visited" select="$ui-navigational-params[@name = 'edit_visited'] = 'true'"/>
  223. <out:variable name="tmp-lang" select="$ui-navigational-params[@name = 'tmp_lang']"/>
  224. <out:for-each select="$locales">
  225. <utml:input name="p_title_{ '{' } id { '}' }" type="hidden">
  226. <utml:value>
  227. <out:variable name="name"><out:if test="$visited">p_</out:if>title_<out:value-of select="id"/></out:variable>
  228. <out:choose>
  229. <out:when test="$visited">
  230. <out:choose>
  231. <out:when test="id = $tmp-lang">
  232. <out:value-of select="$ui-navigational-params[@name = 'tmp_title']"/>
  233. </out:when>
  234. <out:otherwise>
  235. <out:value-of select="$ui-navigational-params[@name = $name]"/>
  236. </out:otherwise>
  237. </out:choose>
  238. </out:when>
  239. <out:otherwise>
  240. <out:value-of select="$ui-state-params[@name = $name]"/>
  241. </out:otherwise>
  242. </out:choose>
  243. </utml:value>
  244. </utml:input>
  245. </out:for-each>
  246. <ui:page-sub-section-group>
  247. <out:variable name="user-locale" select="/root/titleLocale"/>
  248. <out:variable name="locales-in-nav" select="$locales[concat('p_title_',id) = $ui-navigational-params[starts-with(@name, 'p_title_') and .!='']/@name]"/>
  249. <out:variable name="locales-in-state" select="$locales[(concat('title_',id) = $ui-state-params[starts-with(@name, 'title_') and .!='']/@name) or (id = $user-locale and not($ui-state-params[starts-with(@name, 'title_')] != ''))]"/>
  250. <ui:page-sub-section>
  251. <ui:page-sub-section-title><label for="wsrp_rewrite_cpsLangSel"><xts:string id="IDS_PRO_UIX_LABEL_LANGUAGE"/></label></ui:page-sub-section-title>
  252. <ui:page-sub-section-content>
  253. <table border="0" cellspacing="0" cellpadding="1" role="presentation">
  254. <tr>
  255. <td class="portlet-font">
  256. <utml:select id="wsrp_rewrite_cpsLangSel" name="tmp_lang" size="1" onchange="wsrp_rewrite_setlang(this)" class="portlet-form-field">
  257. <xsl:if test="@onfocus">
  258. <xsl:attribute name="onfocus"><xsl:value-of select="@onfocus"/></xsl:attribute>
  259. </xsl:if>
  260. <utml:default-value>
  261. <out:value-of select="$user-locale"/>
  262. </utml:default-value>
  263. <out:choose>
  264. <out:when test="$visited">
  265. <out:for-each select="$locales-in-nav">
  266. <out:sort select="displayName" order="ascending"/>
  267. <utml:option>
  268. <utml:value>
  269. <out:value-of select="id"/>
  270. </utml:value>
  271. <out:value-of select="displayName"/>
  272. </utml:option>
  273. </out:for-each>
  274. <utml:option value="-">--------------------------------------</utml:option>
  275. <out:for-each select="$locales[not(id = $locales-in-nav/id)]">
  276. <out:sort select="displayName" order="ascending"/>
  277. <utml:option>
  278. <utml:value>
  279. <out:value-of select="id"/>
  280. </utml:value>
  281. <out:value-of select="displayName"/>
  282. </utml:option>
  283. </out:for-each>
  284. </out:when>
  285. <out:otherwise>
  286. <out:for-each select="$locales-in-state">
  287. <out:sort select="displayName" order="ascending"/>
  288. <utml:option>
  289. <utml:value>
  290. <out:value-of select="id"/>
  291. </utml:value>
  292. <out:value-of select="displayName"/>
  293. </utml:option>
  294. </out:for-each>
  295. <utml:option value="-">--------------------------------------</utml:option>
  296. <out:for-each select="$locales[not(id = $locales-in-state/id)]">
  297. <out:sort select="displayName" order="ascending"/>
  298. <utml:option>
  299. <utml:value>
  300. <out:value-of select="id"/>
  301. </utml:value>
  302. <out:value-of select="displayName"/>
  303. </utml:option>
  304. </out:for-each>
  305. </out:otherwise>
  306. </out:choose>
  307. </utml:select>
  308. &#160;
  309. <a href="javascript:wsrp_rewrite_removelang()">
  310. <xsl:attribute name="xsl:use-attribute-sets">anchor</xsl:attribute>
  311. <out:text/><xts:string id="IDS_PRO_UIX_LINK_REMOVE_LANGUAGE"/></a>
  312. </td>
  313. </tr>
  314. </table>
  315. </ui:page-sub-section-content>
  316. </ui:page-sub-section>
  317. <ui:page-sub-section tailing-space="false">
  318. <ui:page-sub-section-title><label for="wsrp_rewrite_cpsLangSelTitle"><xts:string id="IDS_PRO_UIX_LABEL_TITLE"/></label></ui:page-sub-section-title>
  319. <ui:page-sub-section-content>
  320. <table border="0" cellspacing="0" cellpadding="1">
  321. <xsl:if test="@style = '2'">
  322. <tr>
  323. <td class="portlet-form-field"><xts:string id="IDS_PRO_UIX_LABEL_TYPE_TITLE"/></td>
  324. </tr>
  325. </xsl:if>
  326. <tr>
  327. <td>
  328. <utml:input id="wsrp_rewrite_cpsLangSelTitle" name="tmp_title" type="text" size="40" onblur="wsrp_rewrite_savelang(this)" class="portlet-form-input-field">
  329. <xsl:if test="@onfocus">
  330. <xsl:attribute name="onfocus"><xsl:value-of select="@onfocus"/></xsl:attribute>
  331. </xsl:if>
  332. <utml:value>
  333. <out:variable name="name">title_<out:value-of select="$user-locale"/></out:variable>
  334. <out:choose>
  335. <out:when test="$ui-navigational-params[@name = $name]">
  336. <out:value-of select="$ui-navigational-params[@name = $name]"/>
  337. </out:when>
  338. <out:otherwise>
  339. <out:value-of select="$ui-state-params[@name = $name]"/>
  340. </out:otherwise>
  341. </out:choose>
  342. </utml:value>
  343. </utml:input>
  344. </td>
  345. </tr>
  346. </table>
  347. </ui:page-sub-section-content>
  348. </ui:page-sub-section>
  349. </ui:page-sub-section-group>
  350. </xsl:template>
  351. <xsl:template match="uix:section-divider" priority="1">
  352. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  353. <tr>
  354. <td class="portlet-form-field-label" nowrap="nowrap"><xts:string id="{@string}"/>&#160;</td>
  355. <td width="100%"><hr size="1"/></td>
  356. </tr>
  357. </table>
  358. </xsl:template>
  359. <xsl:template match="uix:open-links" priority="1">
  360. <xsl:param name="form">wsrp_rewrite_form</xsl:param>
  361. <ui:property name="open-links" select="'open_links'"/>
  362. <ui:property name="channel" select="'channel'"/>
  363. <ui:property name="target" select="'target'"/>
  364. <script language="javascript">
  365. function wsrp_rewrite_open_links_select(id)
  366. {
  367. document.getElementById(id).checked = true;
  368. }
  369. </script>
  370. <utml:radio-group name="p_open_links">
  371. <utml:default-value>
  372. <out:value-of select="$open-links"/>
  373. </utml:default-value>
  374. <table border="0" cellspacing="0" cellpadding="1" role="radiogroup" >
  375. <out:attribute name="aria-label"><xts:string id="{@rgLabel}"/></out:attribute>
  376. <tr>
  377. <td valign="top" class="portlet-form-field">
  378. <utml:input type="radio" class="portlet-form-field" aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_NEW_WINDOW">
  379. <utml:value>
  380. <out:choose>
  381. <out:when test="$open-links='current' and $ui-is-myportal">
  382. <out:text>current</out:text>
  383. </out:when>
  384. <out:otherwise>
  385. <out:text>new</out:text>
  386. </out:otherwise>
  387. </out:choose>
  388. </utml:value>
  389. </utml:input>
  390. </td>
  391. <td class="portlet-form-field" id="wsrp_rewrite_IDS_PRO_UIX_LABEL_NEW_WINDOW"><xts:string id="IDS_PRO_UIX_LABEL_NEW_WINDOW"/></td>
  392. </tr>
  393. <out:if test="not($ui-is-myportal)">
  394. <tr>
  395. <td valign="top" class="portlet-form-field">
  396. <utml:input aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_CURRENT_WINDOW" type="radio" value="current" class="portlet-form-field"/>
  397. </td>
  398. <td class="portlet-form-field" id="wsrp_rewrite_IDS_PRO_UIX_LABEL_CURRENT_WINDOW"><xts:string id="IDS_PRO_UIX_LABEL_CURRENT_WINDOW"/></td>
  399. </tr>
  400. </out:if>
  401. <tr>
  402. <td valign="top" class="portlet-form-field" rowspan="2">
  403. <utml:input type="radio" aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_TARGET_WINDOW" id='wsrp_rewrite_radio_target' value="target" class="portlet-form-field"/>
  404. </td>
  405. <td class="portlet-form-field" id="wsrp_rewrite_IDS_PRO_UIX_LABEL_TARGET_WINDOW"><xts:string id="IDS_PRO_UIX_LABEL_TARGET_WINDOW"/></td>
  406. </tr>
  407. <tr>
  408. <td>
  409. <utml:input aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_TARGET_WINDOW" name="p_target" type="text" size="40" class="portlet-form-input-field" onfocus="wsrp_rewrite_open_links_select('wsrp_rewrite_radio_target')">
  410. <utml:value>
  411. <out:value-of select="$target"/>
  412. </utml:value>
  413. </utml:input>
  414. </td>
  415. </tr>
  416. <tr>
  417. <td valign="top" class="portlet-form-field" rowspan="3">
  418. <utml:input type="radio" aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_CHANNEL" id='wsrp_rewrite_radio_channel' value="channel" class="portlet-form-field"/>
  419. </td>
  420. <td class="portlet-form-field" id="wsrp_rewrite_IDS_PRO_UIX_LABEL_CHANNEL"><xts:string id="IDS_PRO_UIX_LABEL_CHANNEL"/></td>
  421. </tr>
  422. <tr>
  423. <td class="portlet-msg-info"><xts:string id="{ @msgChannel }"/></td>
  424. </tr>
  425. <tr>
  426. <td>
  427. <utml:input aria-labelledby="wsrp_rewrite_IDS_PRO_UIX_LABEL_CHANNEL" name="p_channel" type="text" size="40" class="portlet-form-input-field" onfocus="wsrp_rewrite_open_links_select('wsrp_rewrite_radio_channel')">
  428. <utml:value>
  429. <out:value-of select="$channel"/>
  430. </utml:value>
  431. </utml:input>
  432. </td>
  433. </tr>
  434. </table>
  435. </utml:radio-group>
  436. </xsl:template>
  437. <xsl:template match="uix:*" priority="0">
  438. <xsl:call-template name="uix-compile-error">
  439. <xsl:with-param name="errno">0100</xsl:with-param>
  440. <xsl:with-param name="errmsg">Unsupported logicsheet tag: <xsl:value-of select="local-name(.)"/></xsl:with-param>
  441. </xsl:call-template>
  442. </xsl:template>
  443. <xsl:template name="uix-compile-error">
  444. <xsl:param name="errno"/>
  445. <xsl:param name="errmsg"/>
  446. <xsl:message>
  447. <xsl:text>CPS-ERR-</xsl:text>
  448. <xsl:value-of select="$errno"/>
  449. <xsl:text>: </xsl:text>
  450. <xsl:value-of select="$errmsg"/>
  451. <xsl:text>.</xsl:text>
  452. </xsl:message>
  453. <xsl:message terminate="yes">
  454. <xsl:text> ...at: </xsl:text>
  455. <xsl:for-each select="ancestor-or-self::node()[name()!='']">
  456. <xsl:text>/</xsl:text>
  457. <xsl:value-of select="name()"/>
  458. </xsl:for-each>
  459. </xsl:message>
  460. </xsl:template>
  461. <xsl:template match="*|@*|text()|processing-instruction()" priority="-1">
  462. <xsl:copy>
  463. <xsl:apply-templates select="*|@*|text()|processing-instruction()"/>
  464. </xsl:copy>
  465. </xsl:template>
  466. </xsl:stylesheet>