source: ePrescribing/trunk/p/_zewdCompiler13.m@ 530

Last change on this file since 530 was 516, checked in by George Lilly, 16 years ago

ewd webservices support

File size: 40.7 KB
RevLine 
[516]1%zewdCompiler13 ; Enterprise Web Developer Compiler Functions
2 ;
3 ; Product: Enterprise Web Developer version 4.0.755
4 ; Build Date: Thu, 12 Feb 2009 09:53:12
5 ;
6 ; ----------------------------------------------------------------------------
7 ; | Enterprise Web Developer for GT.M and m_apache |
8 ; | Copyright (c) 2004-9 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 ;
32ifArrayExists(nodeOID,attrValues,docOID,technology)
33 ;
34 ; <ewd:ifArrayExists arrayName="$myArray" param1="xxx" param2="$yyy" param3="#zzz">
35 ;
36 n arrayName,comma,param,subs,pval
37 set arrayName=$$getAttrValue^%zewdAPI("arrayname",.attrValues,technology)
38 s param="param",subs="",comma=""
39 f s param=$o(attrValues(param)) q:param="" q:param'["param" d
40 . s pval=attrValues(param)
41 . d
42 . . s pval=$$replaceAll^%zewdHTMLParser(pval,"""","&quot;")
43 . . s subs=subs_comma_pval,comma=","
44 d
45 . ;
46 . n cwOID,attr
47 . ;
48 . s cwOID=$$addIntermediateNode^%zewdCompiler4("csp:if",nodeOID)
49 . ;
50 . ; <csp:if condition="$d(%ewdVar(&quote;ewdTabMenu&quote;,&quote;5&quote;))">
51 . ;
52 . s arrayName=$$removeQuotes^%zewdAPI(arrayName)
53 . i arrayName="" s arrayName="%ewdVar"
54 . i subs="" s attr="$d("_arrayName_")"
55 . e s attr="$d("_arrayName_"("_subs_"))"
56 . d setAttribute^%zewdDOM("condition",attr,cwOID)
57 ;
58 d removeIntermediateNode^%zewdCompiler4(nodeOID)
59 ;
60 QUIT
61 ;
62url(nodeOID,attrValues,docOID,technology)
63 ;
64 ; <ewd:url return="$fullUrl" url="$url" />
65 ;
66 n return,url
67 ;
68 set url=$$getAttrValue^%zewdAPI("url",.attrValues,technology)
69 set return=$$getAttrValue^%zewdAPI("return",.attrValues,technology)
70 ;
71 d
72 . n page,serverOID,text
73 . s page=url,text=""
74 . s url=$$getRootURL^%zewdCompiler("gtm")_app_"/"_url_".mgwsi?"
75 . s url=url_"ewd_token=""_$g(^%zewdSession(""session"",sessid,""ewd_token""))_""&n=""_tokens("_$tr(page,"'","")_")"
76 . s text=text_" s "_return_"="""_url
77 . s serverOID=$$addCSPServerScript^%zewdCompiler4(nodeOID,text)
78 ;
79 d removeIntermediateNode^%zewdCompiler4(nodeOID)
80 ;
81 QUIT
82 ;
83tabMenuOption(nodeOID,attrValues,docOID,technology)
84 ;
85 ; <ewd:tabMenuOption position="1" text="Configuration" nextpage="config" defaultSelected="true" help="This is some help" greyIf="grey^%zewdMgr">
86 ;
87 n attr,decOID,defaultSelected,docName,greyIf,help,newOID,nextpage
88 n position,text,value
89 ;
90 set position=$$getAttrValue^%zewdAPI("position",.attrValues,technology)
91 s position=$$removeQuotes^%zewdAPI(position)
92 set text=$$getAttrValue^%zewdAPI("text",.attrValues,technology)
93 s text=$$removeQuotes^%zewdAPI(text)
94 set nextpage=$$getAttrValue^%zewdAPI("nextpage",.attrValues,technology)
95 s nextpage=$$removeQuotes^%zewdAPI(nextpage)
96 set defaultSelected=$$getAttrValue^%zewdAPI("defaultselected",.attrValues,technology)
97 s defaultSelected=$$removeQuotes^%zewdAPI(defaultSelected)
98 set help=$$getAttrValue^%zewdAPI("help",.attrValues,technology)
99 s help=$$removeQuotes^%zewdAPI(help)
100 set greyIf=$$getAttrValue^%zewdAPI("greyif",.attrValues,technology)
101 s greyIf=$$removeQuotes^%zewdAPI(greyIf)
102 ;
103 ; Map to
104 ; <ewd:setArrayValue arrayName="ewdTabMenu" param1="1" value="$menuInfo">
105 ; and place just after <body> tag
106 ;
107 s docName=$$getDocumentName^%zewdDOM(docOID)
108 s value=text_"|"_nextpage_"|"_defaultSelected_"|"_help_"|"_greyIf
109 s newOID=$$getFirstElementByTagName^%zewdDOM("ewd:tabmenuarray",docName,"")
110 i $$getParentNode^%zewdDOM(newOID)="" s newOID=""
111 i newOID="" d
112 . n parentOID,xOID
113 . s parentOID=$$getFirstElementByTagName^%zewdDOM("head",docName,"")
114 . s newOID=$$getFirstElementByTagName^%zewdDOM("ewd:new","",parentOID)
115 . i newOID="" d
116 . . s newOID=$$addNewFirstChild^%zewdCompiler4("ewd:tabmenuarray",docOID,parentOID)
117 . e d
118 . . n fcOID,nextOID,tagOID
119 . . s nextOID=$$getNextSibling^%zewdDOM(newOID)
120 . . s tagOID=$$createElement^%zewdDOM("ewd:tabmenuarray",docOID)
121 . . s newOID=$$insertBefore^%zewdDOM(tagOID,nextOID)
122 s attr("arrayname")="$ewdTabMenu"
123 s attr("param1")=position
124 s attr("value")=value
125 s decOID=$$addElementToDOM^%zewdDOM("ewd:setarrayvalue",newOID,,.attr,"")
126 ;
127 i nextpage'="" d
128 . d
129 . . n phpString
130 . . s phpString=" s tokens("""_nextpage_""")=$$setNextPageToken^%zewdCompiler20("""_nextpage_""")"
131 . . d addVBHeaderPreCache^%zewdCompiler8(phpString)
132 ;
133 ; $tokens['run'] = setNextPageToken('run', $ewd_session) ;
134 d removeIntermediateNode^%zewdCompiler4(nodeOID)
135 ;
136 QUIT
137 ;
138xhtml(nodeOID,attrValues,docOID,technology)
139 ;
140 n dtOID,fcOID,htmlOID
141 ;
142 s dtOID=$$createDocumentType^%zewdDOM("html","-//W3C//DTD XHTML 1.0 Strict//EN","http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd",docOID)
143 ;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
144 s dtOID=$$insertBefore^%zewdDOM(dtOID,nodeOID)
145 ;<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
146 s fcOID=$$getFirstChild^%zewdDOM(nodeOID)
147 s htmlOID=$$insertNewIntermediateElement^%zewdDOM(nodeOID,"html",docOID)
148 d setAttribute^%zewdDOM("xmlns","http://www.w3.org/1999/xhtml",htmlOID)
149 d setAttribute^%zewdDOM("xml:lang","en",htmlOID)
150 do removeIntermediateNode^%zewdDOM(nodeOID)
151 QUIT
152 ;
153getSessionArrayValue(arrayName,subscript,sessid,exists)
154 ;
155 n value
156 ;
157 i $g(subscript)="" QUIT ""
158 i $g(arrayName)="" QUIT ""
159 ;
160 s arrayName=$tr(arrayName,".","_")
161 s exists=1
162 i $$isTemp^%zewdAPI(arrayName) d QUIT $g(value)
163 . m value=zewdSession(arrayName,subscript)
164 . i '$d(value) s exists=0
165 m value=^%zewdSession("session",sessid,arrayName,subscript)
166 i '$d(value) s exists=0
167 QUIT $g(value)
168 ;
169sessionArrayValueExists(arrayName,subscript,sessid)
170 ;
171 n exists,value
172 ;
173 s value=$$getSessionArrayValue(arrayName,subscript,sessid,.exists)
174 QUIT exists
175 ;
176deleteSessionArrayValue(arrayName,subscript,sessid)
177 ;
178 i $g(subscript)="" QUIT ""
179 i $g(arrayName)="" QUIT ""
180 s arrayName=$tr(arrayName,".","_")
181 ;
182 i $$isTemp^%zewdAPI(arrayName) k zewdSession(arrayName,subscript) QUIT
183 k ^%zewdSession("session",sessid,arrayName,subscript)
184 d setWLDSymbol^%zewdAPI(arrayName,sessid)
185 QUIT
186 ;
187setSessionObject(objectName,propertyName,propertyValue,sessid)
188 ;
189 n comma,i,np,p,sessionArray,x
190 ;
191 i $g(objectName)="" QUIT
192 i $g(propertyName)="" QUIT
193 ;i $g(propertyValue)="" QUIT
194 i $g(sessid)="" QUIT
195 s np=$l(objectName,".")
196 s objectName=$$replace^%zewdAPI(objectName,".","_")
197 i np=1 d QUIT
198 . i $$isTemp^%zewdAPI(objectName) s zewdSession(objectName_"_"_propertyName)=propertyValue q
199 . s ^%zewdSession("session",sessid,(objectName_"_"_propertyName))=propertyValue
200 ;
201 f i=1:1:np-1 s p(i)=$p(objectName,".",i)
202 s comma=","
203 i $$isTemp^%zewdAPI(objectName) d
204 . s x="s zewdSession(",comma=""
205 e d
206 . s x="s ^%zewdSession(""session"","_sessid
207 f i=1:1:np-1 s x=x_comma_""""_p(i)_"""",comma=","
208 s x=x_","""_propertyName_""")="""_propertyValue_""""
209 x x
210 QUIT
211 ;
212deleteFromSessionObject(objectName,propertyName,sessid)
213 ;
214 d deleteSessionArrayValue(objectName,propertyName,sessid)
215 QUIT
216 ;
217sessionObjectPropertyExists(objectName,propertyName,sessid)
218 QUIT $$sessionArrayValueExists(objectName,propertyName,sessid)
219 ;
220deleteSessionObject(objectName,sessid)
221 d deleteFromSession^%zewdAPI(objectName,sessid)
222 QUIT
223 ;
224 ;
225countResultSetRecords(sessionName,sessid)
226 i $$isTemp^%zewdAPI(sessionName) QUIT $o(zewdSession(sessionName,""),-1)
227 QUIT $o(^%zewdSession("session",sessid,sessionName,""),-1)
228 ;
229addToResultSet(sessionName,propertyName,value,sessid)
230 ;
231 n array,recNo
232 ;
233 s recNo=$$countResultSetRecords(sessionName,sessid)+1
234 s array(recNo,propertyName)=value
235 d mergeArrayToSession^%zewdAPI(.array,sessionName,sessid)
236 QUIT
237 ;
238mergeRecordArrayToResultSet(sessionName,array,sessid)
239 ;
240 n recArray,recNo
241 ;
242 s recNo=$$countResultSetRecords(sessionName,sessid)+1
243 m recArray(recNo)=array
244 d mergeArrayToSession^%zewdAPI(.recArray,sessionName,sessid)
245 QUIT
246 ;
247getResultSetValue(resultSetName,index,propertyName,sessid)
248 ;
249 n exists,value
250 ;
251 i $g(resultSetName)="" QUIT ""
252 i $g(index)="" QUIT ""
253 i $g(propertyName)="" QUIT ""
254 i $g(sessid)="" QUIT ""
255 ;
256 i $$isTemp^%zewdAPI(resultSetName) d QUIT $g(value)
257 . m value=zewdSession(resultSetName,index,propertyName)
258 . i '$d(value) s exists=0
259 m value=^%zewdSession("session",sessid,resultSetName,index,propertyName)
260 i '$d(value) s exists=0
261 QUIT $g(value)
262 ;
263saveJSON(objectName,jsonString)
264 i objectName="ewd" QUIT "alert(""Invalid request"")"
265 i $$JSONAccess^%zewdAPI(objectName,sessid)'="rw" QUIT "alert(""Invalid request"")"
266 i jsonString["\""" s jsonString=$$replaceAll^%zewdAPI(jsonString,"\""","""")
267 i jsonString["\'" s jsonString=$$replaceAll^%zewdAPI(jsonString,"\'","""")
268 d JSONToSessionObject(objectName,jsonString,sessid)
269 QUIT ""
270 ;
271getJSON(objectName,addRefCol)
272 i objectName="ewd" QUIT "alert(""Invalid request"")"
273 ;d trace^%zewdAPI("*** sessid="_sessid_"; JSONAccess="_$$JSONAccess^%zewdAPI(objectName,sessid))
274 i $$JSONAccess^%zewdAPI(objectName,sessid)="" QUIT "alert(""Invalid request"")"
275 QUIT $$sessionObjectToJSON($g(objectName),sessid,$g(addRefCol))
276 ;
277JSONToSessionObject(objectName,jsonString,sessid) ;
278 ;
279 n array,obj,prop
280 ;
281 ;d parseJSON(jsonString,.array)
282 d parseJSON^%zewdCompiler19(jsonString,.array)
283 d deleteSessionObject^%zewdAPI(objectName,sessid)
284 d mergeArrayToSessionObject^%zewdAPI(.array,objectName,sessid)
285 ;s prop=""
286 ;f s prop=$o(array(prop)) q:prop="" d
287 ;. s obj=objectName_"."_prop
288 ;. d trace^%zewdAPI("obj="_obj_"; "_$g(array(prop)))
289 ;. d setSessionValue^%zewdAPI(obj,$g(array(prop)),sessid)
290 ;;d deleteFromSession^%zewdAPI(objectName,sessid)
291 ;;d mergeArrayToSession^%zewdAPI(.array,objectName,sessid)
292 QUIT
293 ;
294parseJSON(jsonString,propertiesArray)
295 ;
296 n c,i,len,name,processing,started,type,value
297 ;
298 k propertiesArray
299 s jsonString=$g(jsonString)
300 s started=0
301 s processing=""
302 s name="",value="",type=""
303 s len=$l(jsonString)
304 ;
305 f i=1:1:len d
306 . s c=$e(jsonString,i)
307 . i 'started,c="{" s started=1,processing="name" q
308 . i processing="",c="""" s processing="name",name="" q
309 . i processing="",c=":" s processing="value",value="",type="" q
310 . i processing="name" d q
311 . . i c=",",name="" q
312 . . i c="""" s processing="" q
313 . . i c=":" s processing="value" q
314 . . s name=name_c
315 . i processing="value" d
316 . . i value="" d q
317 . . . i c="""" s type="literal"
318 . . . i c?1N s type="number"
319 . . . i c="-" s type="number"
320 . . . i c="f" s type="boolean"
321 . . . i c="t" s type="boolean"
322 . . . i c="n" s type="null"
323 . . . i c="[" d q
324 . . . . n arr,no,j,val
325 . . . . s no=0,val=""
326 . . . . f j=i+1:1 d q:c="]"
327 . . . . . s c=$e(jsonString,j)
328 . . . . . i c="]" s no=$$saveSubArray(no,.val,.arr) q
329 . . . . . i c="," s no=$$saveSubArray(no,.val,.arr) q
330 . . . . . s val=val_c
331 . . . . m propertiesArray(name)=arr
332 . . . . s i=j,name="",value="",processing="name"
333 . . . s value=value_c
334 . . ;i c="]" break s name="",value="",processing="name",i=j q
335 . . i type="literal",c="""" s type="literalComplete",value=value_c q
336 . . i ((c=",")!(c="}")),type'="literal" d q
337 . . . i type="literalComplete" s value=$e(value,2,$l(value)-1)
338 . . . s processing="name"
339 . . . s propertiesArray(name)=value
340 . . . s name="",value=""
341 . . s value=value_c
342 QUIT
343 ;
344saveSubArray(no,value,arr)
345 i $e(value,1)=""""!($e(value,1)="'") s value=$e(value,2,$l(value)-1)
346 s no=no+1
347 s arr(no)=value
348 s value=""
349 QUIT no
350 ;
351sessionObjectToJSON(objectName,sessid,addRefCol)
352 ;
353 n object,poropName,sub
354 ;
355 s sub=objectName_"_"
356 i $$isTemp^%zewdAPI(objectName) d
357 . f s sub=$o(zewdSession(sub)) q:sub="" q:sub'[(objectName_"_") d
358 . . s propName=$p(sub,(objectName_"_"),2)
359 . . m object(propName)=zewdSession(sub)
360 . i '$d(object) m object=zewdSession(objectName)
361 e d
362 . f s sub=$o(^%zewdSession("session",sessid,sub)) q:sub="" q:sub'[(objectName_"_") d
363 . . s propName=$p(sub,(objectName_"_"),2)
364 . . m object(propName)=^%zewdSession("session",sessid,sub)
365 . i '$d(object) m object=^%zewdSession("session",sessid,objectName)
366 QUIT $$createJSONString(objectName,.object,,$g(addRefCol))
367 ;
368mergeToJSObject(sessionObjRef,JSObjRef,sessid)
369 ;
370 ; eg sessionObjRef = wld.%User.bridge
371 ; JSObjRef = EZBRIDGE.Config
372 ;
373 n i,json,nsub,objName,ref,sessRef
374 ;
375 s sessRef=$$replace^%zewdAPI(sessionObjRef,".","_")
376 s nsub=$l(sessRef,".")
377 ;
378 s objName=$p(sessionObjRef,".",1)
379 i objName="ewd" QUIT "alert(""Invalid request"")"
380 i $$JSONAccess^%zewdAPI(objName,sessid)="" QUIT "alert(""Invalid request"")"
381 ;
382 s ref="",comma=""
383 f i=1:1:nsub s ref=ref_comma_""""_$p(sessRef,".",i)_"""",comma=","
384 i $$isTemp^%zewdAPI(sessRef) d
385 . s ref="m jsArray=zewdSession("_ref_")"
386 e d
387 . s ref="m jsArray=^%zewdSession(""session"",sessid,"_ref_")"
388 x ref
389 s json=$$createJSONString(JSObjRef,.jsArray)
390 QUIT json
391 ;
392objectGlobalToJSON(objectName)
393 ;
394 QUIT $g(^zewd("jsObject",objectName))
395 ;
396createJSONString(objectName,objectArray,isDojo,addRefCol,directOutput)
397 ;
398 n comma,dd,json,name,object,type
399 ;
400 s directOutput=+$g(directOutput)
401 s isDojo=$g(isDojo)
402 i isDojo=1 s directOutput=0
403 i '$d(objectArray) QUIT ""
404 s name=""
405 s json=""
406 i isDojo'=1 d
407 . i directOutput w objectName_"=" q
408 . s json=objectName_"="
409 i $g(addRefCol)=1 d
410 . n rowNo
411 . s rowNo=""
412 . f s rowNo=$o(objectArray(rowNo)) q:rowNo="" d
413 . . s objectArray(rowNo,0)=rowNo-1
414 s json=$$walkArray(json,$name(objectArray),isDojo)
415 ;
416 ;s json=$e(json,1,$l(json)-1)_"}"
417 i isDojo=1 s json="{identifier:'id',"_$e(json,2,$l(json))
418 i isDojo'=1 d
419 . i directOutput w ";" q
420 . s json=json_" ;"
421 i $g(^zewd("trace"))=1 d trace^%zewdAPI("json="_json)
422 QUIT json
423 ;
424walkArray(json,name,dojo,subscripts,isObject,mixed)
425 ;
426 n arrComma,brace,comma,cr,dd,i,no,numsub,dblquot,quot,ref,sub,subNo,subscripts1,type,valquot,value,xref,zobj
427 ;
428 s cr=$c(13,10),comma=","
429 s mixed=+$g(mixed)
430 s (dblquot,valquot)=""""
431 s dojo=+$g(dojo)
432 i dojo=1 s dblquot="",valquot="'"
433 i $g(isObject) d
434 . s json=json_"("
435 s dd=$d(@name)
436 i dd=1!(dd=11) d i dd=1 QUIT json
437 . s value=@name
438 . i value'[">" q
439 . i dojo=2,value="<mixed>" d q
440 . . i $d(subscripts) q
441 . . s mixed=1
442 . i dojo=2,$e(value,1)="<",$e(value,$l(value))=">" q
443 . i dojo=2 d
444 . . s json=json_$p(value,">",1) ;_"("_cr
445 . i dojo=2 d
446 . . s json=$$walkArray(json,$p(value,">",2),$g(dojo),,1)
447 . e d
448 . . s json=$$walkArray(json,value,$g(dojo),,1)
449 . ;s json=json_cr_")"
450 i 'mixed d
451 . s json=json_"{"
452 s ref=name_"("
453 s no=$o(subscripts(""),-1)
454 i no>0 f i=1:1:no d
455 . s quot=""""
456 . i subscripts(i)?."-"1N.N s quot=""
457 . s ref=ref_quot_subscripts(i)_quot_","
458 ;i no>0 f i=1:1:no s ref=ref_dblquot_subscripts(i)_dblquot_","
459 s ref=ref_"sub)"
460 s sub="",numsub=0,subNo=0
461 f s sub=$o(@ref) q:sub="" d
462 . s subscripts(no+1)=sub
463 . s subNo=subNo+1
464 . i 'mixed,subNo=1,sub?1N.N d
465 . . s numsub=1
466 . . s json=$e(json,1,$l(json)-1)_"["
467 . s dd=$d(@ref)
468 . i dd=1 d
469 . . ;w ref_"="_@ref,!
470 . . s value=@ref
471 . . ;i sub'?1N.N s json=json_dblquot_sub_dblquot_":"
472 . . i sub'?1N.N d
473 . . . s json=json_sub_":"
474 . . s type="literal"
475 . . i dojo=2,value[">",value'["?>" d
476 . . . i $e(value,$l(value))=">" q
477 . . . d
478 . . . . s json=json_$p(value,">",1) ;_"("_cr
479 . . . s json=$$walkArray(json,$p(value,">",2),$g(dojo),,1)
480 . . . s type="object"
481 . . . s value=""
482 . . i value?1N.N s type="numeric"
483 . . i value?1"-"1N.N s type="numeric"
484 . . i value?1N.N1"."1N.N s type="numeric"
485 . . i value?1"-"1N.N1"."1N.N s type="numeric"
486 . . i value="true"!(value="false") s type="boolean"
487 . . i $e(value,1)="{",$e(value,$l(value))="}" s type="variable"
488 . . i dojo=2,value["<?=",value["?>" d
489 . . . s value=$p(value,"<?=",2)
490 . . . s value=$p(value,"?>",1)
491 . . . s value=$$stripSpaces^%zewdAPI(value)
492 . . . s type="variable"
493 . . ;i type="literal" s value=""""_value_""""
494 . . i type="literal" s value=valquot_value_valquot
495 . . i dojo=1,type="numeric" s value=valquot_value_valquot
496 . . d
497 . . . s json=json_value_","
498 . k subscripts1
499 . m subscripts1=subscripts
500 . i dd>9 d
501 . . i sub?1N.N d
502 . . . i 'mixed,subNo=1 d
503 . . . . s numsub=1
504 . . . . s json=$e(json,1,$l(json)-1)_"["
505 . . e d
506 . . . ;s json=json_dblquot_sub_dblquot_":"
507 . . . i $e(sub,1,4)'="zobj" d
508 . . . . s json=json_sub_":"
509 . . . i $e(sub,1,4)="zobj" d
510 . . . . i $e(json,$l(json))'="," d
511 . . . . . s json=$e(json,1,$l(json)-1),zobj=1 ; remove { at end
512 . . s json=$$walkArray(json,name,dojo,.subscripts1)
513 . . i dojo=1,numsub d
514 . . . s json=$e(json,1,$l(json)-1)
515 . . . s json=json_",id:'"_sub_"'}"
516 . . d
517 . . . s json=json_","
518 ;
519 s json=$e(json,1,$l(json)-1)
520 s brace="}"
521 i mixed s brace=""
522 i $g(isObject) s brace=brace_")"
523 i numsub s brace="]"
524 i $g(zobj)'=1 d
525 . s json=json_brace
526 QUIT json ; exit!
527 ;
528createRef(name,subscripts)
529 ;
530 n no,ref
531 ;
532 s ref=name_"("
533 s no=$o(subscripts(""),-1)
534 i no>0 f i=1:1:no d
535 . s quot=""""
536 . i subscripts(i)?."-"1N.N s quot=""
537 . s ref=ref_quot_subscripts(i)_quot_","
538 s ref=ref_""""")"
539 QUIT ref
540 ;
541test
542 k array
543 s array("label")="name"
544 s array("items",1,"name")="Fruit"
545 s array("items",1,"type")="category"
546 s array("items",2,"name")="Cinammon"
547 s array("items",2,"type")="category"
548 s array("items",2,"children",1,"name")="Cinnamon Lozenge"
549 s array("items",2,"children",1,"type")="category"
550 s array("items",2,"children",2,"name")="Cinnamon Toast"
551 s array("items",2,"children",2,"type")="category"
552 s array("items",2,"children",3,"name")="Cinnamon Spread"
553 s array("items",2,"children",3,"type")="category"
554 s array("items",3,"name")="Apple"
555 s array("items",3,"type")="category"
556 w $$createJSONString("myTest",.array,1)
557 QUIT
558 ;
559addJavascriptObject(docName,jsText)
560 ;
561 n childOID,lastLineNo,line,lineNo,OIDArray,scriptOID,text,textArray,textOID
562 ;
563 s scriptOID=$$getLastJavascriptTag(docName,.textArray)
564 s lastLineNo=$o(textArray(""),-1)
565 s lineNo="",text=""
566 f s lineNo=$o(jsText(lineNo)) q:lineNo="" d
567 . i jsText(lineNo)["<?="!(jsText(lineNo)["<%") d
568 . . k ^CacheTempEWD($j)
569 . . s ^CacheTempEWD($j,1)=jsText(lineNo)
570 . . d tokenisePHPVariables^%zewdHTMLParser(.phpVars)
571 . . s jsText(lineNo)=^CacheTempEWD($j,1)
572 . . k ^CacheTempEWD($j)
573 . i $l(text)+$l(jsText(lineNo))<30000 s text=text_jsText(lineNo)_$c(13,10) q
574 . s lastLineNo=lastLineNo+1
575 . s textArray(lastLineNo)=text
576 . s text=jsText(lineNo)_$c(13,10)
577 s lastLineNo=lastLineNo+1
578 s textArray(lastLineNo)=text
579 f q:$$hasChildNodes^%zewdDOM(scriptOID)="false" d
580 . s childOID=$$getFirstChild^%zewdDOM(scriptOID)
581 . s childOID=$$removeChild^%zewdAPI(childOID)
582 ;
583 s lineNo=""
584 f s lineNo=$o(textArray(lineNo)) q:lineNo="" d
585 . s text=textArray(lineNo)
586 . q:text=""
587 . s textOID=$$createTextNode^%zewdDOM(text,docOID)
588 . s textOID=$$appendChild^%zewdDOM(textOID,scriptOID)
589 QUIT scriptOID
590 ;
591getLastJavascriptTag(docName,textArray)
592 ;
593 n attr,childNodes,eArray,headOID,jsText,language,nodeNo,nodeOID,ntags
594 n OIDArray,scriptOID,src,stop,tagName
595 ;
596 s headOID=$$getTagOID^%zewdAPI("head",docName)
597 i headOID="" s headOID=$$addElementToDOM^%zewdDOM("head",docOID,,,,1)
598 d getChildrenInOrder^%zewdDOM(headOID,.childNodes)
599 s nodeNo="",scriptOID="",stop=0
600 f s nodeNo=$o(childNodes(nodeNo),-1) q:nodeNo="" d q:stop
601 . s scriptOID=childNodes(nodeNo)
602 . s tagName=$$getTagName^%zewdDOM(scriptOID)
603 . i tagName'="script" q
604 . s language=$$getAttribute^%zewdDOM("language",scriptOID)
605 . q:$$zcvt^%zewdAPI(language,"l")'="javascript"
606 . s src=$$getAttribute^%zewdDOM("src",scriptOID)
607 . q:src'=""
608 . s stop=1
609 i scriptOID="" d
610 . n attr
611 . s attr("language")="javascript"
612 . set scriptOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,"")
613 k textArray
614 s jsText=$$getElementValueByOID^%zewdDOM(scriptOID,"textArray",1)
615 i '$d(textArray) s textArray(1)=jsText
616 QUIT scriptOID
617 ;
618javascriptObjectExists(objectName,docName)
619 ;
620 QUIT $$getJavascriptObject(objectName,docName)'=""
621 ;
622getJavascriptObject(objectName,docName,eOID) ;
623 ;
624 n c,comm,dqlvl,eArray,slcomm,language,lc,line,lineNo,lvl
625 n mlcomm,ntags,OIDArray,%p1,%p2,pos,refString,sqlvl,stop,stop2,text,textArr
626 n textArray
627 ;
628 s text="",eOID=""
629 s refString=objectName_"="
630 s ntags=$$getElementsArrayByTagName^%zewdDOM("script",docName,,.eArray)
631 s eOID="",stop=0
632 f s eOID=$o(eArray(eOID)) q:eOID="" d q:stop
633 . s language=$$getAttribute^%zewdDOM("language",eOID)
634 . q:$$zcvt^%zewdAPI(language,"l")'["javascript"
635 . k textArray
636 . s text=$$getElementValueByOID^%zewdDOM(eOID,"textArr",1)
637 . i '$d(textArr) s textArr(1)=text
638 . s lineNo="",text=""
639 . f s lineNo=$o(textArr(lineNo)) q:lineNo="" d q:stop
640 . . s stop2=0
641 . . s textArr(lineNo)=$$replaceAll^%zewdAPI(textArr(lineNo)," =","=")
642 . . i textArr(lineNo)[refString f d q:textArr(lineNo)'[refString q:stop2
643 . . . s %p1=$p(textArr(lineNo),refString,1)
644 . . . s %p1=$re(%p1)
645 . . . s %p1=$p(%p1,$c(10,13),1)
646 . . . s %p1=$re(%p1)
647 . . . i %p1["//"!(%p1["/*") d q
648 . . . . s textArr(lineNo)=$p(textArr(lineNo),refString,2,1000)
649 . . . s stop2=1
650 . . q:textArr(lineNo)'[refString
651 . . s text=refString_$p(textArr(lineNo),refString,2,1000)
652 . . s %p1=$p(text,"{",1),%p2=$p(text,"{",2,1000)
653 . . s text=%p1_"{",lvl=1,c="",dqlvl=0,sqlvl=0,slcomm=0,mlcomm=0
654 . . f pos=1:1:$l(%p2) d q:stop
655 . . . s lc=c
656 . . . s c=$e(%p2,pos)
657 . . . i lc="\",c="{" s text=text_c q
658 . . . i lc="\",c="}" s text=text_c q
659 . . . i lc="\",c="""" s text=text_c q
660 . . . i lc="\",c="'" s text=text_c q
661 . . . i lc="/",c="/" s slcomm=1,text=text_c q
662 . . . i lc="/",c="*" s mlcomm=1,text=text_c q
663 . . . i lc="*",c="/" s mlcomm=0,text=text_c q
664 . . . i slcomm,c=$c(10) s slcomm=0,text=text_c q
665 . . . i c="""",dqlvl=0,'slcomm,'mlcomm s dqlvl=1
666 . . . i c="""",dqlvl=1,'slcomm,'mlcomm s dqlvl=0
667 . . . i c="'",sqlvl=0,'slcomm,'mlcomm s sqlvl=1
668 . . . i c="'",sqlvl=1,'slcomm,'mlcomm s sqlvl=0
669 . . . i slcomm!mlcomm s text=text_c q
670 . . . i c="{",dqlvl=1 s text=text_c q
671 . . . i c="}",dqlvl=1 s text=text_c q
672 . . . i c="{",sqlvl=1 s text=text_c q
673 . . . i c="}",sqlvl=1 s text=text_c q
674 . . . i c="{" s lvl=lvl+1
675 . . . i c="}" s lvl=lvl-1 i lvl=0 s stop=1 q
676 . . . s text=text_c
677 . . s text=text_"}"
678 QUIT text
679 ;
680getJavascriptObjectBody(functionName,docName)
681 ;
682 n body,crlf,eOID,jsText,nLines
683 ;
684 s jsText=$$getJavascriptObject(functionName,docName,.eOID)
685 s crlf=$c(13,10)
686 s nLines=$l(jsText,crlf)
687 s body=$p(jsText,crlf,2,nLines-1)
688 QUIT body
689 ;
690replaceJavascriptObjectBody(functionName,newBody,docName)
691 ;
692 n body,call,crlf,eOID,jsText
693 ;
694 s jsText=$$getJavascriptObject(functionName,docName,.eOID)
695 s crlf=$c(13,10)
696 s call=$p(jsText,crlf,1)
697 s body=call_crlf_newBody_crlf_" }"
698 s ok=$$replaceJavascriptObject(functionName,body,docName)
699 QUIT 1
700 ;
701replaceJavascriptObject(objectName,newFunctionText,docName)
702 ;
703 n childOID,eOID,docOID,found,funcText,lineNo,stop,text,textArray,textOID
704 ;
705 s docOID=$$getDocumentNode^%zewdDOM(docName)
706 s found=$$getJavascriptObjectBlock(objectName,docName,.textArray)
707 i 'found QUIT 0
708 ;
709 s funcText=$$getJavascriptObject(objectName,docName,.eOID)
710 s lineNo="",stop=0
711 f s lineNo=$o(textArray(lineNo)) q:lineNo="" d q:stop
712 . s text=textArray(lineNo)
713 . i text[funcText s textArray(lineNo)=$$replace^%zewdAPI(text,funcText,newFunctionText),stop=1
714 i 'stop QUIT 0
715 f q:$$hasChildNodes^%zewdDOM(eOID)="false" d
716 . s childOID=$$getFirstChild^%zewdDOM(eOID)
717 . s childOID=$$removeChild^%zewdAPI(childOID)
718 ;
719 s lineNo=""
720 f s lineNo=$o(textArray(lineNo)) q:lineNo="" d
721 . s text=textArray(lineNo)
722 . s textOID=$$createTextNode^%zewdDOM(text,docOID)
723 . s textOID=$$appendChild^%zewdDOM(textOID,eOID)
724 QUIT 1
725 ;
726getJavascriptObjectBlock(objectName,docName,textArr) ;
727 ;
728 n eArray,eOID,language,lineNo,ntags,OIDArray,refString,stop,text,textArray
729 ;
730 s text="",eOID="" k textArr
731 s refString=objectName_"="
732 s ntags=$$getElementsArrayByTagName^%zewdDOM("script",docName,,.eArray)
733 s eOID="",stop=0
734 f s eOID=$o(eArray(eOID)) q:eOID="" d q:stop
735 . s language=$$getAttribute^%zewdDOM("language",eOID)
736 . q:$$zcvt^%zewdAPI(language,"l")'="javascript"
737 . s text=$$getElementValueByOID^%zewdDOM(eOID,"textArr",1)
738 . i '$d(textArr) s textArr(1)=text
739 . s lineNo="",text=""
740 . f s lineNo=$o(textArr(lineNo)) q:lineNo="" d q:stop
741 . . s textArr(lineNo)=$$replaceAll^%zewdAPI(textArr(lineNo)," =","=")
742 . . i textArr(lineNo)[refString s stop=1 q
743 QUIT stop
744 ;
745 ;
746createDirectory(path)
747 zsystem "mkdir "_path
748 QUIT 1
749 ;
750renameFile(filepath,newpath)
751 zsystem "mv "_filepath_" "_newpath
752 QUIT 1
753 ;
754deleteFile(filepath)
755 n status
756 d gtmDeleteFile
757 QUIT status
758 ;
759gtmDeleteFile
760 s status=1
761 o filepath:(readonly:exception="g deleteNotExists")
762 c filepath:DELETE
763 QUIT
764deleteNotExists
765 s status=0
766 QUIT
767 ;
768fileExists(path)
769 o path:(readonly:exception="g fileNotExists")
770 c path
771 QUIT 1
772fileNotExists
773 i $p($zs,",",1)=2 QUIT 0
774 QUIT 1
775 ;
776fileInfo(path,info)
777 d fileInfo^%zewdGTM(path,.info)
778 QUIT
779 ;n line,results
780 ;k info
781 ;i '$$fileExists(path) QUIT
782 ;d shellCommand^%zewdGTM("ls -l """_path_"""",.results)
783 ;s line=$g(results(1))
784 ;s info("date")=$p(line," ",6,7)
785 ;s info("size")=$p(line," ",5)
786 ;QUIT
787 ;
788directoryExists(path)
789 n line,temp
790 s temp="temp"_$p($h,",",2)_".txt"
791 zsystem "test -d "_path_" && echo ""1"">"_temp_" || echo ""0"">"_temp
792 o temp:(readonly:exception="g dirFileNotExists")
793 u temp
794 r line
795 c temp
796 s ok=$$deleteFile(temp)
797 QUIT line
798dirFileNotExists
799 i $p($zs,",",1)=2 QUIT 0
800 QUIT 0
801 ;
802fileSize(path)
803 n line,temp
804 i '$$fileExists(path) QUIT 0
805 d shellCommand^%zewdGTM("ls -s """_path_"""",.results)
806 s line=$g(results(1))
807 s line=$$stripLeadingSpaces^%zewdAPI(line)
808 s line=$p(line," ",1)
809 QUIT +line
810 ;
811displayText(textID,reviewMode,sessid)
812 ;
813 i $g(textID)="" QUIT ""
814 s reviewMode=+$g(reviewMode)
815 n text,language,phraseType,appName
816 s language=$$getSessionValue^%zewdAPI("ewd_Language",sessid)
817 i $g(language)="" d
818 . n appName
819 . s appName=$$getTextAppName^%zewdCompiler5(textID)
820 . s language=$$getDefaultLanguage^%zewdCompiler5(appName)
821 i '$d(^ewdTranslation("textid",textID)) QUIT "textid "_textID_" : text missing"
822 s text=$g(^ewdTranslation("textid",textID,language))
823 i text="" s text=$g(^ewdTranslation("textid",textID,$$getDefaultLanguage^%zewdCompiler5($$getTextAppName^%zewdCompiler5(textID))))
824 i language="xx" s text=textID_" ("_text_")"
825 i reviewMode d
826 . s text=text_" {textid="_textID_" : "_$g(^ewdTranslation("textid",textID,$$getDefaultLanguage^%zewdCompiler5($$getTextAppName^%zewdCompiler5(textID))))_"}"
827 s phraseType=$$getTextPhraseType^%zewdCompiler5(textID)
828 ;d trace^%zewdAPI("phraseType="_phraseType_" ; text="_text)
829 i phraseType'="error" d
830 . s text=$$replaceAll^%zewdAPI(text,"\'","'")
831 . s text=$$replaceAll^%zewdAPI(text,"\""","""")
832 . s text=$$replaceAll^%zewdAPI(text,"'","&#39;")
833 e d
834 . s text=$$replaceAll^%zewdAPI(text,"'",$c(5))
835 . s text=$$replaceAll^%zewdAPI(text,$c(5),"\'")
836 QUIT text
837 ;
838mergeGlobalToSession(globalName,sessionName,sessid)
839 s globalName=$$stripSpaces^%zewdAPI(globalName)
840 QUIT:$g(sessid)=""
841 QUIT:$g(sessionName)=""
842 s sessionName=$tr(sessionName,".","_")
843 i $$isTemp^%zewdAPI(sessionName) m zewdSession(sessionName)=@globalName QUIT
844 m ^%zewdSession("session",sessid,sessionName)=@globalName
845 QUIT
846 ;
847 ;
848mergeGlobalFromSession(globalName,sessionName,sessid)
849 ;
850 n x
851 ;
852 s globalName=$$stripSpaces^%zewdAPI(globalName)
853 QUIT:$g(sessid)=""
854 QUIT:$g(sessionName)=""
855 s sessionName=$tr(sessionName,".","_")
856 i $$isTemp^%zewdAPI(sessionName) s x="m "_globalName_"=zewdSession(sessionName)" x x QUIT
857 s x="m "_globalName_"=^%zewdSession(""session"",sessid,sessionName)" x x
858 QUIT
859 ;
860createCSSFile(outputPath,mode,verbose,technology) ;
861 ;
862 n filePath,label,line,lineNo,no,stop,x
863 ;
864 i $d(^zewd("config","jsScriptPath",technology,"outputPath")) d
865 . n dlim
866 . s dlim=$$getDelim^%zewdAPI()
867 . s outputPath=^zewd("config","jsScriptPath",technology,"outputPath")
868 . i $e(outputPath,$l(outputPath))'=dlim s outputPath=outputPath_dlim
869 s filePath=outputPath_"ewd.css"
870 i '$$openNewFile^%zewdCompiler(filePath) QUIT
871 u filePath
872 f label="ewdStyles" d
873 . s stop=0
874 . f lineNo=1:1 d q:stop
875 . . s x="s line=$t("_label_"+lineNo^%zewdCompiler18)"
876 . . x x
877 . . i line["***END***" s stop=1 q
878 . . i line[";;*php*",technology'="php" q
879 . . i line[";;*csp*",((technology'="csp")!(technology="wl")!(technology="gtm")) q
880 . . i line[";;*jsp*",technology'="jsp" q
881 . . i line[";;*vb.net*",technology'="vb.net" q
882 . . i line["left(up)" d
883 . . . ; left(up):-4px
884 . . . s line=$$replace^%zewdAPI(line,"(up)","")
885 . . . i mode="collapse" s line=";; left:0px;"
886 . . i line["left(down)" d
887 . . . ;; left(down):-33px ;
888 . . . s line=$$replace^%zewdAPI(line,"(down)","")
889 . . . i mode="collapse" s line=";; left:-25px;"
890 . . s line=$$replace^%zewdHTMLParser(line,"*php*"," ")
891 . . s line=$$replace^%zewdHTMLParser(line,"*csp*"," ")
892 . . s line=$$replace^%zewdHTMLParser(line,"*jsp*"," ")
893 . . s line=$$replace^%zewdHTMLParser(line,"*vb.net*"," ")
894 . . w $p(line,";;",2,250),!
895 c filePath
896 QUIT
897 ;
898spinner(nodeOID,attrValues,docOID,technology)
899 ;
900 n attr,attrName,elOID,imagePath,increment,max,min,name,onBlur
901 n onDown,onUp,onUpOrDown,size,value,width
902 ;
903 s name=$$getAttrValue^%zewdAPI("name",.attrValues,technology)
904 s name=$$removeQuotes^%zewdAPI(name)
905 i name="" s name="spinner"_$p(nodeOID,"-",2)
906 s size=$$getAttrValue^%zewdAPI("size",.attrValues,technology)
907 s size=$$removeQuotes^%zewdAPI(size)
908 i size="" s size=2
909 s width=size*8
910 s value=$$getAttrValue^%zewdAPI("value",.attrValues,technology)
911 s value=$$removeQuotes^%zewdAPI(value)
912 i value="" s value="*"
913 s max=$$getAttrValue^%zewdAPI("max",.attrValues,technology)
914 s max=$$removeQuotes^%zewdAPI(max)
915 i max="" s max="9999999999"
916 s min=$$getAttrValue^%zewdAPI("min",.attrValues,technology)
917 s min=$$removeQuotes^%zewdAPI(min)
918 i min="" s min="0"
919 s increment=$$getAttrValue^%zewdAPI("increment",.attrValues,technology)
920 s increment=$$removeQuotes^%zewdAPI(increment)
921 i increment="" s increment="100"
922 s imagePath=$$getAttrValue^%zewdAPI("imagepath",.attrValues,technology)
923 s imagePath=$$removeQuotes^%zewdAPI(imagePath)
924 s onUp=$$getAttrValue^%zewdAPI("onup",.attrValues,technology)
925 s onUp=$$removeQuotes^%zewdAPI(onUp)
926 s onDown=$$getAttrValue^%zewdAPI("ondown",.attrValues,technology)
927 s onDown=$$removeQuotes^%zewdAPI(onDown)
928 s onBlur=$$getAttrValue^%zewdAPI("onblur",.attrValues,technology)
929 s onBlur=$$removeQuotes^%zewdAPI(onBlur)
930 s onUpOrDown=$$getAttrValue^%zewdAPI("onupordown",.attrValues,technology)
931 s onUpOrDown=$$removeQuotes^%zewdAPI(onUpOrDown)
932 s attrName=""
933 f s attrName=$o(attrValues(attrName)) q:attrName="" d
934 . i "|name|size|value|max|min|increment|onup|ondown|onupordown|"[("|"_attrName_"|") q
935 . s attr(attrName)=$$removeQuotes^%zewdAPI(attrValues(attrName))
936 s attr("type")="text"
937 s attr("name")=name
938 s attr("value")=value
939 s attr("class")="ewdSpinnerText"
940 s attr("style")="width:"_width_"px"
941 s attr("onKeyDown")="EWD.page.spinnerControl(event,'"_name_"',"_min_","_max_")"
942 i onBlur="" d
943 . s attr("onBlur")="EWD.page.spinnerValueCheck(this.value,'"_name_"',"_min_","_max_")"
944 e d
945 . s attr("onBlur")=onBlur
946 s elOID=$$addElementToDOM^%zewdDOM("input",nodeOID,,.attr)
947 i onUp'="" s attr("onClick")=onUp
948 i onUpOrDown'="" d
949 . i onUp'="" s onUpOrDown=onUp_" ; "_onUpOrDown
950 . s attr("onClick")=onUpOrDown
951 s attr("type")="button"
952 s attr("name")=name_"Up"
953 s attr("tabIndex")="-1"
954 s attr("class")="ewdSpinnerButtonUp"
955 i imagePath'="" s attr("style")="background: url("_imagePath_"spinnerUp.gif) no-repeat;"
956 s attr("onMouseDown")="EWD.page.spinnerKeyDown = true ;EWD.page.incrementSpinner('"_name_"',"_max_","_increment_")"
957 s attr("onMouseUp")="EWD.page.spinnerKeyDown=false"
958 s elOID=$$addElementToDOM^%zewdDOM("input",nodeOID,,.attr)
959 i onDown'="" s attr("onClick")=onDown
960 i onUpOrDown'="" d
961 . i onDown'="" s onUpOrDown=onDown_" ; "_onUpOrDown
962 . s attr("onClick")=onUpOrDown
963 s attr("type")="button"
964 s attr("name")=name_"Down"
965 s attr("tabIndex")="-1"
966 s attr("class")="ewdSpinnerButtonDown"
967 i imagePath'="" s attr("style")="background: url("_imagePath_"spinnerDown.gif) no-repeat;"
968 s attr("onMouseDown")="EWD.page.spinnerKeyDown = true ;EWD.page.decrementSpinner('"_name_"',"_min_","_increment_")"
969 s attr("onMouseUp")="EWD.page.spinnerKeyDown=false"
970 s elOID=$$addElementToDOM^%zewdDOM("input",nodeOID,,.attr)
971 ;
972 do removeIntermediateNode^%zewdDOM(nodeOID)
973 ;
974 QUIT
975 ;
976popups(allArray,docOID,jsOID,nextPageList,urlNameList,technology)
977 ;
978 ; Process pop-up directives
979 ;
980 n attr,eh,ehx,ehy,ehz,event,found,jsName,jsParams,nextPage
981 n nodeOID,nodeType,nvp,properties,props,tagName,url,useCurrentPosition
982 n winHandle,winName
983 ;
984 ;d getAllNodes^%zewdCompiler(docOID,.allArray)
985 s nodeOID="",found=0
986 f s nodeOID=$o(allArray(0,nodeOID)) q:nodeOID="" d
987 . ;
988 . ; popup="eHelpWindow" page="sysConfigHelp" event="OnClick" x=50 y=50 height=400 width=600
989 . ; ewdOpenWindow(url,winName,x,y,height,width,toolbar,location,directories,status,menubar,scrollbars,resizable)
990 . ; toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes
991 . ;
992 . s nodeType=$$getNodeType^%zewdDOM(nodeOID)
993 . i nodeType'=1 q
994 . s winHandle=$$getAttributeValue^%zewdDOM("popup",1,nodeOID)
995 . if winHandle="" quit
996 . s winName=winHandle
997 . i winHandle["[]" d
998 . . n attr,headOID,jsOID,jsText
999 . . s winName=$$getAttributeValue^%zewdDOM("windowname",1,nodeOID)
1000 . . s jsOID=$$getTagByNameAndAttr^%zewdAPI("script","id","ewdWinNames",1,docName)
1001 . . i jsOID="" d
1002 . . . s attr("language")="javascript"
1003 . . . s attr("id")="ewdWinNames"
1004 . . . s headOID=$$getTagOID^%zewdAPI("head",docName)
1005 . . . s jsText=$p(winHandle,"[",1)_" = new Array() ;"
1006 . . . s jsOID=$$addElementToDOM^%zewdDOM("script",headOID,,.attr,jsText)
1007 . . e d
1008 . . . n refStr,textOID
1009 . . . s textOID=$$getFirstChild^%zewdDOM(jsOID)
1010 . . . s jsText=$$getData^%zewdDOM(textOID)
1011 . . . s refStr=$p(winHandle,"[",1)_" = new Array() ;"
1012 . . . i jsText'[refStr s jsText=jsText_$c(13,10)_refStr
1013 . . . s textOID=$$modifyTextData^%zewdDOM(jsText,textOID)
1014 . ;
1015 . s found=1
1016 . s event=$$zcvt^%zewdAPI($$getAttributeValue^%zewdDOM("event",1,nodeOID),"L")
1017 . i event="" set event="onclick"
1018 . s nextPage=$$getAttributeValue^%zewdDOM("page",0,nodeOID)
1019 . s props("x")=+$$getAttributeValue^%zewdDOM("x",1,nodeOID)
1020 . s props("y")=+$$getAttributeValue^%zewdDOM("y",1,nodeOID)
1021 . s useCurrentPosition=$$getAttributeValue^%zewdDOM("usecurrentposition",1,nodeOID)
1022 . i $$zcvt^%zewdAPI(useCurrentPosition,"l")="true" d
1023 . . s props("x")="EWD.utils.findPosX(this)+"_props("x")
1024 . . s props("y")="EWD.utils.findPosY(this)+"_props("y")
1025 . e d
1026 . . s props("x")="'"_props("x")_"'"
1027 . . s props("y")="'"_props("y")_"'"
1028 . s props("width")=$$getAttributeValue^%zewdDOM("width",1,nodeOID) if props("width")="" set props("width")=100
1029 . s props("height")=$$getAttributeValue^%zewdDOM("height",1,nodeOID) if props("height")="" set props("height")=100
1030 . s props("toolbar")=$$getAttributeValue^%zewdDOM("toolbar",1,nodeOID) if props("toolbar")="" set props("toolbar")="no"
1031 . s props("location")=$$getAttributeValue^%zewdDOM("location",1,nodeOID) if props("location")="" set props("location")="no"
1032 . s props("directories")=$$getAttributeValue^%zewdDOM("directories",1,nodeOID) if props("directories")="" set props("directories")="no"
1033 . s props("status")=$$getAttributeValue^%zewdDOM("status",1,nodeOID) if props("status")="" set props("status")="no"
1034 . s props("menubar")=$$getAttributeValue^%zewdDOM("menubar",1,nodeOID) if props("menubar")="" set props("menubar")="no"
1035 . s props("scrollbars")=$$getAttributeValue^%zewdDOM("scrollbars",1,nodeOID) if props("scrollbars")="" set props("scrollbars")="yes"
1036 . s props("resizable")=$$getAttributeValue^%zewdDOM("resizable",1,nodeOID) if props("resizable")="" set props("resizable")="yes"
1037 . f attr="useCurrentPosition","popup","event","page","x","y","width","height","toolbar","location","directories","status","menubar","scrollbars","resizable" do
1038 . . d removeAttribute^%zewdAPI(attr,nodeOID,1)
1039 . ;
1040 . s ehx=$$getAttributeValue^%zewdDOM(event,1,nodeOID)
1041 . s ehy=$$getAttributeValue^%zewdDOM("onclickpre",1,nodeOID)
1042 . s ehz=$$getAttributeValue^%zewdDOM("onclickpost",1,nodeOID)
1043 . d removeAttribute^%zewdAPI("onclickpre",nodeOID,1)
1044 . d removeAttribute^%zewdAPI("onclickpost",nodeOID,1)
1045 . s url=$$expandPageName^%zewdCompiler8(nextPage,.nextPageList,.urlNameList,technology,.jsParams)
1046 . ; allow popup names defined in JS reference - ie use unquoted
1047 . s winHandle=$s($e($$zcvt^%zewdAPI($tr(winHandle,"",""),"L"),1,9)="document.":winHandle,1:"'"_winHandle_"'")
1048 . s winName=$s($e($$zcvt^%zewdAPI($tr(winName,"",""),"L"),1,9)="document.":winName,1:"'"_winName_"'")
1049 . set eh="EWD.page.openWindow('"_url_"',"_winHandle_","_winName
1050 . for attr="x","y","height","width","toolbar","location","directories","status","menubar","scrollbars","resizable" do
1051 . . i attr'="x",attr'="y" d
1052 . . . set eh=eh_",'"_props(attr)_"'"
1053 . . e d
1054 . . . set eh=eh_","_props(attr)
1055 . set jsName=""
1056 . for set jsName=$order(jsParams(jsName)) quit:jsName="" do
1057 . . set eh=eh_","_jsParams(jsName)
1058 . set eh=eh_")"
1059 . if ehx'="" set eh=eh_" ; "_ehx
1060 . if ehz'="" set eh=eh_" ; "_ehz
1061 . if ehy'="" set eh=ehy_" ; "_eh
1062 . do setAttribute^%zewdDOM(event,eh,nodeOID)
1063 ;
1064 QUIT
1065 ;
1066addServerToSession(sessid,serverArray)
1067 QUIT:$g(sessid)=""
1068 ;
1069 k ^%zewdSession("session",sessid,"ewd_Server")
1070 m ^%zewdSession("session",sessid,"ewd_Server")=serverArray
1071 d setWLDSymbol^%zewdAPI("ewd_Server",sessid)
1072 QUIT
1073 ;
1074displayTextArea(fieldName)
1075 n lineNo,text,lastLineNo
1076 ;
1077 s fieldName=$tr(fieldName,".","_")
1078 d
1079 . s lastLineNo=$o(^%zewdSession("session",sessid,"ewd_textarea",fieldName,""),-1)
1080 . s lineNo=0
1081 . f s lineNo=$o(^%zewdSession("session",sessid,"ewd_textarea",fieldName,lineNo)) q:lineNo="" d
1082 . . k text
1083 . . s text=^%zewdSession("session",sessid,"ewd_textarea",fieldName,lineNo)
1084 . . s text=$$replaceAll^%zewdHTMLParser(text,"&#39;","'")
1085 . . w $$zcvt^%zewdAPI(text,"o","HTML")
1086 . . i lineNo'=lastLineNo w $c(13,10)
1087 QUIT
1088 ;
1089isNextPageTokenValid(token,sessid,page)
1090 ;
1091 n allowedFrom,expectedPage,fromPage
1092 ;
1093 s expectedPage=$p($g(^%zewdSession("nextPageTokens",sessid,token)),"~",1)
1094 ;s allowedFrom=$p($g(^%zewdSession("nextPageTokens",sessid,token)),"~",2)
1095 i expectedPage="" QUIT 0
1096 ;d trace^%zewdAPI("token="_token_" ; allowedFrom="_allowedFrom_" ; actual from page="_fromPage)
1097 ;i allowedFrom'=fromPage QUIT 0
1098 i page[".php" d
1099 . s page=$p(page,"/",$l(page,"/"))
1100 . s page=$p(page,".php",1)
1101 QUIT $$zcvt^%zewdAPI(expectedPage,"L")=$$zcvt^%zewdAPI(page,"L")
1102 ;
1103existsInSessionArray(name,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11)
1104 ;
1105 n exists,i,nparams,param,ref,sessid,stop,technology,value
1106 ;
1107 s stop=0
1108 f i=11:-1:1 d q:stop
1109 . s param="p"_i
1110 . i $g(@param)'="" s stop=1
1111 s sessid=@("p"_i)
1112 s technology=$$getSessionValue^%zewdAPI("ewd_technology",sessid)
1113 s nparams=i-1
1114 s name=$tr($g(name),".","_")
1115 i $$isTemp^%zewdAPI(name) d
1116 . s ref="s exists=$d(zewdSession("""_name_""""
1117 . s ref="s exists=$d(sessionArray("""_name_""""
1118 e s ref="s exists=$d(^%zewdSession(""session"","""_sessid_""","""_name_""""
1119 i nparams>0 d
1120 . f i=1:1:nparams s ref=ref_","""_$g(@("p"_i))_""""
1121 s ref=ref_"))"
1122 ;d trace^%zewdAPI("ref="_$g(ref))
1123 x ref
1124 ;d trace^%zewdAPI("ref="_ref_" ; exists="_exists)
1125 QUIT exists
1126 ;
1127getSchemaFormErrors(errorArray,sessid)
1128 ;
1129 n error,num
1130 ;
1131 k errorArray
1132 d mergeArrayFromSession^%zewdAPI(.errorArray,"ewd_SchemaFormError",sessid)
1133 s error=""
1134 s num=""
1135 f s num=$o(errorArray("list",num)) q:num="" d
1136 . s error=error_errorArray("list",num)_$c(13,10)
1137 QUIT error
1138 ;
1139existsInSession(name,sessid)
1140 n result,technology
1141 ;
1142 s name=$$stripSpaces^%zewdAPI(name)
1143 i $g(name)="" QUIT 0
1144 s name=$tr(name,".","_")
1145 i $g(sessid)="" QUIT 0
1146 s technology=$$getSessionValue^%zewdAPI("ewd_technology",sessid)
1147 i $$isTemp^%zewdAPI(name) QUIT $d(sessionArray(name))
1148 QUIT $d(^%zewdSession("session",sessid,name))
1149 ;
1150encodeDataType(name,dataType,sessid)
1151 ;
1152 n value,outputMethod,x,encodedValue,Error
1153 ;
1154 i $g(name)="" QUIT "Data Type encoding attempted but field name was not specified"
1155 i $g(dataType)="" QUIT "Data Type encoding attempted for the "_name_" field, but no data type was defined"
1156 s value=$$getSessionValue^%zewdAPI(name,sessid)
1157 s outputMethod=$$getOutputMethod^%zewdCompiler(dataType)
1158 i outputMethod="" QUIT ""
1159 s x="s encodedValue=$$"_outputMethod_"("""_value_""",.Error,sessid)"
1160 x x
1161 i $g(Error)="" d setSessionValue^%zewdAPI(name,encodedValue,sessid)
1162 ;i Error'="" s Error=name_" : "_Error
1163 QUIT Error
1164 ;
Note: See TracBrowser for help on using the repository browser.