/_zewdCompiler7.m

http://github.com/robtweed/EWD · Objective C · 1405 lines · 1405 code · 0 blank · 0 comment · 8 complexity · 6121e654da32b99c64f061f4ed4620e7 MD5 · raw file

  1. %zewdCompiler7 ; Enterprise Web Developer Compiler Functions
  2. ;
  3. ; Product: Enterprise Web Developer (Build 931)
  4. ; Build Date: Fri, 27 Jul 2012 12:05:04
  5. ;
  6. ; ----------------------------------------------------------------------------
  7. ; | Enterprise Web Developer for GT.M and m_apache |
  8. ; | Copyright (c) 2004-12 M/Gateway Developments Ltd, |
  9. ; | Reigate, Surrey UK. |
  10. ; | All rights reserved. |
  11. ; | |
  12. ; | http://www.mgateway.com |
  13. ; | Email: rtweed@mgateway.com |
  14. ; | |
  15. ; | This program is free software: you can redistribute it and/or modify |
  16. ; | it under the terms of the GNU Affero General Public License as |
  17. ; | published by the Free Software Foundation, either version 3 of the |
  18. ; | License, or (at your option) any later version. |
  19. ; | |
  20. ; | This program is distributed in the hope that it will be useful, |
  21. ; | but WITHOUT ANY WARRANTY; without even the implied warranty of |
  22. ; | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
  23. ; | GNU Affero General Public License for more details. |
  24. ; | |
  25. ; | You should have received a copy of the GNU Affero General Public License |
  26. ; | along with this program. If not, see <http://www.gnu.org/licenses/>. |
  27. ; ----------------------------------------------------------------------------
  28. ;
  29. QUIT
  30. ;
  31. ;
  32. eventBroker(allArray,docOID,jsOID,phpHeaderArray,filename,docName,routineName,nextPageList,formDeclaration,technology,mgwsiServer,backend) ;
  33. ;
  34. ; Find all ewd:func() calls
  35. ;
  36. ; First in onXXX attributes
  37. ;
  38. n addJSComment,attr,attrName,attrOID,attrValue,%changed,dlim,docName,eventName,eventNo
  39. n headOID,i,%id,initialEventNo,jsText,jsTextArray,jsTextOID,language,length,line,method,newText
  40. n nnmOID,nodeOID,nodeType,%np,ntags,%nvp,OIDArray,olOID,%p1,%p2,%p2a,%p2b,%p3,%p4,%p5
  41. n page,paramList,tagName,%trace,src,%url,value
  42. ;
  43. s nodeOID="",eventNo=$o(formDeclaration(""),-1),initialEventNo=eventNo
  44. f s nodeOID=$o(allArray(0,nodeOID)) q:nodeOID="" d
  45. . s nodeType=$$getNodeType^%zewdDOM(nodeOID)
  46. . i nodeType'=1 q
  47. . q:$$hasAttributes^%zewdDOM(nodeOID)="false"
  48. . s tagName=$$getTagName^%zewdDOM(nodeOID)
  49. . s nnmOID=$$getAttributes^%zewdCompiler(nodeOID,.attr)
  50. . s attrName=""
  51. . f s attrName=$o(attr(attrName)) q:attrName="" d
  52. . . q:$e(attrName,1,2)'="on"
  53. . . s attrOID=attr(attrName)
  54. . . s attrValue=$$getValue^%zewdDOM(attrOID)
  55. . . i $e(attrValue,1,13)="EWD.page.goNextPage" d goNextPage^%zewdCompiler(attrName,attrValue,nodeOID) q
  56. . . i $$zcvt^%zewdAPI(attrValue,"L")["ewdjump" d q
  57. . . . s attrValue=$$convertSubstringCase^%zewdHTMLParser(attrValue,"ewdjump","L")
  58. . . . s %p1=$p(attrValue,"ewdjump",1)
  59. . . . s %p2=$p(attrValue,"ewdjump",2)
  60. . . . s page=$$getAttributeValue^%zewdDOM("page",1,nodeOID)
  61. . . . s value="EWD.page.goNextPage('"_page_"',<?= $tokens("""_page_""") ?>','<?= sessionArray(""ewd_token"") ?>')"
  62. . . . s attrValue=%p1_value_%p2
  63. . . . d setAttribute^%zewdDOM(attrName,attrValue,nodeOID)
  64. . . . d removeAttribute^%zewdAPI("page",nodeOID)
  65. . . . s nextPageList(page)=""
  66. . . q:$e(attrValue,1,4)'="ewd:"
  67. . . d parseEventBrokerCall(attrValue)
  68. ;
  69. ; Now look in all JavaScript functions
  70. ;
  71. s docName=$$getDocumentName^%zewdDOM(docOID)
  72. s ntags=$$getTagsByName^%zewdCompiler("script",docName,.OIDArray)
  73. s nodeOID=""
  74. f s nodeOID=$o(OIDArray(nodeOID)) q:nodeOID="" d
  75. . s language=$$getAttributeValue^%zewdDOM("language",1,nodeOID)
  76. . i language="" s language="javascript"
  77. . q:$$zcvt^%zewdAPI(language,"L")'["javascript"
  78. . s src=$$getAttributeValue^%zewdDOM("src",1,nodeOID)
  79. . q:src'=""
  80. . s jsTextOID="" k addJSComment
  81. . f s jsTextOID=$$getNextChild^%zewdAPI(nodeOID,jsTextOID) q:jsTextOID="" d
  82. . . s jsText=$$getData^%zewdDOM(jsTextOID)
  83. . . i $g(addJSComment(jsTextOID))=1 s jsText="/*ewd:comment"_jsText,addJSComment=0
  84. . . ;
  85. . . ; remove any ewd:comment text from within the JavaScript
  86. . . ;
  87. . . s %changed=0
  88. . . i jsText["*/ewd:comment" d
  89. . . . s %p1=$p(jsText,"*/ewd:comment",1)
  90. . . . i %p1'["/*ewd:comment" s jsText=$p(jsText,"*/ewd:comment",2,2000)
  91. . . f q:jsText'["/*ewd:comment" d
  92. . . . s %p1=$p(jsText,"/*ewd:comment",1)
  93. . . . s %p2=$p(jsText,"*/ewd:comment",2,2000) i jsText'["*/ewd:comment" s addJSComment($$getNextChild^%zewdAPI(nodeOID,jsTextOID))=1
  94. . . . i %p1=$c(13,10) s %p1=""
  95. . . . i %p1=$c(10) s %p1=""
  96. . . . i $e(%p2,1,2)=$c(13,10) s %p2=$e(%p2,3,$l(%p2))
  97. . . . i $e(%p2,1)=$c(10) s %p2=$e(%p2,2,$l(%p2))
  98. . . . s jsText=%p1_%p2
  99. . . . s %changed=1
  100. . . i %changed s jsTextOID=$$modifyTextData^%zewdDOM(jsText,jsTextOID)
  101. . . ;
  102. . . i $l(jsText)>2000 d
  103. . . . n dlim,jsText1,jsText2,np,p1,textOID
  104. . . . s jsText1=$e(jsText,1,2000)
  105. . . . s jsText2=$e(jsText,(2000+1),$l(jsText))
  106. . . . i $$os^%zewdHTMLParser()="windows" s dlim=$c(13,10)
  107. . . . e s dlim=$c(10)
  108. . . . s np=$l(jsText2,dlim)
  109. . . . s p1=$p(jsText2,dlim,1)
  110. . . . s jsText2=$p(jsText2,dlim,2,np)
  111. . . . s jsText1=jsText1_p1_dlim
  112. . . . s jsTextOID=$$modifyTextData^%zewdDOM(jsText1,jsTextOID)
  113. . . . s textOID=$$createTextNode^%zewdDOM(jsText2,docOID)
  114. . . . i $$getNextChild^%zewdAPI(nodeOID,jsTextOID)="" d
  115. . . . . s textOID=$$appendChild^%zewdDOM(textOID,nodeOID)
  116. . . . e d
  117. . . . . n nextChildOID
  118. . . . . s nextChildOID=$$getNextChild^%zewdAPI(nodeOID,jsTextOID)
  119. . . . . i $$insertBefore^%zewdDOM(textOID,nextChildOID)
  120. . . . s jsText=jsText1
  121. . . ;
  122. . . f q:jsText'["ewd:" d
  123. . . . k %p1,%p2,%p2a,%p2b,%p3
  124. . . . s %p1=$p(jsText,"ewd:",1)
  125. . . . s %p2=$p(jsText,"ewd:",2,2000)
  126. . . . s %p2a=$p(%p2,"(",1)
  127. . . . i %p2'["class(" d ; extrinsic
  128. . . . . s method=%p2a
  129. . . . . s %p2b=$p(%p2,"(",2,2000)
  130. . . . . s paramList=$p(%p2b,")",1)
  131. . . . . s %p2=$p(%p2b,")",2,2000)
  132. . . . e d ; class method
  133. . . . . s method=$p(%p2,"(",1,2)
  134. . . . . i $e(method,1,2)'="##" s method="##"_method
  135. . . . . s %p2a=$p(%p2,"(",3,2000)
  136. . . . . s paramList=$p(%p2a,")",1)
  137. . . . . s %p2=$p(%p2a,")",2,2000)
  138. . . . s dlim=") ;" i paramList'[") ;",paramList[");" s dlim=");"
  139. . . . s eventNo=eventNo+1
  140. . . . s eventName="eventU"_$$zcvt^%zewdAPI($p(filename,".",1),"L")_"U"_eventNo
  141. . . . d
  142. . . . . n ebCall,nline,nparams,paramString,pval
  143. . . . . s nline=$o(phpHeaderArray(2,""),-1)+1
  144. . . . . s phpHeaderArray(2,nline)=" s ebToken("""_method_""")=$$createEBToken^%zewdGTMRuntime("""_method_""",.sessionArray)"
  145. . . . . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"scriptCalls",$$zcvt^%zewdAPI(pageName,"l"),method)="eventBroker"
  146. . . . . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"scriptCalledBy",method,$$zcvt^%zewdAPI(pageName,"l"))="eventBroker"
  147. . . . . ;
  148. . . . . s nparams=$length(paramList,",")
  149. . . . . s paramString=""
  150. . . . . i paramList'="" d
  151. . . . . . i nparams>0 for i=1:1:nparams do
  152. . . . . . . s pval=$p(paramList,",",i)
  153. . . . . . . i $e(pval,1)="""" d
  154. . . . . . . . set paramString=paramString_"&px"_i_"="_$$zcvt^%zewdAPI($p(paramList,",",i),"O","URL")
  155. . . . . . . e d
  156. . . . . . . . s paramString=paramString_"&px"_i_"=' + "_pval_" + '"
  157. . . . . s ebCall="EWD.ajax.makeRequest('#($$getRootURL^%zewdCompiler(""gtm""))#ewdeb/eb.mgwsi?ewd_token=#($$getSessionValue^%zewdAPI(""ewd_token"",sessid))#&eb=#(ebToken("""_method_"""))#"_paramString_"','','synch','','')"
  158. . . . . s jsText=%p1_ebCall_%p2
  159. . . . . s jsTextOID=$$modifyTextData^%zewdDOM(jsText,jsTextOID)
  160. . . ;
  161. . . ; Now expand any ewd.ajaxRequest functions
  162. . . ;
  163. . . k %changed,%id,%np,%nvp,%p1,%p2,%p3,%p4,%trace,%url
  164. . . ;
  165. . . s %changed=0
  166. . . s jsText=$$getData^%zewdDOM(jsTextOID)
  167. . . f q:jsText'["ewd.ajaxRequest(" d
  168. . . . s %p1=$p(jsText,"ewd.ajaxRequest(",1)
  169. . . . s %p2=$p(jsText,"ewd.ajaxRequest(",2,2000)
  170. . . . s %p3=$p(%p2,")",1),%p4=$p(%p2,")",2,2000)
  171. . . . s %np=$p(%p3,",",1)
  172. . . . s %id=$p(%p3,",",2) i %id="" s %id=""""""
  173. . . . s %nvp=$p(%p3,",",3)
  174. . . . s %trace=$p(%p3,",",4)
  175. . . . s %trace=$$removeQuotes^%zewdAPI(%trace)
  176. . . . s %trace=$$zcvt^%zewdAPI(%trace,"l")
  177. . . . i %trace'="",%trace'="alert",%trace'="window" s %trace=""
  178. . . . i %trace="window" d createTraceDiv^%zewdCompiler16(docName)
  179. . . . s %np=$$removeQuotes^%zewdAPI(%np)
  180. . . . s %url=$$expandPageName^%zewdCompiler8(%np,.nextPageList,.urlNameList,technology,.jsParams)
  181. . . . i %nvp="" d
  182. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'get','','"_%trace_"')"
  183. . . . e i $e(%nvp,1)="""" d
  184. . . . . s %url=%url_"&"_$$removeQuotes^%zewdAPI(%nvp)
  185. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'get','','"_%trace_"')"
  186. . . . e d
  187. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"&' + "_%nvp_","_%id_",'get','','"_%trace_"')"
  188. . . . s jsText=%p1_%p5_%p4
  189. . . . s %changed=1
  190. . . f q:jsText'["ewd.ajaxSynchRequest(" d
  191. . . . s %p1=$p(jsText,"ewd.ajaxSynchRequest(",1)
  192. . . . s %p2=$p(jsText,"ewd.ajaxSynchRequest(",2,2000)
  193. . . . s %p3=$p(%p2,")",1),%p4=$p(%p2,")",2,2000)
  194. . . . s %np=$p(%p3,",",1)
  195. . . . s %id=$p(%p3,",",2) i %id="" s %id=""""""
  196. . . . s %nvp=$p(%p3,",",3)
  197. . . . s %trace=$p(%p3,",",4)
  198. . . . s %trace=$$removeQuotes^%zewdAPI(%trace)
  199. . . . s %trace=$$zcvt^%zewdAPI(%trace,"l")
  200. . . . i %trace'="",%trace'="alert",%trace'="window" s %trace=""
  201. . . . i %trace="window" d createTraceDiv^%zewdCompiler16(docName)
  202. . . . s %np=$$removeQuotes^%zewdAPI(%np)
  203. . . . ;s %id=$$removeQuotes^%zewdAPI(%id)
  204. . . . s %url=$$expandPageName^%zewdCompiler8(%np,.nextPageList,.urlNameList,technology,.jsParams)
  205. . . . i %nvp="" d
  206. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'synch','','"_%trace_"')"
  207. . . . e i $e(%nvp,1)="""" d
  208. . . . . s %url=%url_"&"_$$removeQuotes^%zewdAPI(%nvp)
  209. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'synch','','"_%trace_"')"
  210. . . . e d
  211. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"&' + "_%nvp_","_%id_",'synch','','"_%trace_"')"
  212. . . . s jsText=%p1_%p5_%p4
  213. . . . s %changed=1
  214. . . i %changed set jsTextOID=$$modifyTextData^%zewdDOM(jsText,jsTextOID)
  215. s olOID=$$getTagByNameAndAttr^%zewdCompiler3("span","id","ewdajaxonload",0,docName)
  216. i olOID'="" d
  217. . n %changed,%id,lineNo,%np,%nvp,%p1,%p2,%p3,%p4,%p5,textArray,%trace,%url
  218. . s jsText=$$getElementValueByOID^%zewdDOM(olOID,"jsTextArray",1)
  219. . i jsText'="***Array***" s jsTextArray(1)=jsText
  220. . s lineNo=""
  221. . f s lineNo=$o(jsTextArray(lineNo)) q:lineNo="" d
  222. . . s jsText=jsTextArray(lineNo)
  223. . . i jsText'["ewd.ajaxRequest",jsText'["ewd.ajaxSynchRequest" q
  224. . . d removeChildTextNodes^%zewdDOM(olOID)
  225. . . f q:jsText'["ewd.ajaxRequest" d
  226. . . . s %p1=$p(jsText,"ewd.ajaxRequest(",1)
  227. . . . s %p2=$p(jsText,"ewd.ajaxRequest(",2,2000)
  228. . . . s %p3=$p(%p2,")",1),%p4=$p(%p2,")",2,2000)
  229. . . . s %np=$p(%p3,",",1)
  230. . . . s %id=$p(%p3,",",2) i %id="" s %id=""""""
  231. . . . s %nvp=$p(%p3,",",3)
  232. . . . s %trace=$p(%p3,",",4)
  233. . . . s %trace=$$zcvt^%zewdAPI(%trace,"l")
  234. . . . s %trace=$$removeQuotes^%zewdAPI(%trace)
  235. . . . i %trace'="",%trace'="alert",%trace'="window" s %trace=""
  236. . . . s %np=$$removeQuotes^%zewdAPI(%np)
  237. . . . s %url=$$expandPageName^%zewdCompiler8(%np,.nextPageList,.urlNameList,technology,.jsParams)
  238. . . . i %nvp="" d
  239. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'get','','"_%trace_"')"
  240. . . . e i $e(%nvp,1)="""" d
  241. . . . . s %url=%url_"&"_$$removeQuotes^%zewdAPI(%nvp)
  242. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'get','','"_%trace_"')"
  243. . . . e d
  244. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"&' + "_%nvp_","_%id_",'get','','"_%trace_"')"
  245. . . . s jsText=%p1_%p5_%p4
  246. . . . s %changed=1
  247. . . f q:jsText'["ewd.ajaxSynchRequest" d
  248. . . . s %p1=$p(jsText,"ewd.ajaxSynchRequest(",1)
  249. . . . s %p2=$p(jsText,"ewd.ajaxSynchRequest(",2,2000)
  250. . . . s %p3=$p(%p2,")",1),%p4=$p(%p2,")",2,2000)
  251. . . . s %np=$p(%p3,",",1)
  252. . . . s %id=$p(%p3,",",2) i %id="" s %id=""""""
  253. . . . s %nvp=$p(%p3,",",3)
  254. . . . s %trace=$p(%p3,",",4)
  255. . . . s %trace=$$zcvt^%zewdAPI(%trace,"l")
  256. . . . s %trace=$$removeQuotes^%zewdAPI(%trace)
  257. . . . i %trace'="",%trace'="alert",%trace'="window" s %trace=""
  258. . . . s %np=$$removeQuotes^%zewdAPI(%np)
  259. . . . s %url=$$expandPageName^%zewdCompiler8(%np,.nextPageList,.urlNameList,technology,.jsParams)
  260. . . . i %nvp="" d
  261. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'synch','','"_%trace_"')"
  262. . . . e i $e(%nvp,1)="""" d
  263. . . . . s %url=%url_"&"_$$removeQuotes^%zewdAPI(%nvp)
  264. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"',"_%id_",'synch','','"_%trace_"')"
  265. . . . e d
  266. . . . . s %p5="EWD.ajax.makeRequest('"_%url_"&' + "_%nvp_","_%id_",'synch','','"_%trace_"')"
  267. . . . s jsText=%p1_%p5_%p4
  268. . . . s %changed=1
  269. . . i %changed s jsTextOID=$$addTextToElement^%zewdDOM(olOID,jsText)
  270. ;
  271. q:eventNo=initialEventNo
  272. QUIT
  273. ;
  274. ; now add the <applet> call to the page
  275. ;
  276. new attr,appletOID,divOID
  277. ;<div style="visibility:hidden">
  278. set nodeOID=$$getTagOID^%zewdCompiler("body",docName)
  279. ;
  280. set attr("style")="visibility:hidden"
  281. set divOID=$$addElementToDOM^%zewdDOM("div",nodeOID,,.attr,"")
  282. ;
  283. set attr("name")="m_php"
  284. set attr("codebase")="/"
  285. set attr("code")="m_php.class"
  286. set attr("width")=2
  287. set attr("height")=2
  288. set appletOID=$$addElementToDOM^%zewdDOM("applet",divOID,,.attr,"")
  289. ;
  290. QUIT
  291. ;
  292. getJSText(label,technology)
  293. ;
  294. n i,jsText,line,text,x
  295. ;
  296. s jsText=""
  297. s x="s line=$T("_label_"+i^%zewdCompiler2)"
  298. f i=1:1 x x q:line["***END***" d
  299. . s text=$p(line,";;",2,255)
  300. . i $e(text,1)="*",$e(text,2,4)'=technology q
  301. . s text=$$replaceAll^%zewdHTMLParser(text,("*"_technology_"*")," ")
  302. . s jsText=jsText_$c(13,10)_text
  303. QUIT jsText
  304. ;
  305. parseEventBrokerCall(ebCall)
  306. ;
  307. n char,method,p1,p2,p3,p4,paramList,paramName,params,pos,quit,quoteSingle
  308. n quoteDouble,x1,x2,x3,xtra
  309. ;
  310. s p1=$p(ebCall,"ewd:",1)
  311. s p2=$p(ebCall,"ewd:",2,300)
  312. f q:p2'["&php;" d
  313. . s x1=$p(p2,"&php;",1)
  314. . s x2=$p(p2,"&php;",2)
  315. . s x3=$p(p2,"&php;",3,500)
  316. . s x2=$g(phpVars(x2))
  317. . s p2=x1_"<?="_x2_" ?>"_x3
  318. s p3=$p(p2,";",1)
  319. s p4=$p(p2,";",2,255)
  320. s method=$$stripSpaces^%zewdAPI(p3)
  321. s xtra=$$stripSpaces^%zewdAPI(p4)
  322. i method["class(" d
  323. . s paramList=$p(method,"(",3,999)
  324. . s method=$p(method,"(",1,2)
  325. . i $e(method,1,2)'="##" s method="##"_method
  326. e d
  327. . s paramList=$p(method,"(",2,999)
  328. . s method=$p(method,"(",1)
  329. s (params,quoteSingle,quoteDouble,quit)=0,paramName=""
  330. f pos=1:1 s char=$e(paramList,pos) q:char="" d q:quit
  331. . i char="'" d
  332. . . if quoteSingle,'quoteDouble s quoteSingle=0 w:'$f("|,|)|","|"_$e(paramList,pos+1)) !!,"Error parsing EWD page: ",filename,!?3,"Event broker call: ",ebCall
  333. . . e s quoteSingle=1
  334. . e i char="""" d
  335. . . i quoteDouble,'quoteSingle s quoteDouble=0 s quoteSingle=0 w:'$f("|,|)|","|"_$e(paramList,pos+1)) !!,"Error parsing page: ",filename,!?3,"Event broker call: ",ebCall
  336. . . e s quoteDouble=1
  337. . e i char=",",'quoteSingle,'quoteDouble s char="",quit=1
  338. . e i char=")",'quoteSingle,'quoteDouble s char="",quit=2
  339. . i quit s:paramName'="" params($increment(params))=paramName_char,paramName="",(quoteSingle,quoteDouble)=0,quit=quit-1 q
  340. . s paramName=paramName_char
  341. s paramList=""
  342. f pos=1:1:params s paramList=paramList_$s(pos>1:",",1:"")_params(pos)
  343. s eventNo=eventNo+1
  344. s eventName="eventU"_$$zcvt^%zewdAPI($p(filename,".",1),"L")_"U"_eventNo
  345. d
  346. . n nline,nparams,paramString,pval
  347. . s nline=$o(phpHeaderArray(2,""),-1)+1
  348. . s phpHeaderArray(2,nline)=" s ebToken("""_method_""")=$$createEBToken^%zewdWLD("""_method_""",.sessionArray)"
  349. . ;
  350. . s nparams=$l(paramList,",")
  351. . s paramString=""
  352. . i paramList'="" d
  353. .. i nparams>0 f i=1:1:nparams d
  354. ... s pval=$p(paramList,",",i)
  355. ... i $e(pval,1)="""" d
  356. .... s paramString=paramString_"&px"_i_"="_$$zcvt^%zewdAPI($p(paramList,",",i),"O","URL")
  357. ... e d
  358. .... s paramString=paramString_"&px"_i_"=' + "_pval_" + '"
  359. . s ebCall="EWD.ajax.makeRequest('#($$getRootURL^%zewdCompiler(""gtm""))#ewdeb/eb.mgwsi?ewd_token=#($$getSessionValue^%zewdAPI(""ewd_token"",sessid))#&eb=#(ebToken("""_method_"""))#"_paramString_"','','get','','')"
  360. . d setAttribute^%zewdDOM(attrName,ebCall,nodeOID)
  361. QUIT
  362. ;
  363. spanTags(docName,technology,multilingual,inputPath,textidList) ;
  364. ;
  365. n appendOnclick,appName,attr,bodyOID,childOID,confirm,confirmText
  366. n divOID,dlim,docOID,event,formOID,headOID,hiddenForms
  367. n inputOID,jsArray,jsCount,jsNodeOID,jsOID,language,n,name
  368. n nextpage,nodeOID,ntags,nvp,nvpCount,nvpStr,OIDArray,onclick
  369. n pageName,popup,pos,spanCounter,%stop,styleOID,submitOID,text
  370. n textOID,v,value
  371. ;
  372. s spanCounter=0
  373. s appName=inputPath
  374. s dlim=$$getDelim^%zewdCompiler()
  375. s appName=$p(appName,$$getApplicationRootPath^%zewdCompiler(),2)
  376. s appName=$p(appName,dlim,2)
  377. ;
  378. s docOID=$$getDocumentNode^%zewdDOM(docName)
  379. s ntags=$$getTagsByName^%zewdCompiler("span",docName,.OIDArray)
  380. s nodeOID=""
  381. f s nodeOID=$o(OIDArray(nodeOID)) q:nodeOID="" d
  382. . k nvp
  383. . s popup=$$getAttributeValue^%zewdDOM("popup",1,nodeOID)
  384. . q:popup'=""
  385. . s nextpage=$$getAttributeValue^%zewdDOM("nextpage",1,nodeOID)
  386. . q:nextpage=""
  387. . i $e(nextpage,1)="$" d q
  388. . . s event=$$getAttributeValue^%zewdDOM("event",1,nodeOID)
  389. . . s:event="" event="onclick"
  390. . . s onclick=$$getAttributeValue^%zewdDOM(event,1,nodeOID)
  391. . . i onclick'="" s onclick=onclick_" ; "
  392. . . d
  393. . . . n parentOID,scriptOID
  394. . . . s scriptOID=$$createElement^%zewdDOM("script",docOID)
  395. . . . d setAttribute^%zewdDOM("language","cache",scriptOID)
  396. . . . d setAttribute^%zewdDOM("runat","server",scriptOID)
  397. . . . s scriptOID=$$insertBefore^%zewdDOM(scriptOID,nodeOID)
  398. . . . s text=" s url=..Link("_$extract(nextpage,2,$length(nextpage))_"_"".csp"")"_$char(13,10)
  399. . . . s text=text_" s click=""document.location='""_url_""'"""
  400. . . . s textOID=$$createTextNode^%zewdDOM(text,docOID)
  401. . . . s textOID=$$appendChild^%zewdDOM(textOID,scriptOID)
  402. . . . s onclick=onclick_"#(click)#"
  403. . . d setAttribute^%zewdDOM("onclick",onclick,nodeOID)
  404. . . d removeAttribute^%zewdAPI("nextpage",nodeOID)
  405. . ;
  406. . s name="span"_$increment(spanCounter)
  407. . s pageName=$p(nextpage,"?",1)
  408. . s pageName=$p(pageName,".ewd",1)
  409. . s nvp=$p(nextpage,"?",2,255)
  410. . i nvp'="" d
  411. . . s nvp=$$replaceAll^%zewdHTMLParser(nvp,"&php;",$c(1))
  412. . . s nvpCount=$l(nvp,"&")
  413. . . f pos=1:1:nvpCount d
  414. . . . s nvpStr=$p(nvp,"&",pos)
  415. . . . s n=$p(nvpStr,"=",1)
  416. . . . s v=$p(nvpStr,"=",2)
  417. . . . s v=$$replaceAll^%zewdHTMLParser(v,$c(1),"&php;")
  418. . . . s v=$$replaceVars^%zewdHTMLParser(v,.cspVars,.phpVars,technology)
  419. . . . s nvp(n)=v
  420. . ;
  421. . i '$d(hiddenForms("form",name)) d
  422. . . k attr ; Attribute Array!
  423. . . s attr("type")="text/css"
  424. . . s text="#hiddenForm {visibility: hidden ;}"
  425. . . s headOID=$$getTagOID^%zewdCompiler("head",docName)
  426. . . s styleOID=$$addElementToDOM^%zewdDOM("style",headOID,,.attr,text)
  427. . . k jsArray
  428. . . s jsCount=$$getTagsByName^%zewdCompiler("script",docName,.jsArray)
  429. . . s jsNodeOID="",%stop=0
  430. . . f s jsNodeOID=$o(jsArray(jsNodeOID)) q:jsNodeOID="" d q:%stop
  431. . . . s language=$$getAttributeValue^%zewdDOM("language",1,jsNodeOID)
  432. . . . q:$$zcvt^%zewdAPI(language,"L")'["javascript"
  433. . . . q:$$getFirstChild^%zewdDOM(jsNodeOID)=""
  434. . . . s %stop=1
  435. . . ;
  436. . . s jsOID=jsNodeOID
  437. . . i jsOID="" d
  438. . . . k attr
  439. . . . s attr("language")="javascript"
  440. . . . s jsOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,"")
  441. . . s childOID=$$getFirstChild^%zewdDOM(jsOID)
  442. . . s text=$$getData^%zewdDOM(childOID)
  443. . . ;
  444. . . s text=text_$c(13,10)_"function ewdNP"_name_"("
  445. . . i $o(nvp(""))="" s text=text_" "
  446. . . s n=""
  447. . . f s n=$o(nvp(n)) q:n="" s text=text_n_","
  448. . . s text=$e(text,1,$l(text)-1)_$s($o(nvp(""))="":"",1:",")_"confirmText) {"_$c(13,10)
  449. . . s n=""
  450. . . f s n=$o(nvp(n)) q:n="" s text=text_" document.ewdNP"_name_"Form."_n_".value = "_n_" ;"_$c(13,10)
  451. . . s text=text_" document.ewdNP"_name_"Form.ewd_action.value='"_name_"submit' ;"_$c(13,10)
  452. . . s text=text_" document.ewdNP"_name_"Form.ewd_pressed.value='"_name_"submit' ;"_$c(13,10)
  453. . . s text=text_" if ((confirmText != null) && (confirmText != ''))"_$c(13,10)
  454. . . s text=text_" {"_$c(13,10)
  455. . . s text=text_" confirmText = EWD.utils.replace(confirmText,""&#39;"",""'"") ;"_$c(13,10)
  456. . . s text=text_" confirmText = EWD.utils.replace(confirmText,'&#34;','""') ;"_$c(13,10)
  457. . . s text=text_" ok=confirm(confirmText) ;"_$c(13,10)
  458. . . s text=text_" if (ok) document.ewdNP"_name_"Form.submit() ;"_$c(13,10)
  459. . . s text=text_" }"_$c(13,10)
  460. . . s text=text_" else"_$c(13,10)
  461. . . s text=text_" document.ewdNP"_name_"Form.submit() ;"_$c(13,10)
  462. . . s text=text_"}"
  463. . . s textOID=$$modifyTextData^%zewdDOM(text,childOID)
  464. . s confirm=$$getAttributeValue^%zewdDOM("confirm",1,nodeOID)
  465. . s confirmText=$$getAttributeValue^%zewdDOM("confirmtext",1,nodeOID)
  466. . i confirmText'="",multilingual d
  467. . . n attrOID,containsVars,event,outputText,text,textid
  468. . . s event=$$getAttributeValue^%zewdDOM("event",1,nodeOID)
  469. . . s attrOID=$$getAttributeNode^%zewdDOM(event,nodeOID)
  470. . . i attrOID="" d setAttribute^%zewdDOM(event,"",nodeOID) s attrOID=$$getAttributeNode^%zewdDOM(event,nodeOID)
  471. . . s textid=$$encodeValue^%zewdCompiler5(confirmText,attrOID,appName,pageName,.text,.textidList,technology,.containsVars,.outputText)
  472. . . i textid="" q
  473. . . i 'containsVars d q
  474. . . . s confirmText="#($$displayText^%zewdAPI("""_textid_""",0,"""_technology_"""))#"
  475. . . . i multilingual=1 s confirmText="#($$displayText^%zewdAPI("""_textid_""",1,"""_technology_"""))#"
  476. . . ;
  477. . . ; contains variables
  478. . . ;
  479. . . s confirmText=text
  480. . e d
  481. . . s:confirmText["'" confirmText=$$replaceAll^%zewdHTMLParser(confirmText,"'","\&#39;")
  482. . . s:confirmText["""" confirmText=$$replaceAll^%zewdHTMLParser(confirmText,"""","\&#34;")
  483. . ;
  484. . s event=$$getAttributeValue^%zewdDOM("event",1,nodeOID)
  485. . s:event="" event="onClick"
  486. . s onclick=$$getAttributeValue^%zewdDOM(event,1,nodeOID)
  487. . i onclick'="" s onclick=onclick_" ; "
  488. . s onclick=onclick_"ewdNP"_name_"("
  489. . i $o(nvp(""))="" s onclick=onclick_" "
  490. . s n=""
  491. . f s n=$o(nvp(n)) q:n="" d
  492. . . s v=nvp(n)
  493. . . i v["document." d q
  494. . . . s onclick=onclick_v_","
  495. . . i $$zcvt^%zewdAPI($e(v,1,11),"l")="javascript." d q
  496. . . . s v=$e(v,12,$l(v))
  497. . . . s onclick=onclick_v_","
  498. . . if $e(v,1)="$"!($e(v,1)="#") d
  499. . . . i $e(v,1)="$" d
  500. . . . . s v=$e(v,2,$l(v))
  501. . . . e d
  502. . . . . i $e(v,1)="#" s v="$$getSessionValue^%zewdAPI("""_$e(v,2,$l(v))_""",sessid)"
  503. . . . s onclick=onclick_"'#("_v_")#',"
  504. . . e d
  505. . . . s onclick=onclick_"'"_v_"',"
  506. . s onclick=$e(onclick,1,$l(onclick)-1)
  507. . s onclick=onclick_$s($o(nvp(""))="":"",1:",")_"'"_confirmText_"')"
  508. . s appendOnclick=$$getAttributeValue^%zewdDOM("appendonclick",1,nodeOID)
  509. . i appendOnclick'="" d
  510. . . s onclick=onclick_" ; "_appendOnclick
  511. . . d removeAttribute^%zewdAPI("appendonclick",nodeOID)
  512. . d setAttribute^%zewdDOM(event,onclick,nodeOID)
  513. . d removeAttribute^%zewdAPI("nextpage",nodeOID)
  514. . d removeAttribute^%zewdAPI("event",nodeOID)
  515. . ;
  516. . i '$d(hiddenForms("form",name)) d
  517. . . k attr ; Attribute Array!
  518. . . s bodyOID=$$getTagOID^%zewdCompiler("body",docName)
  519. . . s attr("id")="hiddenForm"
  520. . . s divOID=$$addElementToDOM^%zewdDOM("div",bodyOID,,.attr,"")
  521. . . s attr("method")="post"
  522. . . s attr("action")="ewd"
  523. . . s attr("name")="ewdNP"_name_"Form"
  524. . . s formOID=$$addElementToDOM^%zewdDOM("form",divOID,,.attr,"")
  525. . . s n=""
  526. . . f s n=$o(nvp(n)) quit:n="" d
  527. . . . s attr("type")="hidden"
  528. . . . s attr("name")=n
  529. . . . s attr("value")=""
  530. . . . s inputOID=$$addElementToDOM^%zewdDOM("input",formOID,,.attr,"")
  531. . . k attr
  532. . . s attr("type")="submit"
  533. . . s attr("name")=name_"submit"
  534. . . s attr("value")="submit"
  535. . . s attr("nextpage")=pageName
  536. . . s submitOID=$$addElementToDOM^%zewdDOM("input",formOID,,.attr,"")
  537. . . s hiddenForms("form",name)=formOID
  538. . . s hiddenForms("form",name,"submitOID")=submitOID
  539. . ;
  540. . f attr="confirm","confirmtext","action" d
  541. . . s value=$$getAttributeValue^%zewdDOM(attr,1,nodeOID)
  542. . . i value'="" d
  543. . . . i attr="action" do setAttribute^%zewdDOM(attr,value,hiddenForms("form",name,"submitOID"))
  544. . . . d removeAttribute^%zewdAPI(attr,nodeOID)
  545. QUIT
  546. ;
  547. XSLFO(docName) ;
  548. ;
  549. n appName,attr,dlim,headOID,nodeOID,npieces,os,prePageScript,scriptOID,text
  550. ;
  551. s nodeOID=$$getTagOID^%zewdCompiler("ewd:config",docName)
  552. s prePageScript=$$getAttributeValue^%zewdDOM("prepagescript",1,nodeOID)
  553. set headOID=$$getTagOID^%zewdCompiler("body",docName)
  554. if headOID="" set headOID=$$getDocumentNode^%zewdDOM(docName)
  555. set attr("language")="cache"
  556. set attr("method")="OnPreHTTP"
  557. set attr("arguments")=""
  558. set attr("returntype")="%Library.Boolean"
  559. set text=" i $$"_prePageScript_"(0)"_$char(13,10)
  560. s text=text_" s xslfoFilename=""xslfo.txt"""_$c(13,10)
  561. s text=text_" o xslfoFilename:""NW"""_$c(13,10)
  562. s text=text_" u xslfoFilename"_$c(13,10)
  563. s text=text_" s quitStatus=1"_$c(13,10)
  564. set scriptOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,text)
  565. ;
  566. set attr("language")="cache"
  567. set attr("method")="OnPostHTTP"
  568. set attr("arguments")=""
  569. set attr("returntype")="%Library.Boolean"
  570. s text=" c xslfoFilename"_$c(13,10)
  571. s text=text_" QUIT 1"_$c(13,10)
  572. set scriptOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,text)
  573. ;
  574. s nodeOID=$$removeChild^%zewdAPI(nodeOID)
  575. set appName=inputPath
  576. set os=$$os^%zewdHTMLParser()
  577. if os="windows" set dlim="\"
  578. else set dlim="/"
  579. if $extract(appName,$length(appName))=dlim set appName=$extract(appName,1,$length(appName)-1)
  580. set npieces=$length(appName,dlim)
  581. set appName=$piece(appName,dlim,npieces)
  582. set pageName=$piece(filename,".ewd",1)
  583. QUIT pageName
  584. ;
  585. pageIndex(app,filename,nextPageList) ;
  586. ;
  587. n nextPage,np
  588. ;
  589. i technology="wl"!(technology="gtm")!(technology="ewd")!(technology="node") s app=appx
  590. i $g(rawApp)'="" s app=rawApp
  591. i $e(filename,1,3)'="ewd",isAjax s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"pages",$p(filename,".ewd",1))=$g(config("isFirstPage"))
  592. s nextPage=""
  593. f s nextPage=$o(nextPageList(nextPage)) q:nextPage="" d
  594. . s np=$p(nextPage,"?",1)
  595. . q:np="*"
  596. . q:$e(np,1)="#"
  597. . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"pageCalls",$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"),$$zcvt^%zewdAPI(np,"l"))=""
  598. . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"pageCalledBy",$$zcvt^%zewdAPI(np,"l"),$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"))=""
  599. QUIT
  600. ;
  601. getIndices(sessid)
  602. ;
  603. n app,dlim,os,pageCalledBy,pageCalls,path,scriptCalledBy,scriptCalls,tagCalls,tagCalledBy,xref
  604. ;
  605. s xref=$$getSessionValue^%zewdAPI("xref",sessid)
  606. i xref="" d
  607. . s xref="pageCalls"
  608. . d setSessionValue^%zewdAPI("xref",xref,sessid)
  609. ;
  610. s path=$$getSessionValue^%zewdAPI("path",sessid)
  611. s os=$$os^%zewdHTMLParser()
  612. s dlim="/" i os="windows" s dlim="\"
  613. i dlim="\" s path=$tr(path,"/",dlim)
  614. s app=$p($re(path),dlim,1)
  615. i app="" s app=$p($re(path),dlim,2)
  616. s app=$re(app)
  617. d setSessionValue^%zewdAPI("app",app,sessid)
  618. s app=$$zcvt^%zewdAPI(app,"l")
  619. ;
  620. i $$getSessionValue^%zewdAPI("clearXRef",sessid)'=0 d
  621. . d clearSessionArray^%zewdAPI("pageCalls",sessid)
  622. . d clearSessionArray^%zewdAPI("pageCalledBy",sessid)
  623. . d clearSessionArray^%zewdAPI("scriptCalls",sessid)
  624. . d clearSessionArray^%zewdAPI("scriptCalledBy",sessid)
  625. . d clearSessionArray^%zewdAPI("tagCalls",sessid)
  626. . d clearSessionArray^%zewdAPI("tagCalledBy",sessid)
  627. ;
  628. i xref="pageCalls" d QUIT ""
  629. . m pageCalls=^%zewdIndex(app,"pageCalls")
  630. . d mergeArrayToSession^%zewdAPI(.pageCalls,"pageCalls",sessid)
  631. ;
  632. i xref="pageCalledBy" d QUIT ""
  633. . m pageCalledBy=^%zewdIndex(app,"pageCalledBy")
  634. . d mergeArrayToSession^%zewdAPI(.pageCalledBy,"pageCalledBy",sessid)
  635. ;
  636. i xref="scriptCalls" d QUIT ""
  637. . m scriptCalls=^%zewdIndex(app,"scriptCalls")
  638. . d mergeArrayToSession^%zewdAPI(.scriptCalls,"scriptCalls",sessid)
  639. ;
  640. i xref="scriptCalledBy" d QUIT ""
  641. . m scriptCalledBy=^%zewdIndex(app,"scriptCalledBy")
  642. . d mergeArrayToSession^%zewdAPI(.scriptCalledBy,"scriptCalledBy",sessid)
  643. ;
  644. i xref="tagCalls" d QUIT ""
  645. . m tagCalls=^%zewdIndex(app,"tagCalls")
  646. . d mergeArrayToSession^%zewdAPI(.tagCalls,"tagCalls",sessid)
  647. ;
  648. i xref="tagCalledBy" d QUIT ""
  649. . m tagCalledBy=^%zewdIndex(app,"tagCalledBy")
  650. . d mergeArrayToSession^%zewdAPI(.tagCalledBy,"tagCalledBy",sessid)
  651. ;
  652. QUIT ""
  653. ;
  654. ;
  655. getProperty(nodeOID,attrValues,docOID,technology)
  656. ;
  657. ; <ewd:getProperty sessionName="menuOption" param1="optionNo" propertyName="text" return="$text">
  658. ; <ewd:getProperty localName="menuOption" param1="optionNo" propertyName="text" return="$text">
  659. ;
  660. n localName,param,propertyName,pval,return,sessionName,sname,subList,subListq,subs,subscripts
  661. ;
  662. s param="param",subs=""
  663. f s param=$o(attrValues(param)) q:param="" q:param'["param" d
  664. . s pval=attrValues(param)
  665. . d
  666. . . i $e(pval,1)="""" s pval=$e(pval,2,$l(pval)-1) q
  667. . . i $e(pval,1)'="$" s pval="$"_pval
  668. . s subs=subs_pval_","
  669. s subscripts=$e(subs,1,$l(subs)-1)
  670. ;
  671. s propertyName=$$getAttrValue^%zewdCompiler4("propertyName",.attrValues,technology)
  672. s sessionName=$$getAttrValue^%zewdCompiler4("sessionname",.attrValues,technology)
  673. s localName=$$getAttrValue^%zewdCompiler4("localname",.attrValues,technology)
  674. s localName=$$removeQuotes^%zewdAPI(localName)
  675. s return=$$getAttrValue^%zewdCompiler4("return",.attrValues,technology)
  676. s subList="",subListq=""
  677. i subscripts'="" d
  678. . n nsubs,i
  679. . s nsubs=$l(subscripts,",")
  680. . f i=1:1:nsubs d
  681. . . n sub
  682. . . s sub=$p(subscripts,",",i)
  683. . . i $e(sub,1)="$" d
  684. . . . s sub=$e(sub,2,$l(sub))
  685. . . . s subList=subList_","_sub
  686. . . . s subListq=subListq_","_sub
  687. . . e d
  688. . . . s subList=subList_","""_sub_""""
  689. . . . s subListq=subListq_",&quot;"_sub_"&quot;"
  690. ;
  691. i $e(sessionName,1)="""" s sname="&quot;"_$e(sessionName,2,$l(sessionName)-1)_"&quot;"
  692. e s sname=sessionName
  693. i sessionName'="""""" d
  694. . d
  695. . . n serverOID,text,useSessGlo
  696. . . s useSessGlo=+$g(^%zewd("config","csp","useSessionGlobal"))=1
  697. . . i technology="wl"!(technology="gtm")!(technology="ewd")!(technology="node") s useSessGlo=1
  698. . . i 'useSessGlo s text=" s "_return_"=%session.Data("_sname_subList_","_propertyName_")"
  699. . . i useSessGlo s text=" s "_return_"=^%zewdSession(""session"","_sname_subList_","_propertyName_")"
  700. . . s serverOID=$$addCSPServerScript^%zewdCompiler4(nodeOID,text)
  701. e d
  702. . d
  703. . . n %p,serverOID,text
  704. . . s %p=localName_""""_subList
  705. . . i subList="" s %p=localName_""""
  706. . . s text=" s "_return_"=%ewdVar(""$"_%p_","_propertyName_")"
  707. . . s serverOID=$$addCSPServerScript^%zewdCompiler4(nodeOID,text)
  708. ;
  709. d removeIntermediateNode^%zewdCompiler4(nodeOID)
  710. ;
  711. QUIT
  712. ;
  713. include(nodeOID,attrValues,docOID,technology)
  714. ;
  715. ; <ewd:include file="myFile.inc">
  716. ;
  717. n filename
  718. ;
  719. s filename=$$getAttrValue^%zewdCompiler4("file",.attrValues,technology)
  720. s filename=$$removeQuotes^%zewdAPI(filename)
  721. if filename'="" do
  722. . new %error,fcOID,incDocName,incDocOID,blockOID,newChildOID,ok,tagName,docOID,incOID
  723. . set incDocName="ewdInclude"
  724. . quit:$$zcvt^%zewdAPI(filename,"L")'[".inc"
  725. . set filename=inputPath_filename
  726. . set %error=$$parseFile^%zewdHTMLParser(filename,incDocName,,.phpVars,1)
  727. . if %error'="" QUIT
  728. . set incDocOID=$$getDocumentNode^%zewdDOM(incDocName)
  729. . set docOID=$$getDocumentNode^%zewdDOM(docName)
  730. . s fcOID=$$getFirstChild^%zewdDOM(incDocOID)
  731. . s tagName=$$getTagName^%zewdDOM(fcOID)
  732. . i tagName'="ewd:content" s fcOID=$$insertNewIntermediateElement^%zewdDOM(incDocOID,"ewd:content",incDocOID)
  733. . set incOID=$$getTagOID^%zewdCompiler("ewd:content",incDocName)
  734. . set blockOID=$$importNode^%zewdDOM(incOID,"true",docOID)
  735. . set newChildOID=$$appendChild^%zewdDOM(blockOID,nodeOID)
  736. . do removeIntermediateNode^%zewdCompiler4(newChildOID)
  737. . set ok=$$removeDocument^%zewdDOM(incDocName,0,0)
  738. ;
  739. do removeIntermediateNode^%zewdCompiler4(nodeOID)
  740. ;
  741. QUIT
  742. ;
  743. testFindCustomTags
  744. ;
  745. n docName,nodeOID
  746. s docName="ewd"
  747. s ok=$$openDOM^%eDOMAPI()
  748. d initialiseProcessedFlags
  749. f s nodeOID=$$findFirstCustomTag(docName) q:nodeOID="" d
  750. . w nodeOID," : ",$$getTagName^%eDOMAPI(nodeOID),!
  751. s ok=$$closeDOM^%eDOMAPI()
  752. QUIT
  753. ;
  754. initialiseProcessedFlags
  755. n j,n
  756. k ^CacheTempCTProcessed($j)
  757. ; clear down any old records
  758. s j=""
  759. f s j=$o(^CacheTempCTProcessed(j)) q:j="" d
  760. . s n=""
  761. . f s n=$o(^CacheTempCTProcessed(j,n)) q:n="" d
  762. . . i ^CacheTempCTProcessed(j,n)<$h k ^CacheTempCTProcessed(j,n)
  763. QUIT
  764. ;
  765. setProcessedFlagOn(nodeOID)
  766. s ^CacheTempCTProcessed($j,nodeOID)=+$h
  767. QUIT
  768. ;
  769. setProcessedFlagOff(nodeOID)
  770. k ^CacheTempCTProcessed($j,nodeOID)
  771. QUIT
  772. ;
  773. findFirstCustomTag(docName)
  774. ;
  775. n docOID,nIncludes,nodeOID,OIDArray,stop
  776. ;
  777. s docOID=$$getDocumentNode^%zewdDOM(docName)
  778. ;
  779. s nIncludes=$$getTagsByName^%zewdCompiler("ewd:include",docName,.OIDArray)
  780. s nodeOID="",stop=0
  781. f s nodeOID=$o(OIDArray(nodeOID)) q:nodeOID="" d q:stop
  782. . i '$d(^CacheTempCTProcessed($j,nodeOID)) s stop=1
  783. i stop d setProcessedFlagOn(nodeOID) QUIT nodeOID
  784. ;
  785. s nodeOID=$$getFirstCustomTag(docOID,0)
  786. i nodeOID'="" d setProcessedFlagOn(nodeOID)
  787. QUIT nodeOID
  788. ;
  789. getFirstCustomTag(parentOID,stop)
  790. ;
  791. ; recurses through all child node levels of parent node and
  792. ; returns them as a text string
  793. ;
  794. n childOID,grandChildOID,tagName
  795. ;
  796. s childOID=""
  797. for set childOID=$$getNextChild^%zewdAPI(parentOID,childOID) quit:childOID="" d quit:stop
  798. . s tagName=$$getTagName^%zewdDOM(childOID)
  799. . q:tagName=""
  800. . i $d(^%zewd("customTag",tagName)),'$d(^CacheTempCTProcessed($j,childOID)) s stop=1 quit
  801. . s grandChildOID=$$getFirstCustomTag(childOID,.stop) i stop s childOID=grandChildOID quit
  802. QUIT childOID
  803. ;
  804. processTag(tagName,attrList,procName,include,defFile,docName,technology,error)
  805. ;processTag(tagName,procName,docName,technology,error)
  806. ;
  807. n attr,attrName,attrValue,attrValues,docOID,func,i,isCustomTag,lcAttrName
  808. n nAttr,nodeOID,ntags,OIDArray,ok,%p,page,x,%zt
  809. ;
  810. s error=""
  811. s docOID=$$getDocumentNode^%zewdDOM(docName)
  812. s ntags=$$getTagsByName^%zewdCompiler(tagName,docName,.OIDArray)
  813. s nodeOID=""
  814. f s nodeOID=$o(OIDArray(nodeOID)) q:nodeOID="" d i error'="" QUIT
  815. . q:$$getParentNode^%zewdDOM(nodeOID)="" ; detached node
  816. . k attrValues
  817. . s nAttr=$l(attrList,",")
  818. . s ok=$$getAttributes^%zewdCompiler(nodeOID,.attr)
  819. . s attrName=""
  820. . f s attrName=$o(attr(attrName)) q:attrName="" d
  821. . . s attrValue=$$getNormalAttributeValue^%zewdAPI(attrName,nodeOID,technology)
  822. . . s attrValues($$zcvt^%zewdAPI(attrName,"l"))=attrValue
  823. . . s attrValues(attrName)=attrValue
  824. . ; the following is old mechanism compatibility code to prevent old custom tags breaking on null values
  825. . f i=1:1:nAttr d
  826. . . s attrName=$p(attrList,",",i)
  827. . . q:attrName=""
  828. . . s lcAttrName=$$zcvt^%zewdAPI(attrName,"l")
  829. . . s attrValue=$g(attrValues(lcAttrName))
  830. . . q:attrValue'=""
  831. . . s attrValue=""""""
  832. . . s attrValues($$zcvt^%zewdAPI(attrName,"l"))=attrValue
  833. . . s attrValues(attrName)=attrValue
  834. . i include'="" d
  835. . . n attr,incOID
  836. . . s attr("file")=include
  837. . . s incOID=$$addElementToDOM^%zewdDOM("ewd:include",nodeOID,,.attr,"")
  838. . . do removeIntermediateNode^%zewdCompiler4(nodeOID)
  839. . i defFile'="" d
  840. . . ; tag defined in definition file
  841. . . n blockOID,childOID,dlim,defDocName,dummyOID,eArray,eOID,%error
  842. . . n newChildOID,ntags,incOID,ipath,name,ok,opath,path,stop
  843. . . n cspVarsX,phpVarsX
  844. . . k cspVarsX,phpVarsX
  845. . . m cspVarsX=cspVars
  846. . . m phpVarsX=phpVars
  847. . . s path=$$getApplicationRootPath^%zewdAPI()
  848. . . s dlim=$$getDelim^%zewdCompiler()
  849. . . i $e(path,$l(path))'=dlim s path=path_dlim
  850. . . s ipath=path_defFile
  851. . . s defDocName="ewdDefFile"
  852. . . ;s ok=$$openDOM^%zewdAPI()
  853. . . s ok=$$removeDocument^%zewdDOM(defDocName,0,0)
  854. . . ;s ok=$$$closeDOM
  855. . . s %error=$$parseFile^%zewdHTMLParser(ipath,defDocName,.cspVarsX,.phpVarsX,1)
  856. . . s opath=path_"temp.txt"
  857. . . s ok=$$openNewFile^%zewdCompiler(opath) u opath
  858. . . ;o opath:"nw" u opath
  859. . . s tagNameX=tagName d outputDOM^%zewdHTMLParser(defDocName,"collapse",,.cspVarsX,.phpVarsX,1,technology)
  860. . . c opath
  861. . . ;s ok=$$openDOM^%zewdAPI()
  862. . . s ok=$$removeDocument^%zewdDOM(defDocName,0,0)
  863. . . s %error=$$parseFile^%zewdHTMLParser(opath,defDocName,.cspVars,.phpVars,1)
  864. . . s ok=$$deleteFile^%zewdHTMLParser(opath) ;break:tagName["vpitem"
  865. . . s dummyOID=$$insertNewIntermediateElement^%zewdDOM(nodeOID,"dummy",docOID)
  866. . . ;<ewd:tagdefinition name='qm:vpSection'>
  867. . . s ntags=$$getElementsArrayByTagName^%zewdDOM("ewd:tagdefinition",defDocName,,.eArray)
  868. . . s eOID="",stop=0
  869. . . f s eOID=$o(eArray(eOID)) q:eOID="" d q:stop
  870. . . . s name=$$getAttribute^%zewdDOM("name",eOID)
  871. . . . s name=$$zcvt^%zewdAPI(name,"l")
  872. . . . i name=tagName s stop=1
  873. . . i 'stop q ; definition not actually found!
  874. . . s incOID=$$getFirstElementByTagName^%zewdDOM("ewd:tagexpansion",,eOID)
  875. . . set blockOID=$$importNode^%zewdDOM(incOID,"true",docOID)
  876. . . set newChildOID=$$appendChild^%zewdDOM(blockOID,nodeOID)
  877. . . ;s childOID=$$getFirstElementByTagName^%eDOMAPI("ewd:children",docName) break
  878. . . k eArray
  879. . . s ntags=$$getElementsArrayByTagName^%zewdDOM("ewd:children",docName,,.eArray)
  880. . . s childOID="",stop=0
  881. . . f s childOID=$o(eArray(childOID)) q:childOID="" d q:stop
  882. . . . i $$getParentNode^%zewdDOM(childOID)'="" s stop=1
  883. . . s dummyOID=$$removeChild^%zewdAPI(dummyOID)
  884. . . i $$hasChildNodes^%zewdDOM(dummyOID)="true" d
  885. . . . s dummyOID=$$appendChild^%zewdDOM(dummyOID,childOID)
  886. . . . do removeIntermediateNode^%zewdCompiler4(dummyOID)
  887. . . . do removeIntermediateNode^%zewdCompiler4(childOID)
  888. . . e d
  889. . . . s ok=$$removeChild^%zewdAPI(childOID)
  890. . . do removeIntermediateNode^%zewdCompiler4(newChildOID)
  891. . . do removeIntermediateNode^%zewdCompiler4(nodeOID)
  892. . . set ok=$$removeDocument^%zewdDOM(defDocName,0,0)
  893. . . ;s ok=$$$closeDOM break
  894. . i include="",defFile="" d i error'="" q
  895. . . i $$zcvt^%zewdAPI(procName,"l")["##class" d
  896. . . e d
  897. . . . s x="d "_procName_"(nodeOID,.attrValues,docOID,technology)"
  898. . . . i $g(^zewd("trace"))=1,$e(tagName,1,4)'="ewd:",tagName'="textarea" d trace^%zewdAPI("Compiling custom tag "_tagName_": about to call "_x)
  899. . . . s %zt=$zt
  900. . . . ;s $zt="g processTagError"
  901. . . . x x
  902. . . . s $zt=%zt
  903. . s %p=$g(^%zewd("customTag",tagName))
  904. . s func=$p(%p,$c(1),1)
  905. . ;i func'="",func'["^%zewd" d
  906. . s isCustomTag=1
  907. . s isCustomTag=0
  908. . i tagName[":" s isCustomTag=1
  909. . ;i func'["^%zewd" d
  910. . i isCustomTag d
  911. . . n appName
  912. . . s appName=$$zcvt^%zewdAPI(subPath,"l")
  913. . . s appName=app
  914. . . ;s ^%zewdIndex(appName,"tagCalls",$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"),tagName)=""
  915. . . ;s ^%zewdIndex(appName,"tagCalledBy",tagName,$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"))=""
  916. . . s ^%zewdIndex($$zcvt^%zewdAPI(appName,"l"),"tagCalls",$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"),tagName)=""
  917. . . s ^%zewdIndex($$zcvt^%zewdAPI(appName,"l"),"tagCalledBy",tagName,$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"))=""
  918. . i tagName="ewd:include" s includeFound=1
  919. QUIT
  920. ;
  921. processTagError ;
  922. ;
  923. i $g(%zt)'="" s $zt=%zt
  924. ;d ^%STACK
  925. ;s error="Error in custom tag processing of the <"_tagName_"> tag : "_procName_" not found in the "_$$namespace^%zewdAPI()_" namespace"
  926. s error="Error in custom tag processing of the <"_$g(tagName)_"> tag : "_$ze
  927. QUIT
  928. ;
  929. processTagErrorET ;
  930. ;
  931. ;s $etrap=""
  932. s $ecode=""
  933. s error="Error in custom tag processing of the <"_$g(tagName)_"> tag : "_$zerror
  934. QUIT error
  935. ;
  936. ;
  937. substitute(string,phpVars,technology)
  938. ;
  939. n p1,value
  940. s string=$$removeQuotes^%zewdAPI(string)
  941. s p1=$p(string,"&php;",2)
  942. s value=$$stripSpaces^%zewdAPI(p1)
  943. i $e(value,1)="$" s value=$e(value,2,$l(value))
  944. QUIT value
  945. ;
  946. ;===============================================================
  947. ; Javascript functions
  948. ;===============================================================
  949. ;
  950. javascriptFunctionExists(functionName,docName)
  951. ;
  952. QUIT $$getJavascriptFunction(functionName,docName)'=""
  953. ;
  954. getJavascriptBlock(functionName,docName,textArr) ;
  955. ;
  956. n eArray,eOID,language,lineNo,ntags,OIDArray,refString,stop,text,textArray
  957. ;
  958. s text="",eOID="" k textArr
  959. s refString="function "_functionName
  960. s ntags=$$getElementsArrayByTagName^%zewdDOM("script",docName,,.eArray)
  961. s eOID="",stop=0
  962. f s eOID=$o(eArray(eOID)) q:eOID="" d q:stop
  963. . s language=$$getAttribute^%zewdDOM("language",eOID)
  964. . q:language=""
  965. . q:$$zcvt^%zewdAPI(language,"l")'="javascript"
  966. . s text=$$getElementValueByOID^%zewdDOM(eOID,"textArr",1)
  967. . i '$d(textArr) s textArr(1)=text
  968. . s lineNo="",text=""
  969. . f s lineNo=$o(textArr(lineNo)) q:lineNo="" d q:stop
  970. . . i textArr(lineNo)[refString s stop=1 q
  971. QUIT stop
  972. ;
  973. removeJavascriptFunction(functionName,docName)
  974. QUIT $$replaceJavascriptFunction(functionName,"",docName)
  975. ;
  976. replaceJavascriptFunction(functionName,newFunctionText,docName)
  977. ;
  978. n childOID,eOID,docOID,found,funcText,lineNo,stop,text,textArr,textOID
  979. ;
  980. s docOID=$$getDocumentNode^%zewdDOM(docName)
  981. s found=$$getJavascriptBlock(functionName,docName,.textArr)
  982. i 'found QUIT 0
  983. ;
  984. s funcText=$$getJavascriptFunction(functionName,docName,.eOID)
  985. s lineNo="",stop=0
  986. f s lineNo=$o(textArr(lineNo)) q:lineNo="" d q:stop
  987. . s text=textArr(lineNo)
  988. . i text[funcText s textArr(lineNo)=$$replace^%zewdAPI(text,funcText,newFunctionText),stop=1
  989. i 'stop QUIT 0
  990. f q:$$hasChildNodes^%zewdDOM(eOID)="false" d
  991. . s childOID=$$getFirstChild^%zewdDOM(eOID)
  992. . s childOID=$$removeChild^%zewdAPI(childOID)
  993. ;
  994. s lineNo=""
  995. f s lineNo=$o(textArr(lineNo)) q:lineNo="" d
  996. . s text=textArr(lineNo)
  997. . s textOID=$$createTextNode^%zewdDOM(text,docOID)
  998. . s textOID=$$appendChild^%zewdDOM(textOID,eOID)
  999. QUIT 1
  1000. ;
  1001. getFirstJavascriptFunction(docName,textArr)
  1002. ;
  1003. n docOID,eArray,jsText,language,ntags,OIDArray,scriptOID,src,stop,textArray
  1004. ;
  1005. s docOID=$$getDocumentNode^%zewdDOM(docName)
  1006. s ntags=$$getElementsArrayByTagName^%zewdDOM("script",docName,,.eArray)
  1007. s scriptOID="",stop=0
  1008. f s scriptOID=$o(eArray(scriptOID)) q:scriptOID="" d q:stop
  1009. . s language=$$getAttribute^%zewdDOM("language",scriptOID)
  1010. . q:language=""
  1011. . q:$$zcvt^%zewdAPI(language,"l")'="javascript"
  1012. . s src=$$getAttribute^%zewdDOM("src",scriptOID)
  1013. . q:src'=""
  1014. . s stop=1
  1015. i scriptOID="" d
  1016. . i 'isAjax d
  1017. . . n attr,headOID
  1018. . . s headOID=$$getFirstElementByTagName^%zewdDOM("head",docName,"")
  1019. . . i headOID="" s headOID=$$addElementToDOM^%zewdDOM("head",docOID,,,,1)
  1020. . . s attr("language")="javascript"
  1021. . . s scriptOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,"")
  1022. . e d
  1023. . . s attr("language")="javascript"
  1024. . . s scriptOID=$$addElementToDOM^%zewdDOM("script",docOID,,.attr,"")
  1025. k textArr
  1026. s jsText=$$getElementValueByOID^%zewdDOM(scriptOID,"textArr",1)
  1027. i '$d(textArr) s textArr(1)=jsText
  1028. QUIT scriptOID
  1029. ;
  1030. addJavascriptFunction(docName,jsText)
  1031. ;
  1032. n childOID,lastLineNo,line,lineNo,OIDArray,scriptOID,text,textArr,textOID
  1033. ;
  1034. s scriptOID=$$getFirstJavascriptFunction(docName,.textArr)
  1035. s lastLineNo=$o(textArr(""),-1)
  1036. s lineNo="",text=""
  1037. f s lineNo=$o(jsText(lineNo)) q:lineNo="" d
  1038. . i jsText(lineNo)["<?="!(jsText(lineNo)["<%") d
  1039. . . k ^CacheTempEWD($j)
  1040. . . s ^CacheTempEWD($j,1)=jsText(lineNo)
  1041. . . d tokenisePHPVariables^%zewdHTMLParser(.phpVars)
  1042. . . s jsText(lineNo)=^CacheTempEWD($j,1)
  1043. . . k ^CacheTempEWD($j)
  1044. . i $l(text)+$l(jsText(lineNo))<4000 s text=text_jsText(lineNo)_$c(13,10) q
  1045. . s lastLineNo=lastLineNo+1
  1046. . s textArr(lastLineNo)=text
  1047. . s text=jsText(lineNo)_$c(13,10)
  1048. s lastLineNo=lastLineNo+1
  1049. s textArr(lastLineNo)=text
  1050. f q:$$hasChildNodes^%zewdDOM(scriptOID)="false" d
  1051. . s childOID=$$getFirstChild^%zewdDOM(scriptOID)
  1052. . s childOID=$$removeChild^%zewdAPI(childOID)
  1053. ;
  1054. s lineNo=""
  1055. f s lineNo=$o(textArr(lineNo)) q:lineNo="" d
  1056. . s text=textArr(lineNo)
  1057. . q:text=""
  1058. . s textOID=$$createTextNode^%zewdDOM(text,docOID)
  1059. . s textOID=$$appendChild^%zewdDOM(textOID,scriptOID)
  1060. QUIT scriptOID
  1061. ;
  1062. getJavascriptFunction(functionName,docName,eOID) ;
  1063. ;
  1064. n c,comm,dqlvl,eArray,slcomm,language,lc,lineNo,lvl
  1065. n mlcomm,ntags,OIDArray,%p1,%p2,pos,refString,sqlvl,stop,stop2
  1066. n text,textArr,textArray
  1067. ;
  1068. s text="",eOID=""
  1069. s refString="function "_functionName_"("
  1070. s ntags=$$getElementsArrayByTagName^%zewdDOM("script",docName,,.eArray)
  1071. s eOID="",stop=0
  1072. f s eOID=$o(eArray(eOID)) q:eOID="" d q:stop
  1073. . s language=$$getAttribute^%zewdDOM("language",eOID)
  1074. . q:language=""
  1075. . q:$$zcvt^%zewdAPI(language,"l")'["javascript"
  1076. . k textArr
  1077. . s text=$$getElementValueByOID^%zewdDOM(eOID,"textArr",1)
  1078. . i '$d(textArr) s textArr(1)=text
  1079. . s lineNo="",text=""
  1080. . f s lineNo=$o(textArr(lineNo)) q:lineNo="" d q:stop
  1081. . . s stop2=0
  1082. . . i textArr(lineNo)[refString f d q:textArr(lineNo)'[refString q:stop2
  1083. . . . s %p1=$p(textArr(lineNo),refString,1)
  1084. . . . s %p1=$re(%p1)
  1085. . . . s %p1=$p(%p1,$c(10,13),1)
  1086. . . . s %p1=$re(%p1)
  1087. . . . i %p1["//"!(%p1["/*") d q
  1088. . . . . s textArr(lineNo)=$p(textArr(lineNo),refString,2,1000)
  1089. . . . s stop2=1
  1090. . . q:textArr(lineNo)'[refString
  1091. . . s text=refString_$p(textArr(lineNo),refString,2,1000)
  1092. . . s %p1=$p(text,"{",1),%p2=$p(text,"{",2,1000)
  1093. . . s text=%p1_"{",lvl=1,c="",dqlvl=0,sqlvl=0,slcomm=0,mlcomm=0
  1094. . . f pos=1:1:$l(%p2) d q:stop
  1095. . . . s lc=c
  1096. . . . s c=$e(%p2,pos)
  1097. . . . i lc="\",c="{" s text=text_c q
  1098. . . . i lc="\",c="}" s text=text_c q
  1099. . . . i lc="\",c="""" s text=text_c q
  1100. . . . i lc="\",c="'" s text=text_c q
  1101. . . . i lc="/",c="/" s slcomm=1,text=text_c q
  1102. . . . i lc="/",c="*" s mlcomm=1,text=text_c q
  1103. . . . i lc="*",c="/" s mlcomm=0,text=text_c q
  1104. . . . i slcomm,c=$c(10) s slcomm=0,text=text_c q
  1105. . . . i c="""",dqlvl=0,'slcomm,'mlcomm s dqlvl=1
  1106. . . . i c="""",dqlvl=1,'slcomm,'mlcomm s dqlvl=0
  1107. . . . i c="'",sqlvl=0,'slcomm,'mlcomm s sqlvl=1
  1108. . . . i c="'",sqlvl=1,'slcomm,'mlcomm s sqlvl=0
  1109. . . . i slcomm!mlcomm s text=text_c q
  1110. . . . i c="{",dqlvl=1 s text=text_c q
  1111. . . . i c="}",dqlvl=1 s text=text_c q
  1112. . . . i c="{",sqlvl=1 s text=text_c q
  1113. . . . i c="}",sqlvl=1 s text=text_c q
  1114. . . . i c="{" s lvl=lvl+1
  1115. . . . i c="}" s lvl=lvl-1 i lvl=0 s stop=1 q
  1116. . . . s text=text_c
  1117. . . s text=text_"}"
  1118. QUIT text
  1119. ;
  1120. getJavascriptFunctionBody(functionName,docName)
  1121. ;
  1122. n body,crlf,eOID,jsText,nLines
  1123. ;
  1124. s jsText=$$getJavascriptFunction(functionName,docName,.eOID)
  1125. s crlf=$c(13,10)
  1126. s nLines=$l(jsText,crlf)
  1127. s body=$p(jsText,crlf,2,nLines-1)
  1128. QUIT body
  1129. ;
  1130. replaceJavascriptFunctionBody(functionName,newBody,docName)
  1131. ;
  1132. n body,call,crlf,eOID,jsText
  1133. ;
  1134. s jsText=$$getJavascriptFunction(functionName,docName,.eOID)
  1135. s crlf=$c(13,10)
  1136. s call=$p(jsText,crlf,1)
  1137. s body=call_crlf_newBody_crlf_" }"
  1138. s ok=$$replaceJavascriptFunction(functionName,body,docName)
  1139. QUIT 1
  1140. ;
  1141. ;
  1142. ewdConfig(docName,phpHeaderArray,routineName,technology,dataTypeList,inputPath,filename,multilingual,config,pageName)
  1143. ;
  1144. ; Get the <ewd:config> tag and process it
  1145. ; Create the start of the CSP Pre-page script
  1146. ;
  1147. ; attributes are:
  1148. ;
  1149. ; isFirstPage = true | false ; true is the default
  1150. ; prePageScript = Cache function reference
  1151. ; defaultTimeout = default session timeout in seconds (default = 1200)
  1152. ; pageTimeout = page-specific session timeout in seconds (default = defaultTimeout)
  1153. ; homePage = URL of homepage redirection if ewdlogout.php is invoked
  1154. ; persistRequest = true | false ; saves the HTTP request name/value pairs to session array
  1155. ; overrideTemplate = true | false ; (default=false) determines whether values in template or page take precedence
  1156. ;
  1157. ;
  1158. ; If missing, set page to be allowed to be used as a first page,
  1159. ; and no pre-page Script
  1160. ;
  1161. n multiLingual,nodeOID,onErrorScript,prePageScript,preProcess,secureRequest,templatePrePageScript
  1162. ;
  1163. i $$isXSLFO^%zewdCompiler(docName) d QUIT 0
  1164. . s pageName=$$XSLFO^%zewdCompiler7(docName)
  1165. ;
  1166. s multiLingual=2
  1167. s nodeOID=$$getTagOID^%zewdCompiler("ewd:config",docName)
  1168. i nodeOID="" d
  1169. . s config("isFirstPage")=1
  1170. . s config("defaultTimeout")=1200
  1171. . s config("pageTimeout")=config("defaultTimeout")
  1172. . ;s config("homePage")="/default.htm"
  1173. . s config("homePage")=$g(^zewd("config","homePage"))
  1174. . s config("persistRequest")="true"
  1175. . s config("errorPage")="ewdError"
  1176. . s config("mgwsiServer")="LOCAL" i $$os^%zewdHTMLParser()="gtm" s config("mgwsiServer")="gtm"
  1177. . s config("pageType")="html"
  1178. . s config("errorClass")=""
  1179. e d
  1180. . n serverList
  1181. . i $g(backend)="" s backend="m"
  1182. . s config("backend")=backend
  1183. . s config("pageType")=$$zcvt^%zewdAPI($$getAttributeValue^%zewdDOM("pagetype",1,nodeOID),"l")
  1184. . i config("pageType")="" s config("pageType")="html"
  1185. . s config("isFirstPage")=$$getAttributeValue^%zewdDOM("isfirstpage",1,nodeOID)
  1186. . i config("pageType")="ajax",config("isFirstPage")="" s config("isFirstPage")="false"
  1187. . i config("isFirstPage")="" d
  1188. . . n public
  1189. . . s public=$$getAttributeValue^%zewdDOM("publicpage",1,nodeOID)
  1190. . . s config("isFirstPage")="true"
  1191. . . i $$zcvt^%zewdAPI(public,"l")="false" s config("isFirstPage")="false"
  1192. . ;i config("isFirstPage")="" s config("isFirstPage")="true"
  1193. . s config("isFirstPage")=$$zcvt^%zewdAPI(config("isFirstPage"),"l")="true"
  1194. . s prePageScript=$$getAttributeValue^%zewdDOM("prepagescript",1,nodeOID)
  1195. . i prePageScript="" s prePageScript=$$getAttributeValue^%zewdDOM("fetchmethod",1,nodeOID)
  1196. . i prePageScript'="" d
  1197. . . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"scriptCalls",$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"),$$zcvt^%zewdAPI(prePageScript,"l"))="prePage"
  1198. . . s ^%zewdIndex($$zcvt^%zewdAPI(app,"l"),"scriptCalledBy",$$zcvt^%zewdAPI(prePageScript,"l"),$$zcvt^%zewdAPI($p(filename,".ewd",1),"l"))="prePage"
  1199. . d
  1200. . . i prePageScript'["^",$e(prePageScript,1,7)'="##class",$e(prePageScript,1)'="$",$g(routineName)'="" s config("prePageScript")=config("prePageScript")_"^"_routineName q
  1201. . . i $e(prePageScript,1)="$" s config("prePageScript")=prePageScript_"($ewd_session)" q
  1202. . . s config("prePageScript")=prePageScript
  1203. . . i $e(prePageScript,1,3)="js:" d
  1204. . . . n page
  1205. . . . s page=$p(filename,".ewd",1)
  1206. . . . s ^zewd("nodeModules","methods",$$zcvt^%zewdAPI(app,"l"),$$zcvt^%zewdAPI(page,"l"))=$p(prePageScript,"js:",2)
  1207. . s templatePrePageScript=$$getAttributeValue^%zewdDOM("templateprepagescript",1,nodeOID)
  1208. . s preProcess=$$getAttributeValue^%zewdDOM("preprocess",1,nodeOID)
  1209. . d
  1210. . . i filename="ewdAjaxError.ewd" q
  1211. . . i filename="ewdAjaxErrorRedirect.ewd" q
  1212. . . i filename="ewdErrorRedirect.ewd" q
  1213. . . i templatePrePageScript'["^",$e(templatePrePageScript,1,7)'="##class",$e(templatePrePageScript,1)'="$",$g(routineName)'="" s config("templatePrePageScript")=config("templatePrePageScript")_"^"_routineName q
  1214. . . i $e(templatePrePageScript,1)="$" s config("templatePrePageScript")=templatePrePageScript_"($ewd_session)" q
  1215. . . i templatePrePageScript["^" s config("templatePrePageScript")=templatePrePageScript
  1216. . . s config("templatePrePageScript")=templatePrePageScript
  1217. . . i preProcess'["^",$e(preProcess,1,7)'="##class",$e(preProcess,1)'="$",$g(routineName)'="" s config("preProcess")=config("preProcess")_"^"_routineName q
  1218. . . i $e(preProcess,1)="$" s config("preProcess")=preProcess_"($ewd_session)" q
  1219. . . i preProcess["^" s config("preProcess")=preProcess
  1220. . . s config("preProcess")=preProcess
  1221. . s onErrorScript=$$getAttributeValue^%zewdDOM("onerrorscript",1,nodeOID)
  1222. . d
  1223. . . i onErrorScript'["^",$e(onErrorScript,1,7)'="##class",$e(onErrorScript,1)'="$",$g(routineName)'="" s config("onErrorScript")=config("onErrorScript")_"^"_routineName q
  1224. . . i $e(onErrorScript,1)="$" s config("onErrorScript")=onErrorScript_"($ewd_session)" q
  1225. . . s config("onErrorScript")=onErrorScript
  1226. . s config("defaultTimeout")=$$getAttributeValue^%zewdDOM("defaulttimeout",1,nodeOID)
  1227. . i config("defaultTimeout")="" s config("defaultTimeout")=1200
  1228. . s config("pageTimeout")=$$getAttributeValue^%zewdDOM("pagetimeout",1,nodeOID)
  1229. . i config("pageTimeout")="" s config("pageTimeout")=config("defaultTimeout")
  1230. . i $$zcvt^%zewdAPI(config("pageTimeout"),"l")="system" d
  1231. . . i technology="csp" s config("pageTimeout")="" q
  1232. . . s config("pageTimeout")=config("defaultTimeout")
  1233. . s config("homePage")=$g(^zewd("config","homePage"))
  1234. . i $$getAttributeValue^%zewdDOM("homepage",1,nodeOID)'="" s config("homePage")=$$getAttributeValue^%zewdDOM("homepage",1,nodeOID)
  1235. . s config("persistRequest")=$$getAttributeValue^%zewdDOM("persistrequest",1,nodeOID)
  1236. . i config("persistRequest")="" s config("persistRequest")="true"
  1237. . s config("pageTitle")=$$getAttributeValue^%zewdDOM("pagetitle",1,nodeOID)
  1238. . i config("pageTitle")="" s config("pageTitle")=""
  1239. . s config("confirmText")=$$getAttributeValue^%zewdDOM("confirmtext",1,nodeOID)
  1240. . i config("confirmText")="" s config("confirmText")="Click OK if you're sure you want to delete this record"
  1241. . s config("secureRequest")=$$getAttributeValue^%zewdDOM("securerequest",1,nodeOID)
  1242. . i config("secureRequest")="" s config("secureRequest")="true"
  1243. . s config("errorPage")=$$getAttributeValue^%zewdDOM("errorpage",1,nodeOID)
  1244. . i $g(config("isFirstPage")),config("errorPage")="" s config("errorPage")="ewdError"
  1245. . s config("errorClass")=$$getAttributeValue^%zewdDOM("errorclass",1,nodeOID)
  1246. . s config("mgwsiServer")=$$getAttributeValue^%zewdDOM("mgwsiserver",1,nodeOID)
  1247. . i config("mgwsiServer")="" s config("mgwsiServer")=$$getAttributeValue^%zewdDOM("mphpserver",1,nodeOID)
  1248. . i config("mgwsiServer")="" s config("mgwsiServer")=$g(ewd("sessionDatabase","mgwsiServer"))
  1249. . i config("mgwsiServer")="" s config("mgwsiServer")="LOCAL"
  1250. . i $$os^%zewdHTMLParser()="gtm" s config("mgwsiServer")="gtm"
  1251. . s config("cachePage")=$$getAttributeValue^%zewdDOM("cachepage",1,nodeOID)
  1252. . i config("cachePage")="" s config("cachePage")="true"
  1253. . s config("disableGetPage")=$$getAttributeValue^%zewdDOM("disablegetpage",1,nodeOID)
  1254. . i config("disableGetPage")="" s config("disableGetPage")="false"
  1255. . s config("escapeText")=$$getAttributeValue^%zewdDOM("escapetext",1,nodeOID)
  1256. . i config("escapeText")="" s config("escapeText")="false"
  1257. . s config("redirection")=$$getAttributeValue^%zewdDOM("redirection",1,nodeOID)
  1258. . i config("redirection")="" s config("redirection")="server"
  1259. . s config("arraySize")=$$getAttributeValue^%zewdDOM("arraysize",1,nodeOID)
  1260. . i config("arraySize")="" s config("arraySize")="128"
  1261. . s config("nextPageList")=$$getAttributeValue^%zewdDOM("nextpagelist",1,nodeOID)
  1262. . s config("actionIfTimedOut")=$$getAttributeValue^%zewdDOM("actioniftimedout",1,nodeOID)
  1263. . s config("maxLines")=$$getAttributeValue^%zewdDOM("maxlines",1,nodeOID)
  1264. . s config("websockets")=$$getAttributeValue^%zewdDOM("websockets",1,nodeOID)
  1265. . s multiLingual=$$zcvt^%zewdAPI($$getAttributeValue^%zewdDOM("multilingual",1,nodeOID),"l")
  1266. . i multiLingual="false" s multiLingual=0
  1267. . e s multiLingual=2
  1268. . s config("ewd_sessionServer")=$$getAttributeValue^%zewdDOM("sessionserver",1,nodeOID)
  1269. . i config("ewd_sessionServer")="" s config("ewd_sessionServer")=$g(ewd("sessionDatabase","type"))
  1270. . i config("ewd_sessionServer")="cache" s config("ewd_sessionServer")="m"
  1271. . i config("ewd_sessionServer")="" s config("ewd_sessionServer")="m"
  1272. . i $g(persistenceDB)'="" s config("ewd_sessionServer")=persistenceDB
  1273. . s config("ewd_sessionServerHostname")=$$getAttributeValue^%zewdDOM("sessionserverhost",1,nodeOID)
  1274. . i config("ewd_sessionServerHostname")="" s config("ewd_sessionServerHostname")=$g(ewd("sessionDatabase","host"))
  1275. . s config("ewd_sessionServerUsername")=$$getAttributeValue^%zewdDOM("sessionserverusername",1,nodeOID)
  1276. . i config("ewd_sessionServerUsername")="" s config("ewd_sessionServerUsername")=$g(ewd("sessionDatabase","username"))
  1277. . s config("ewd_sessionServerPassword")=$$getAttributeValue^%zewdDOM("sessionserverpassword",1,nodeOID)
  1278. . i config("ewd_sessionServerPassword")="" s config("ewd_sessionServerPassword")=$g(ewd("sessionDatabase","password"))
  1279. . s config("startFromWLDOnly")=$$getAttributeValue^%zewdDOM("startfromwldonly",1,nodeOID)
  1280. . s config("startFromWLDOnly")=config("startFromWLDOnly")="true"
  1281. . s serverList=$$getAttributeValue^%zewdDOM("servernamelist",1,nodeOID)
  1282. . i serverList'="" d
  1283. . . n i,np,p
  1284. . . s serverList=$$stripSpaces^%zewdAPI(serverList)
  1285. . . s np=$l(serverList,",")
  1286. . . i np>0 d
  1287. . . . f i=1:1:np d
  1288. . . . . s p=$p(serverList,",",i)
  1289. . . . . i p'="" s config("serverList",p)=""
  1290. i multiLingual=0 s multilingual=multiLingual
  1291. d createPHPConfigHeader^%zewdCompiler3(.config,.phpHeaderArray,technology,docName,.dataTypeList,inputPath,filename,multilingual,.pageName)
  1292. s nodeOID=$$removeChild^%zewdAPI(nodeOID)
  1293. QUIT multiLingual
  1294. ;
  1295. ;
  1296. mergeToList(listName,listArray,sessid)
  1297. ;
  1298. n position,data,%d,text,value,pos
  1299. ;
  1300. s pos=""
  1301. f s pos=$o(listArray(pos)) q:pos="" d
  1302. . k data
  1303. . s data=listArray(pos)
  1304. . i data["~",data'[$c(1) d
  1305. . . n p1,p2
  1306. . . s p1=$p(data,"~",1)
  1307. . . s p2=$p(data,"~",2)
  1308. . . s listArray(pos)=p1_$c(1)_p2
  1309. ;
  1310. ;
  1311. k ^%zewdSession("session",sessid,"ewd_list",listName)
  1312. k ^%zewdSession("session",sessid,"ewd_listIndex",listName)
  1313. m ^%zewdSession("session",sessid,"ewd_list",listName)=listArray
  1314. s position=""
  1315. f s position=$o(^%zewdSession("session",sessid,"ewd_list",listName,position)) q:position="" d
  1316. . k %d,text,value
  1317. . s %d=^%zewdSession("session",sessid,"ewd_list",listName,position)
  1318. . s text=$p(%d,$c(1),1)
  1319. . s value=$p(%d,$c(1),2)
  1320. . i value="" s value=$e(text,1,200)
  1321. . q:value=""
  1322. . s ^%zewdSession("session",sessid,"ewd_listIndex",listName,value)=position
  1323. d setWLDSymbol^%zewdAPI("ewd_list",sessid)
  1324. d setWLDSymbol^%zewdAPI("ewd_listIndex",sessid)
  1325. QUIT
  1326. ;
  1327. copyList(fromListName,toListName,sessid)
  1328. ;
  1329. n ewdList,ewdListIndex
  1330. ;
  1331. i $g(fromListName)="" QUIT
  1332. i $g(toListName)="" QUIT
  1333. i $g(sessid)="" QUIT
  1334. ;
  1335. d mergeArrayFromSession^%zewdAPI(.ewdList,"ewd_list",sessid)
  1336. d mergeArrayFromSession^%zewdAPI(.ewdListIndex,"ewd_listIndex",sessid)
  1337. ;
  1338. k ewdList(toListName)
  1339. k ewdListIndex(toListName)
  1340. m ewdList(toListName)=ewdList(fromListName)
  1341. m ewdListIndex(toListName)=ewdListIndex(fromListName)
  1342. ;
  1343. d deleteFromSession^%zewdAPI("ewd_list",sessid)
  1344. d deleteFromSession^%zewdAPI("ewd_listIndex",sessid)
  1345. d mergeArrayToSession^%zewdAPI(.ewdList,"ewd_list",sessid)
  1346. d mergeArrayToSession^%zewdAPI(.ewdListIndex,"ewd_listIndex",sessid)
  1347. ;
  1348. QUIT
  1349. ;
  1350. getTextFromList(listName,codeValue,sessid)
  1351. ;
  1352. n position,return
  1353. ;
  1354. i $g(listName)="" QUIT ""
  1355. i $g(sessid)="" QUIT ""
  1356. i $g(codeValue)="" QUIT ""
  1357. set $zt="getTextFromListErr"
  1358. ;
  1359. s position=$g(^%zewdSession("session",sessid,"ewd_listIndex",listName,codeValue))
  1360. i position="" QUIT ""
  1361. QUIT $p(^%zewdSession("session",sessid,"ewd_list",listName,position),$c(1),1)
  1362. ;
  1363. getTextFromListErr
  1364. set $zt=""
  1365. QUIT ""
  1366. ;
  1367. replaceOptionsByFieldName(formName,fieldName,listName,sessid)
  1368. ;
  1369. n fieldRef,return,textValue,textValueEsc
  1370. ;
  1371. s fieldRef="document."_formName_"."_fieldName
  1372. s return=fieldRef_".options.length = 0;"
  1373. s return=return_$$returnOptions(fieldRef,listName,sessid)
  1374. QUIT return
  1375. ;
  1376. replaceOptionsByID(fieldID,listName,sessid)
  1377. ;
  1378. n fieldRef,return,textValue,textValueEsc
  1379. ;
  1380. s fieldRef="document.getElementById('"_fieldID_"')"
  1381. s return=fieldRef_".options.length = 0;"
  1382. s return=return_$$returnOptions(fieldRef,listName,sessid)
  1383. QUIT return
  1384. ;
  1385. returnOptions(fieldRef,listName,sessid)
  1386. ;
  1387. n codeValue,codeValueEsc,%d,ewdList,i,pos,return,textValue,textValueEsc
  1388. ;
  1389. d mergeArrayFromSession^%zewdAPI(.ewdList,"ewd_list",sessid)
  1390. ;
  1391. s pos="",i=-1,return=""
  1392. f s pos=$o(ewdList(listName,pos)) q:pos="" d
  1393. . k %d,textValue,codeValue,codeValueEsc,textValueEsc
  1394. . s %d=ewdList(listName,pos)
  1395. . s textValue=$p(%d,$c(1),1)
  1396. . s textValueEsc=textValue
  1397. . s textValueEsc=$$replaceAll^%zewdHTMLParser(textValueEsc,"&#39;","'")
  1398. . s codeValue=$p(%d,$c(1),2)
  1399. . i codeValue="" s codeValue=textValue
  1400. . s codeValueEsc=codeValue
  1401. . s codeValueEsc=$$replaceAll^%zewdHTMLParser(codeValueEsc,"&#39;","'")
  1402. . s i=i+1
  1403. . s return=return_fieldRef_".options["_i_"] = new Option("""_textValueEsc_""","""_codeValueEsc_""");"
  1404. QUIT return
  1405. ;