specify_printer.xts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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, 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. <xts:morphlet messageBase="messages/portal.xml, messages/portalRL.xml" xmlns:xts="http://developer.cognos.com/schemas/xts/">
  13. <xts:block id="formlogic_init" type="exec" mode="interpret" processor="XSLT" path="/logicsheets/formlogic_init.xslt" nodelist="env,credential,system,http"/>
  14. <!--
  15. ===============================================================================================
  16. getContent - get content about printer.
  17. ===============================================================================================
  18. -->
  19. <xts:block id="getContent" processor="XSLT" type="exec" dependency="formlogic_init">
  20. <xts:logicsheet path="logicsheets/portal.xsl"/>
  21. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  22. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  23. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  24. xmlns:send="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/brl/1/"
  25. xmlns:bus="http://developer.cognos.com/schemas/bibus/3/"
  26. xmlns:cml="http://developer.cognos.com/schemas/xts/logic-sheet/xslt/cml/1/"
  27. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt">
  28. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  29. <cml:object-predicates/>
  30. <xsl:template match="root">
  31. <xts:sequence>
  32. <xts:append>
  33. <xts:transform src="transforms/CM/post-process.xslt" processor="XSLT">
  34. <send:request provider="cm">
  35. <xts:transform src="transforms/CM/pre-process.xslt" processor="XSLT">
  36. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  37. <cm:requests>
  38. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  39. <cm:search>CAMID(':')</cm:search>
  40. <cm:properties>
  41. <cm:property name="permissions"/>
  42. </cm:properties>
  43. </cm:query>
  44. <cm:query xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/">
  45. <cm:search>
  46. <xsl:text>CAMID(':')/printer[permission('read')]</xsl:text>
  47. <xsl:value-of select="$hidden-objects-predicate"/>
  48. </cm:search>
  49. <cm:properties>
  50. <cm:property name="defaultName"/>
  51. <cm:property name="searchPath"/>
  52. <cm:property name="location"/>
  53. <cm:property name="modelName"/>
  54. <cm:property name="printerAddress"/>
  55. <cm:property name="iconURI"/>
  56. <cm:property name="hidden"/>
  57. </cm:properties>
  58. <cm:sortBy>
  59. <cm:sort name="defaultName" order="ascending"/>
  60. </cm:sortBy>
  61. </cm:query>
  62. </cm:requests>
  63. </cm:query>
  64. </xts:transform>
  65. </send:request>
  66. </xts:transform>
  67. </xts:append>
  68. <xts:delete select="/root/env/param[@name='pagerfrom']"/>
  69. <xts:delete select="/root/env/param[@name='pagerto']"/>
  70. <xts:delete select="/root/env/param[@name='pagerfrom_d']"/>
  71. <xts:delete select="/root/env/param[@name='pagerto_d']"/>
  72. </xts:sequence>
  73. </xsl:template>
  74. </xsl:stylesheet>
  75. </xts:block>
  76. <!--
  77. ===============================================================================================
  78. select default printer
  79. ===============================================================================================
  80. -->
  81. <xts:block id="selectDefault" processor="XSLT" type="exec" dependency="getContent" condition=".[/root/env/param[@name='x_p_defaultName']!='']" mandatory="false">
  82. <xts:logicsheet path="logicsheets/portal.xsl"/>
  83. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  84. <xsl:stylesheet version="1.0"
  85. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  86. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  87. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  88. exclude-result-prefixes="xsl cm xtsext">
  89. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  90. <xsl:variable name="newPrinterName" select="/root/env/param[@name='x_p_defaultName']"/>
  91. <xsl:template match="/root/cm:queryResponse/cm:queryReply[2]/cm:printer[cm:defaultName=$newPrinterName]">
  92. <xts:sequence>
  93. <xts:replace select="/root/env/param[@name='m_ro_printerAddress']">
  94. <param name="m_ro_printerAddress">
  95. <xsl:value-of select="cm:printerAddress"/>
  96. </param>
  97. </xts:replace>
  98. <xts:replace select="/root/env/param[@name='select_printerAddress']">
  99. <param name="select_printerAddress">
  100. <xsl:value-of select="cm:printerAddress"/>
  101. </param>
  102. </xts:replace>
  103. <xts:replace select="/root/env/param[@name='m_ro_printer']">
  104. <param name="m_ro_printer">
  105. <xsl:value-of select="cm:searchPath"/>
  106. </param>
  107. </xts:replace>
  108. <xts:delete select="/root/env/param[@name='printeritem' or @name='select_printerName']"/>
  109. <xts:append select="/root/env">
  110. <param name="printeritem"><xsl:value-of select="cm:searchPath"/></param>
  111. <param name="select_printerName"><xsl:value-of select="cm:defaultName"/></param>
  112. </xts:append>
  113. </xts:sequence>
  114. </xsl:template>
  115. </xsl:stylesheet>
  116. </xts:block>
  117. <xts:block id="format" dependency="getContent selectDefault" mode="output" processor="XSLT" type="exec" mimeType="text/html">
  118. <xts:logicsheet path="logicsheets/portal.xsl"/>
  119. <xts:logicsheet path="logicsheets/presentation/dialog/framework.xsl"/>
  120. <xts:logicsheet path="logicsheets/presentation/layout.xsl"/>
  121. <xts:logicsheet path="logicsheets/presentation/dialog/presentation.xsl"/>
  122. <xts:logicsheet path="logicsheets/presentation/controls/framework.xsl"/>
  123. <xts:logicsheet path="logicsheets/presentation/controls/presentation.xsl"/>
  124. <xts:logicsheet path="logicsheets/formlogic.xslt"/>
  125. <xts:logicsheet path="logicsheets/validation.xslt"/>
  126. <xts:logicsheet path="logicsheets/presentation/touch_up.xslt"/>
  127. <xsl:stylesheet version="1.0"
  128. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  129. xmlns:cm="http://developer.cognos.com/schemas/xts-cm/1/"
  130. xmlns:pf="http://developer.cognos.com/schemas/xts/pf"
  131. xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt"
  132. xmlns:lyt="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/layout/"
  133. xmlns:dp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/presentation/"
  134. xmlns:df="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/framework/"
  135. xmlns:cf="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/framework/"
  136. xmlns:cp="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/controls/presentation/"
  137. xmlns:utml="http://developer.cognos.com/schemas/xts/logicsheet/xslt/formlogic/"
  138. exclude-result-prefixes="xsl cf cp df dp cf lyt cm utml xtsext">
  139. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
  140. <!-- current file name -->
  141. <xsl:variable name="mname" select="'specify_printer.xts'"/>
  142. <!-- icon generator -->
  143. <pf:gen-icon/>
  144. <!-- portal variables -->
  145. <pf:variables/>
  146. <xsl:variable name="has_write_permission" select="contains(/root/cm:queryResponse/cm:queryReply[1]/*/cm:permissions, 'write')"/>
  147. <xsl:variable name="xreturn">
  148. <xsl:choose>
  149. <xsl:when test="key('env-param','x_return') and key('env-param','x_return')!=''">
  150. <xsl:value-of select="key('env-param','x_return')"/>
  151. </xsl:when>
  152. <xsl:otherwise>
  153. <xsl:if test="key('env-param','m_return')">
  154. <xsl:value-of select="key('env-param','m_return')"/>
  155. </xsl:if>
  156. </xsl:otherwise>
  157. </xsl:choose>
  158. </xsl:variable>
  159. <xsl:variable name="lines">
  160. <xsl:choose>
  161. <xsl:when test="key('session-param', 'linesPerPage')">
  162. <xsl:value-of select="key('session-param', 'linesPerPage')"/>
  163. </xsl:when>
  164. <xsl:otherwise>
  165. <xsl:value-of select="/root/system/param[@name='defaultPortalPreferences']/pref[@name='lines']"/>
  166. </xsl:otherwise>
  167. </xsl:choose>
  168. </xsl:variable>
  169. <!-- This is here for show only. It is required by some controls to be present on the page. -->
  170. <xsl:variable name="back-url" select="key('env-param', 'backURL')"/>
  171. <xsl:variable name="newJobString">
  172. <xts:string id="IDS_ADDENTRIES_TITLE_NEW_JOB"/>
  173. </xsl:variable>
  174. <xsl:variable name="browserTitle">
  175. <xts:string id="IDS_SELECT_PRINTER_TITLE">
  176. <xts:param name="obj_name">
  177. <xsl:choose>
  178. <xsl:when test="/root/env/param[@name = 'm_new_class'] and (/root/env/param[@name = 'm_new_class'] != '') ">
  179. <xsl:value-of select="xtsext:enforceBTD($newJobString, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/>
  180. </xsl:when>
  181. <xsl:otherwise>
  182. <span lang="{$contentLocale}"><xsl:value-of select="xtsext:enforceBTD(key('env-param', 'm_name'), $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/></span>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. </xts:param>
  186. </xts:string>
  187. </xsl:variable>
  188. <!-- Start output -->
  189. <xsl:template match="/root">
  190. <xsl:text disable-output-escaping='yes'>&lt;!DOCTYPE html></xsl:text><dp:page longTitle="$browserTitle">
  191. <dp:meta>
  192. <pf:meta/>
  193. <!-- Standard meta tags -->
  194. </dp:meta>
  195. <dp:script>
  196. <pf:help context="HID_DISTRIB_PRINT"/>
  197. <!-- Help system -->
  198. <script language="JavaScript">
  199. function init()
  200. {
  201. <!-- Reset all form fields that get modified using client-side Javascript -->
  202. document.pform.m.value = "<xsl:value-of select="$app"/>/<xsl:value-of select="$mname"/>";
  203. document.pform.ps_nav_op.value = "maintain";
  204. document.pform.m_return.value = "<xsl:value-of select="xtsext:javascriptencode(string($xreturn))"/>";
  205. <xsl:if test="key('env-param','x_path') and key('env-param','x_path')!=''">
  206. document.pform.ifrmcmd.value = "<xsl:value-of select="xtsext:javascriptencode(string(key('env-param','x_ifrmcmd')))"/>";
  207. resetXCommand();
  208. </xsl:if>
  209. }
  210. function resetXCommand()
  211. {
  212. document.pform.x_path.value = "";
  213. document.pform.x_ifrmcmd.value = "";
  214. document.pform.x_p_defaultName.value = "";
  215. document.pform.x_p_defaultScreenTip.value = "";
  216. document.pform.x_p_defaultDescription.value = "";
  217. document.pform.x_new_class.value = "";
  218. document.pform.x_return.value = "";
  219. document.pform.x_p_printerAddress.value = "";
  220. document.pform.x_p_location.value = "";
  221. document.pform.x_p_modelName.value = "";
  222. }
  223. function radioState(radio, printerAdd, printerName)
  224. {
  225. document.pform.m_ro_printer.value = radio.value;
  226. document.pform.m_ro_printerAddress.value = printerAdd;
  227. document.pform.select_printerAddress.value = printerAdd;
  228. document.pform.select_printerName.value = printerName;
  229. }
  230. function doNewPrinter()
  231. {
  232. document.pform.x_ifrmcmd.value = "create";
  233. document.pform.x_path.value = "CAMID(':')";
  234. document.pform.x_return.value = "<xsl:value-of select="xtsext:javascriptencode(string(key('env-param','m_return')))"/>";
  235. document.pform.m_return.value = "<xsl:value-of select="$app"/>/<xsl:value-of select="$mname"/>";
  236. document.pform.m.value = "<xsl:value-of select="$app"/>/new_printer.xts";
  237. document.pform.submit();
  238. }
  239. function validate()
  240. {
  241. if ( !entrySelected() )
  242. {
  243. alert("<xts:string id="IDS_SELECT_PRINTER_ERR_NO_SELECTION" encode="javascript"/>" );
  244. return false;
  245. }
  246. else
  247. {
  248. //use "m_ro_printer" instead of "m_ro_printerAddress" to identify a printer
  249. document.pform.ro_printer_kw.value = 'printer';
  250. return true;
  251. }
  252. }
  253. function entrySelected()
  254. {
  255. <!--
  256. // See if we have radio buttons on the page. If there are, then make sure at least one is checked.
  257. // There is a special case when only one radio button exists.
  258. -->
  259. if (document.pform.printeritem)
  260. {
  261. if (document.pform.printeritem.length > 0)
  262. {
  263. for (var i=0; i&lt;document.pform.printeritem.length; i++)
  264. {
  265. if (document.pform.printeritem[i].checked)
  266. return true;
  267. }
  268. }
  269. else
  270. {
  271. return document.pform.printeritem.checked;
  272. }
  273. }
  274. return false;
  275. }
  276. </script>
  277. </dp:script>
  278. <utml:form name="pform" method="post" action="{$gateway}">
  279. <dp:header>
  280. <dp:title>
  281. <xsl:copy-of select="$browserTitle"/>
  282. </dp:title>
  283. <dp:description>
  284. <xts:string id="IDS_SELECT_PRINTER_INTRO"/>
  285. </dp:description>
  286. </dp:header>
  287. <lyt:layout style="1" border="no">
  288. <lyt:section>
  289. <utml:radio-group name="printeritem">
  290. <cf:main-pager-section form="pform">
  291. <cf:param name="item-path">cm:queryResponse/cm:queryReply[2]/*</cf:param>
  292. <cf:param name="target">concat(concat($app,'/'),$mname)</cf:param>
  293. <cf:param name="lines-per-page">
  294. <xsl:value-of select="$lines"/>
  295. </cf:param>
  296. <cf:param name="rows">
  297. <cp:tableHeader>
  298. <cp:columnHeader width="16"/>
  299. <cp:columnHeader width="20"/>
  300. <cp:columnHeader width="120">
  301. <xts:string id="IDS_NAME"/>
  302. </cp:columnHeader>
  303. <cp:columnHeader width="120">
  304. <xts:string id="IDS_PRINTER_ADDRESS"/>
  305. </cp:columnHeader>
  306. <cp:columnHeader width="120">
  307. <xts:string id="IDS_PRINTER_MODEL"/>
  308. </cp:columnHeader>
  309. <cp:columnHeader width="100%">
  310. <xts:string id="IDS_PRINTER_LOCATION"/>
  311. </cp:columnHeader>
  312. </cp:tableHeader>
  313. <cp:tableContent>
  314. <cp:columnContent>
  315. <utml:input type="radio" name="printeritem" onclick="radioState(this, '{xtsext:javascriptencode(string(cm:printerAddress))}', '{xtsext:javascriptencode(string(cm:defaultName))}')">
  316. <xsl:attribute name="aria-label"><xts:string id="IDS_SELECTION_FOR_PAGER_ITEM" encode="html"><xts:param name="pagerItemName"><xsl:value-of select="cm:defaultName"/></xts:param></xts:string></xsl:attribute>
  317. <utml:value>
  318. <xsl:value-of select="cm:searchPath"/>
  319. </utml:value>
  320. </utml:input>
  321. </cp:columnContent>
  322. <cp:columnContent>
  323. <xsl:call-template name="gen-icon">
  324. <xsl:with-param name="hiddenObject" select="cm:hidden"/>
  325. </xsl:call-template>
  326. </cp:columnContent>
  327. <cp:columnContent>
  328. <xsl:value-of select="xtsext:enforceBTD(cm:defaultName, $baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/>
  329. </cp:columnContent>
  330. <cp:columnContent>
  331. <xsl:value-of select="cm:printerAddress"/>
  332. </cp:columnContent>
  333. <cp:columnContent>
  334. <xsl:choose>
  335. <xsl:when test="cm:modelName != ''">
  336. <xsl:value-of select="cm:modelName"/>
  337. </xsl:when>
  338. <xsl:otherwise>&#160;</xsl:otherwise>
  339. </xsl:choose>
  340. </cp:columnContent>
  341. <cp:columnContent>
  342. <xsl:choose>
  343. <xsl:when test="cm:location!= ''">
  344. <xsl:value-of select="cm:location"/>
  345. </xsl:when>
  346. <xsl:otherwise>&#160;</xsl:otherwise>
  347. </xsl:choose>
  348. </cp:columnContent>
  349. </cp:tableContent>
  350. <!-- Show the "New Printer" option -->
  351. <cp:action>
  352. <xsl:if test="$has_write_permission">
  353. <utml:a utml:align="right">
  354. <utml:href>
  355. <xsl:text/>javascript:doNewPrinter()<xsl:text/>
  356. </utml:href>
  357. <xsl:text/><xts:string id="IDS_NEW_PRINTER"/><xsl:text/>
  358. </utml:a>
  359. <!-- Insert form variables to implement the "new printer" function -->
  360. <utml:input type="hidden" name="x_ifrmcmd" value=""/>
  361. <utml:input type="hidden" name="x_path" value=""/>
  362. <utml:input type="hidden" name="x_return" value=""/>
  363. <utml:input type="hidden" name="x_p_defaultName" value=""/>
  364. <utml:input type="hidden" name="x_p_defaultScreenTip" value=""/>
  365. <utml:input type="hidden" name="x_new_class" value=""/>
  366. <utml:input type="hidden" name="x_p_defaultDescription" value=""/>
  367. <utml:input type="hidden" name="x_p_printerAddress" value=""/>
  368. <utml:input type="hidden" name="x_p_modelName" value=""/>
  369. <utml:input type="hidden" name="x_p_location" value=""/>
  370. </xsl:if>
  371. </cp:action>
  372. </cf:param>
  373. </cf:main-pager-section>
  374. </utml:radio-group>
  375. </lyt:section>
  376. </lyt:layout>
  377. <!-- ===============================================================
  378. F o o t e r
  379. ================================================================= -->
  380. <dp:footer>
  381. <df:button df:id="IDS_OK" utml:validate="true" df:style="stack-down-save"/>
  382. <df:button df:id="IDS_CANCEL" df:style="stack-down"/>
  383. </dp:footer>
  384. <utml:input type="hidden" name="m_return" value=""/>
  385. <utml:input type="hidden" name="select_printerAddress" utml:update="false">
  386. <xsl:attribute name="value"><xsl:value-of select="key('env-param', 'm_ro_printerAddress')"/></xsl:attribute>
  387. </utml:input>
  388. <utml:input type="hidden" name="select_printerName" utml:update="false">
  389. <xsl:attribute name="value"><xsl:value-of select="/root/cm:queryResponse/cm:queryReply[2]/cm:printer[cm:printerAddress=key('env-param', 'm_ro_printerAddress')]/cm:defaultName"/></xsl:attribute>
  390. </utml:input>
  391. </utml:form>
  392. </dp:page>
  393. </xsl:template>
  394. </xsl:stylesheet>
  395. </xts:block>
  396. <!--
  397. ===============================================================================================
  398. debug - display debug information
  399. ===============================================================================================
  400. -->
  401. <xts:block id="debug" dependency="format" condition=".[ /root/session/param[@name='debug'] = '1' ]" type="exec" mode="output" processor="XSLT" mandatory="false" mimeType="text/html">
  402. <!-- get the debug logic sheet -->
  403. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  404. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dbg="http://developer.cognos.com/schemas/xts/logicsheets/xslt/debug/" exclude-result-prefixes="dbg">
  405. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
  406. <xsl:template match="/">
  407. <dbg:dumpxml select="/root"/>
  408. </xsl:template>
  409. </xsl:stylesheet>
  410. </xts:block>
  411. </xts:morphlet>