viewer-email.xts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. <!--
  2. Licensed Materials - Property of IBM
  3. IBM Cognos Products: Viewer
  4. (C) Copyright IBM Corp. 2001, 2011
  5. US Government Users Restricted Rights - Use, duplication or
  6. disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. -->
  8. <xts:morphlet xmlns:xts="http://developer.cognos.com/schemas/xts/" messageBase="messages/viewer.xml, messages/portal.xml, messages/portalRL.xml" includeConfig="true" requiredCapability="canUseCognosViewer">
  9. <!-- Reads session-sensitive info from CM -->
  10. <xts:block processor="XSLT" type="exec" mandatory="false"
  11. id="refreshSession"
  12. path="portal/cc/read_session.xml"
  13. condition=".[
  14. string(/root/cookies/cookie[@name = 'cc_session']) = ''
  15. or /root/env/param[@name='m_reload']
  16. or /root/env/param[@name='m_root'] ]">
  17. <xts:logicsheet path="logicsheets/cm-logic.xsl"/>
  18. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  19. </xts:block>
  20. <!-- Update the <session> element for this request. -->
  21. <xts:block id="buildSession" path="portal/session.xml" dependency="refreshSession" processor="XSLT" type="exec"
  22. condition=".[
  23. /root/newSession
  24. or /root/env/param[@name='ui']
  25. or /root/env/param[@name='d']
  26. or /root/env/param[starts-with(@name,'m_s_')]
  27. or /root/env/param[@name = 'resetSort'] ]"
  28. mandatory="false"/>
  29. <!-- Save changes to the state info in a cookie -->
  30. <xts:block mode="interpret" processor="XSLT" type="exec"
  31. id="setSession"
  32. path="portal/set_session.xml"
  33. dependency="buildSession"
  34. condition=".[/root/updateSession]"
  35. mandatory="false"/>
  36. <xts:block id="initialize" processor="XSLT" type="exec" mandatory="false">
  37. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
  38. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  39. <xsl:template match="/">
  40. <xts:sequence>
  41. <xts:append select="/root">
  42. <xsl:choose>
  43. <xsl:when test="/root/env/param[@name='controller_state']">
  44. <controllerState>
  45. <xsl:attribute name="controllerState">
  46. <xsl:value-of select="/root/env/param[@name='controller_state']"/>
  47. </xsl:attribute>
  48. </controllerState>
  49. </xsl:when>
  50. <xsl:otherwise>
  51. <!-- if this is the first pass through the morphlet, get the gateway URI -->
  52. <gateway>
  53. <xts:function name="getConfiguration">
  54. <xts:param name="gateway"/>
  55. </xts:function>
  56. </gateway>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xts:append>
  60. <xts:append select="/root/env">
  61. <param name="CAMNamespaceOnEmailLink">
  62. <xts:function name="getConfiguration">
  63. <xts:param name="CAMNamespaceOnEmailLink"/>
  64. </xts:function>
  65. </param>
  66. </xts:append>
  67. <!--add an m_name env variable so the email dialog defaults the subject properly-->
  68. <xts:append select="/root/env">
  69. <param name="m_name"><xsl:value-of select="/root/env/param[@name='ui.name']"/></param>
  70. </xts:append>
  71. </xts:sequence>
  72. </xsl:template>
  73. </xsl:stylesheet>
  74. </xts:block>
  75. <!--
  76. ===============================================================================================
  77. generateDefaultEmailOptions - If no delivery options where save on the object and it's the
  78. first time we hit this page then generate defaults
  79. ===============================================================================================
  80. -->
  81. <xts:block id="generateDefaultEmailOptions" dependency="initialize setSession" path="/portal/emailOptions/logicsheets/generate_defaults.xslt" processor="XSLT" type="exec" condition=".[not(/root/controllerState) and not(string(/root/env/param[@name='executeEmail'])='true')]" mandatory="false">
  82. <xts:logicsheet path="logicsheets/presentation/dialog/controller-templates.xsl"/>
  83. </xts:block>
  84. <!--
  85. ===============================================================================================
  86. processDefaultEmailOptions - If no delivery options where save on the object and it's the
  87. first time we hit then process the default delivery options.
  88. ===============================================================================================
  89. -->
  90. <xts:block id="processDefaultEmailOptions" path="/portal/emailOptions/logicsheets/process_email_options.xslt" processor="XSLT" dependency="generateDefaultEmailOptions" type="exec" condition=".[not(/root/controllerState) and not(string(/root/env/param[@name='executeEmail'])='true')]" mandatory="false">
  91. <xts:logicsheet path="logicsheets/presentation/dialog/controller-templates.xsl"/>
  92. <xts:logicsheet path="logicsheets/presentation/dialog/templates.xsl"/>
  93. <xts:logicsheet path="logicsheets/portal.xsl"/>
  94. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  95. </xts:block>
  96. <xts:block id="generateEmailParams" processor="XSLT" type="exec" dependency="processDefaultEmailOptions" condition=".[not(/root/controllerState) and not(string(/root/env/param[@name='executeEmail'])='true')]" mandatory="false">
  97. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" exclude-result-prefixes="xsl xtsext">
  98. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  99. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  100. <xsl:template match="/">
  101. <xts:sequence>
  102. <xts:append select="/root/env">
  103. <param name="controller_state">email|markup</param>
  104. <xsl:variable name="linkToReport">
  105. <xsl:value-of select="/root/*[local-name()='gateway']"/>
  106. <xsl:text>?b_action=cognosViewer</xsl:text>
  107. <xsl:if test="/root/env/param[@name='CAMNamespaceOnEmailLink']='true' or /root/env/param[@name='CAMNamespaceOnEmailLink']='TRUE'">
  108. <xsl:variable name="camNamespace">
  109. <xsl:value-of select="substring-before(substring-after(/root/session/param[@name = 'e_hp'], 'CAMID(&quot;' ), ':')"/>
  110. </xsl:variable>
  111. <xsl:if test="$camNamespace!= ''" >
  112. <xsl:text>&amp;CAMNamespace=</xsl:text>
  113. <xsl:value-of select="$camNamespace"/>
  114. </xsl:if>
  115. </xsl:if>
  116. <xsl:choose>
  117. <xsl:when test="key('env-param','ui.action')='view'">&amp;ui.action=view</xsl:when>
  118. <xsl:otherwise>&amp;ui.action=run</xsl:otherwise>
  119. </xsl:choose>
  120. <xsl:text>&amp;ui.object=</xsl:text>
  121. <xsl:value-of select="xtsext:protect(xtsext:urlencode(string(key('env-param','ui.object'))),'url','url','getdata')"/>
  122. <xsl:text>&amp;run.outputFormat=</xsl:text>
  123. <xsl:value-of select="key('env-param','run.outputFormat')"/>
  124. <xsl:text>&amp;run.outputLocale=</xsl:text>
  125. <xsl:value-of select="key('env-param','run.outputLocale')"/>
  126. <xsl:if test="key('env-param','lang')!=''">
  127. <xsl:text>&amp;lang=</xsl:text>
  128. <xsl:value-of select="key('env-param','lang')"/>
  129. </xsl:if>
  130. </xsl:variable>
  131. <xsl:variable name="html-markup">
  132. <xsl:text>&lt;A href=&quot;</xsl:text>
  133. <xsl:value-of select="$linkToReport"/>
  134. <xsl:text>&quot;&gt;</xsl:text>
  135. <xsl:choose>
  136. <xsl:when test="contains(string(key('env-param','run.outputFormat')), 'HTML')">HTML</xsl:when>
  137. <xsl:otherwise><xsl:value-of select="key('env-param', 'run.outputFormat')"/></xsl:otherwise>
  138. </xsl:choose>
  139. <xsl:text>&lt;/A&gt;</xsl:text>
  140. </xsl:variable>
  141. <param name="linkToReport"><xsl:value-of select="$html-markup"/></param>
  142. <param name="hideEmailAsAttachment">
  143. <xsl:choose>
  144. <xsl:when test="key('env-param', 'hideEmailAsAttachment')!=''"><xsl:value-of select="key('env-param', 'hideEmailAsAttachment')"/></xsl:when>
  145. <xsl:when test="key('env-param','ui.action')='view'">true</xsl:when>
  146. <xsl:otherwise>false</xsl:otherwise>
  147. </xsl:choose>
  148. </param>
  149. <param name="hideLinkToReport">
  150. <xsl:choose>
  151. <xsl:when test="key('env-param', 'hideLinkToReport')!=''"><xsl:value-of select="key('env-param', 'hideLinkToReport')"/></xsl:when>
  152. <xsl:when test="key('env-param','run.continueConversation') = 'true'">false</xsl:when>
  153. <xsl:otherwise>true</xsl:otherwise>
  154. </xsl:choose>
  155. </param>
  156. </xts:append>
  157. <xts:delete select="/root/*[local-name()='morphletResponse']"/>
  158. </xts:sequence>
  159. </xsl:template>
  160. </xsl:stylesheet>
  161. </xts:block>
  162. <!--
  163. ===============================================================================================
  164. callMorphlet - Calls the appropriate morphlet using the passed in params which will return
  165. markup to be displayed or the expected results
  166. ===============================================================================================
  167. -->
  168. <xts:block id="callMorphlet" processor="XSLT" dependency="generateEmailParams" type="exec" condition=".[ /root/env/param[@name='controller_state'] != '' ]" mandatory="false">
  169. <xts:logicsheet path="logicsheets/presentation/dialog/controller-templates.xsl"/>
  170. <xts:logicsheet path="logicsheets/portal.xsl"/>
  171. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:req-params="http://developer.cognos.com/schemas/request/params" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" exclude-result-prefixes="xsl dlgctrl xtsext req-params pf">
  172. <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
  173. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  174. <pf:variables/>
  175. <xsl:template match="/">
  176. <xts:sequence>
  177. <dlgctrl:XTS2Request>
  178. <dlgctrl:target>/portal/emailOptions/email_options.xts</dlgctrl:target>
  179. <dlgctrl:stackName>viewer-email</dlgctrl:stackName>
  180. <req-params:param name="options"><xsl:value-of select="key('env-param','deliveryOptions')"/></req-params:param>
  181. <req-params:param name="titlePrefix"><xts:string id="IDS_EMAIL_OPTIONS_TITLE_PREFIX"/></req-params:param>
  182. <req-params:param name="titlePostfix"><xsl:value-of select="xtsext:enforceBTD(key('env-param','ui.name'),$baseTextDirection, $productLocale, boolean($isBidiEnabled='true'))"/></req-params:param>
  183. <req-params:param name="defaultTarget">/portal/viewer-email.xts</req-params:param>
  184. <req-params:param name="hideEmailAsAttachment"><xsl:value-of select="key('env-param','hideEmailAsAttachment')"/></req-params:param>
  185. <req-params:param name="linkToReport"><xsl:value-of select="key('env-param','linkToReport')"/></req-params:param>
  186. <req-params:param name="reportViewer">true</req-params:param>
  187. <!--
  188. If we don't want to continue the conversation, then we're being called from the wait page so we
  189. should hide the 'Include a link to the report' link.
  190. -->
  191. <req-params:param name="hideLinkToReport"><xsl:value-of select="key('env-param','hideLinkToReport')"/></req-params:param>
  192. <!-- Fix for COGCQ00225444 - only if we want to hide attachment, otherwise, we want to check attachment as default -->
  193. <req-params:param name="m_ro_emailAsAttachment">
  194. <xsl:choose>
  195. <xsl:when test="key('env-param','hideEmailAsAttachment') = 'true'">false</xsl:when>
  196. <xsl:otherwise>true</xsl:otherwise>
  197. </xsl:choose>
  198. </req-params:param>
  199. </dlgctrl:XTS2Request>
  200. </xts:sequence>
  201. </xsl:template>
  202. </xsl:stylesheet>
  203. </xts:block>
  204. <!--
  205. ===============================================================================================
  206. processReponse - Process the response from the callMorphlet block and either displays
  207. the markup or processes the results
  208. ===============================================================================================
  209. -->
  210. <xts:block id="processResponse" path="/portal/emailOptions/logicsheets/process_email_options.xslt" processor="XSLT" dependency="callMorphlet" type="exec" condition=".[ /root/env/param[@name='controller_state'] != '' ]" mandatory="false">
  211. <xts:logicsheet path="logicsheets/presentation/dialog/controller-templates.xsl"/>
  212. <xts:logicsheet path="logicsheets/presentation/dialog/templates.xsl"/>
  213. <xts:logicsheet path="logicsheets/portal.xsl"/>
  214. <xts:logicsheet path="logicsheets/buslogic.xslt"/>
  215. </xts:block>
  216. <xts:block id="sendRequest" processor="XSLT" type="exec" mode="output" dependency="processResponse" mimeType="text/html" contentId="callEmail" partId="1" condition=".[/root/controllerState[@controllerState='email|finished' or @controllerState='email|canceled']]" mandatory="false">
  217. <xts:logicsheet path="logicsheets/portal.xsl"/>
  218. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dlgctrl="http://developer.cognos.com/schemas/xts/logicsheets/xslt/presentation/dialog/controller-templates/" xmlns:xtsext="xalan://com.cognos.xts.ext.XTSExt" xmlns:req-params="http://developer.cognos.com/schemas/request/params" xmlns:pf="http://developer.cognos.com/schemas/xts/pf" exclude-result-prefixes="xsl dlgctrl xtsext req-params">
  219. <xsl:output method="html" encoding="utf-8" indent="no"/>
  220. <xsl:key name="env-param" match="/root/env/param" use="@name"/>
  221. <pf:variables/>
  222. <xsl:template match="/">
  223. <xsl:variable name="method">
  224. <xsl:choose>
  225. <xsl:when test="/root/*[local-name()='morphletResponse']/*[local-name()='options']/*/*[local-name()='item'][*[local-name()='name']='emailAsAttachment']/*[local-name()='value']='true'">email</xsl:when>
  226. <xsl:otherwise>run</xsl:otherwise>
  227. </xsl:choose>
  228. </xsl:variable>
  229. <xsl:variable name="emailOptions">
  230. <xsl:call-template name="serialize-xml">
  231. <xsl:with-param name="node-set">
  232. <options xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="bus:option[]">
  233. <xsl:copy-of select="/root/*[local-name()='morphletResponse']/*[local-name()='options']/*/*"/>
  234. <xsl:if test="$method != 'run'">
  235. <item xsi:type="bus:runOptionBoolean">
  236. <name xsi:type="bus:runOptionEnum">continueConversation</name>
  237. <value xsi:type="xsd:boolean"><xsl:value-of select="key('env-param', 'run.continueConversation')"/></value>
  238. </item>
  239. </xsl:if>
  240. </options>
  241. </xsl:with-param>
  242. </xsl:call-template>
  243. </xsl:variable>
  244. <xsl:variable name="web64encodedEmailOptions">
  245. <xsl:value-of select="xtsext:cafaction(concat('sign_wrap_setpassportid_', $passport), xtsext:web64encode(string($emailOptions), true()))"/>
  246. </xsl:variable>
  247. <html>
  248. <head>
  249. <link rel="stylesheet" type="text/css" href="{$skin_root}/portal/default.css"/>
  250. <link rel="stylesheet" type="text/css" href="{$skin_root}/qs/RVReport.css"/>
  251. <script language="javascript">
  252. function finish()
  253. {
  254. var form = document.getElementById("executeEmail");
  255. if (typeof form != "undefined" &amp;&amp; form != null)
  256. {
  257. if (typeof form.pageVisited != "undefined" &amp;&amp; form.pageVisited != null &amp;&amp; form.pageVisited.value.length > 0)
  258. {
  259. window.history.go(+1);
  260. return;
  261. }
  262. else if (typeof form.pageVisited != "undefined" &amp;&amp; form.pageVisited != null)
  263. {
  264. <!-- set the page visited value so if the user hits the back button in the browser it'll have a value -->
  265. form.pageVisited.value = "true";
  266. }
  267. }
  268. <xsl:choose>
  269. <xsl:when test="/root/controllerState[@controllerState='email|canceled']">
  270. if(typeof parent.destroyCModal == "function")
  271. {
  272. parent.destroyCModal();
  273. }
  274. else if (window.opener)
  275. {
  276. window.close();
  277. }
  278. var oCognosViewerObject = parent.oCV<xsl:value-of select="key('env-param', 'cv.id')"/>;
  279. if (oCognosViewerObject)
  280. {
  281. if(oCognosViewerObject.getStatus() == "working" || oCognosViewerObject.getStatus() == "stillWorking")
  282. {
  283. oCognosViewerObject.getWorkingDialog().show();
  284. }
  285. }
  286. </xsl:when>
  287. <xsl:otherwise>
  288. var oCognosViewerObject = parent.oCV<xsl:value-of select="key('env-param', 'cv.id')"/>;
  289. if (oCognosViewerObject)
  290. {
  291. oCognosViewerObject.closeActiveHTTPConnection();
  292. oCognosViewerObject.removeTransparentBackgroundLayer();
  293. <xsl:if test="$method='email' and key('env-param','run.continueConversation')='false'">
  294. <!--so the viewer framework doesn't cancel the request when we exit, set it to keep the session alive-->
  295. oCognosViewerObject.setKeepSessionAlive(true);
  296. </xsl:if>
  297. }
  298. form.submit();
  299. setTimeout('document.progress.src="<xsl:value-of select="xtsext:javascriptencode($brand_images)"/>progress.gif"',1);
  300. </xsl:otherwise>
  301. </xsl:choose>
  302. }
  303. </script>
  304. </head>
  305. <body onload="finish();">
  306. <form action="{/root/http/param[@name='SCRIPT_NAME']}" name="executeEmail" id="executeEmail" method="post" style="display:none;height:100%;margin:0px">
  307. <input type="hidden" name="pageVisited" value=""/>
  308. <input type="hidden" name="b_action" value="cognosViewer"/>
  309. <input type="hidden" name="cv.id" value="{key('env-param','cv.id')}"/>
  310. <input type="hidden" name="email.options">
  311. <xsl:attribute name="value">
  312. <xsl:value-of select="$web64encodedEmailOptions"/>
  313. </xsl:attribute>
  314. </input>
  315. <input type="hidden" name="email.method" value="{$method}"/>
  316. <input type="hidden" name="cv.header" value="false"/>
  317. <input type="hidden" name="ui.action" value="email"/>
  318. <input type="hidden" name="cv.responseFormat" value="closeDialog"/>
  319. <input type="hidden" name="m_tracking" value="{key('env-param', 'm_tracking')}"/>
  320. <input type="hidden" name="ui.conversation" value="{key('env-param','ui.conversation')}"/>
  321. <input type="hidden" name="ui.routingServerGroup" value="{key('env-param','ui.routingServerGroup')}"/>
  322. <input type="hidden" name="run.continueConversation" value="{key('env-param','run.continueConversation')}"/>
  323. <input type="hidden" name="ui.backURL">
  324. <xsl:attribute name="value">
  325. <xsl:choose>
  326. <xsl:when test="string(key('env-param','ui.backURL')) != ''">
  327. <xsl:value-of select="key('env-param','ui.backURL')"/>
  328. </xsl:when>
  329. <xsl:otherwise>
  330. <xsl:value-of select="key('env-param','backURL')"/>
  331. </xsl:otherwise>
  332. </xsl:choose>
  333. </xsl:attribute>
  334. </input>
  335. </form>
  336. <table id="workingStatus" cellspacing="0" height="100%" width="100%" cellpadding="0" align="center" valign="middle">
  337. <tr>
  338. <td width="100%" height="100%" align="center" valign="middle">
  339. <table align="center" cellspacing="0" cellpadding="0" style="vertical-align:middle; border:1px outset;" class="busyBody">
  340. <tr>
  341. <td rowspan="2">
  342. <img src="{$brand_images}progress.gif" style="margin:5px;" width="48" height="48" name="progress"/>
  343. </td>
  344. <td nowrap="nowrap">
  345. <span class="busyUpdatingStr">
  346. <xts:string id="GOTO_WORKING"/>
  347. </span>
  348. </td>
  349. </tr>
  350. <tr>
  351. <td nowrap="nowrap">
  352. <span class="busyUpdatingStr">
  353. <xts:string id="RV_PLEASE_WAIT"/>
  354. </span>
  355. </td>
  356. </tr>
  357. <tr>
  358. <td style="height:7px;" colspan="2"/>
  359. </tr>
  360. </table>
  361. </td>
  362. </tr>
  363. </table>
  364. </body>
  365. </html>
  366. </xsl:template>
  367. <pf:serialize-xml/>
  368. </xsl:stylesheet>
  369. </xts:block>
  370. <!--
  371. ===============================================================================================
  372. debug - display debug information
  373. ===============================================================================================
  374. -->
  375. <xts:block id="debug" dependency="sendRequest" condition=".[/root/session/param[@name='debug']='1']" type="exec" mode="output" processor="XSLT" mandatory="false" mimeType="text/html">
  376. <!-- get the debug logic sheet -->
  377. <xts:logicsheet path="logicsheets/debuglogic.xslt"/>
  378. <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">
  379. <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>
  380. <xsl:template match="/">
  381. <dbg:dumpxml select="/root"/>
  382. </xsl:template>
  383. </xsl:stylesheet>
  384. </xts:block>
  385. </xts:morphlet>