[system] / trunk / pg / lib / Applet.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Applet.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5594 Revision 5619
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/lib/Applet.pm,v 1.3 2007/11/06 16:47:19 gage Exp $ 4# $CVSHeader: pg/lib/Applet.pm,v 1.4 2007/12/20 00:04:39 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
35 ################################### 35 ###################################
36 # Configure applet 36 # Configure applet
37 ################################### 37 ###################################
38 38
39 #xml data to set up the problem-rac 39 #xml data to set up the problem-rac
40 $applet->xmlString(qq{<XML> 40 $applet->state(qq{<XML>
41 <point xval='$xval_1' yval='$yval_1' /> 41 <point xval='$xval_1' yval='$yval_1' />
42 <point xval='$xval_2' yval='$yval_2' /> 42 <point xval='$xval_2' yval='$yval_2' />
43 </XML>}); 43 </XML>});
44 44
45 45
75 75
76(not yet completed) 76(not yet completed)
77 77
78The module JavaApplet has defaults for inserting java applets. 78The module JavaApplet has defaults for inserting java applets.
79 79
80The module Applet will store common code for the two types of applet. 80The module Applet stores common code for the two types of applet.
81 81
82=head1 USAGE 82=head1 USAGE
83 83
84This file is included by listing it in the modules section of global.conf. 84These modules are activate by listing it in the modules section of global.conf and rebooting the server.
85The companion file to this one is macros/AppletObjects.pl
86
87qw(Applet FlashApplet JavaApplet)
85 88
86=cut 89=cut
87 90
88 91
89 92
90package Applet; 93package Applet;
91 94
92 95
93package FlashApplet; 96
94 97
95 98
96use MIME::Base64 qw( encode_base64 decode_base64); 99use MIME::Base64 qw( encode_base64 decode_base64);
97 100
98 101
99=head2 Default javaScript functions placed in header 102=head2 Default javaScript functions placed in header
100 103
101These functions are automatically defined for use for 104These functions are automatically defined for use for
102any javaScript placed in the text of a PG question. 105any javaScript placed in the text of a PG question.
103 106
104 getFlashMovie(appletName) -- finds the applet path in the DOM 107 getApplet(appletName) -- finds the applet path in the DOM
105 108
106 submitAction() -- calls the submit action of the applet 109 submitAction() -- calls the submit action of the applets
107 -- the submitAction is defined 110
108 111
109 initialize() -- calls the initialize action of the applet 112 initializeAction() -- calls the initialize action of the applets
110 113
111 getQE(name) -- gets an HTML element of the question by name 114 getQE(name) -- gets an HTML element of the question by name
112 or by id. Be sure to keep all names and ids 115 or by id. Be sure to keep all names and ids
113 unique within a given PG question. 116 unique within a given PG question.
114 117
121 just before END_DOCUMENT(): 124 just before END_DOCUMENT():
122 125
123 TEXT(qq!<script> listQuestionElements() </script>!); 126 TEXT(qq!<script> listQuestionElements() </script>!);
124 ENDDOCUMENT(); 127 ENDDOCUMENT();
125 128
129 list of accessor methods format: current_value = $self->method(new_value or empty)
130
131 appletId for simplicity and reliability appletId and appletName are always the same
132 appletName
133
134 archive the name of the .jar file containing the applet code
135 code the name of the applet code in the .jar archive
136 codebase a prefix url used to find the archive and the applet itself
137
138 height rectangle alloted in the html page for displaying the applet
139 width
140
141 params an anonymous array containing name/value pairs
142 to configure the applet [name =>'value, ...]
143
144 header stores the text to be added to the header section of the html page
145 object stores the text which places the applet on the html page
146
147 debug in debug mode several alerts mark progress through the procedure of calling the applet
148
149 config configuration are those customizable attributes of the applet which don't
150 change as it is used. When stored in hidden answer fields
151 it is usually stored in base64 encoded format.
152 base64_config base64 encode version of the contents of config
153
154 configAlias (default: config ) names the applet command called with the contents of $self->config
155 to configure the applet. The parameters are passed to the applet in plain text using <xml>
156 The outer tags must be <xml> ..... </xml>
157 state state consists of those customizable attributes of the applet which change
158 as the applet is used. It is stored by the calling .pg question so that
159 when revisiting the question the applet
160 will be restored to the same state it was left in when the question was last
161 viewed.
162
163 getStateAlias (default: getState) alias for command called to read the current state of the applet.
164 The state is passed in plain text xml format with outer tags: <xml>....</xml>
165 setStateAlias (default: setState) alias for the command called to reset the state of the applet.
166 The state is passed in plain text in xml format with outer tags: <xml>....</xml>
167
168 base64_state returns the base64 encoded version of the state stored in the applet object.
169
170 initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState
171 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the
172 .pg question is pressed.
173
174 returnFieldName
175
176
177
178
126 179
127=cut 180=cut
128 181
129 182
183
184
185sub new {
186 my $class = shift;
187 my $self = {
188 appletName =>'',
189 code=>'',
190 codebase=>'',
191# appletId =>'', #always use identical applet Id's and applet Names
192 params =>undef,
193 width => 550,
194 height => 400,
195 base64_state => '',
196 base64_config => '',
197 getStateAlias => 'getXML',
198 setStateAlias => 'setState',
199 configAlias => 'config',
200 initializeActionAlias => 'setXML',
201 submitActionAlias => 'getXML',
202 returnFieldName => 'receivedField',
203 headerText => DEFAULT_HEADER_TEXT(),
204 objectText => '',
205 debug => 0,
206 @_,
207 };
208 bless $self, $class;
209 return $self;
210}
211
212sub header {
213 my $self = shift;
214 if ($_[0] eq "reset") { # $applet->header('reset'); erases default header text.
215 $self->{headerText}='';
216 } else {
217 $self->{headerText} .= join("",@_); # $applet->header(new_text); concatenates new_text to existing header.
218 }
219 $self->{headerText};
220}
221sub object {
222 my $self = shift;
223 if ($_[0] eq "reset") {
224 $self->{objectText}='';
225 } else {
226 $self->{objectText} .= join("",@_);
227 }
228 $self->{objectText};
229}
230sub params {
231 my $self = shift;
232 if (ref($_[0]) =~/HASH/) {
233 $self->{params} = shift;
234 } elsif ( !defined($_[0]) or $_[0] =~ '') {
235 # do nothing (read)
236 } else {
237 warn "You must enter a reference to a hash for the parameter list";
238 }
239 $self->{params};
240}
241
242sub initializeActionAlias {
243 my $self = shift;
244 $self->{initializeActionAlias} = shift ||$self->{initializeActionAlias}; # replace the current contents if non-empty
245 $self->{initializeActionAlias};
246}
247
248sub submitActionAlias {
249 my $self = shift;
250 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
251 $self->{submitActionAlias};
252}
253sub getStateAlias {
254 my $self = shift;
255 $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty
256 $self->{getStateAlias};
257}
258
259sub setStateAlias {
260 my $self = shift;
261 $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
262 $self->{setStateAlias};
263}
264sub configAlias {
265 my $self = shift;
266 $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty
267 $self->{configAlias};
268}
269sub returnFieldName {
270 my $self = shift;
271 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty
272 $self->{returnFieldName};
273}
274sub codebase {
275 my $self = shift;
276 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
277 $self->{codebase};
278}
279sub code {
280 my $self = shift;
281 $self->{code} = shift ||$self->{code}; # replace the current code if non-empty
282 $self->{code};
283}
284sub height {
285 my $self = shift;
286 $self->{height} = shift ||$self->{height}; # replace the current height if non-empty
287 $self->{height};
288}
289sub width {
290 my $self = shift;
291 $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
292 $self->{width};
293}
294sub archive {
295 my $self = shift;
296 $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
297 $self->{archive};
298}
299sub appletName {
300 my $self = shift;
301 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
302 $self->{appletName};
303}
304sub debug {
305 my $self = shift;
306 my $new_flag = shift;
307 $self->{debug} = $new_flag if defined($new_flag);
308 $self->{debug};
309}
310sub appletId {
311 appletName(@_);
312}
313sub state {
314 my $self = shift;
315 my $str = shift;
316 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
317 $self->{base64_state} =~ s/\n//g;
318 decode_base64($self->{base64_state});
319}
320
321sub base64_state{
322 my $self = shift;
323 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
324 $self->{base64_state};
325}
326sub config {
327 my $self = shift;
328 my $str = shift;
329 $self->{base64_config} = encode_base64($str) || $self->{base64_config}; # replace the current string if non-empty
330 $self->{base64_config} =~ s/\n//g;
331 decode_base64($self->{base64_config});
332}
333sub base64_config {
334 my $self = shift;
335 $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
336 $self->{base64_config} =$self->{base64_config};
337 $self->{base64_config};
338}
339#FIXME
340# need to be able to adjust header material
341
342sub insertHeader {
343 my $self = shift;
344 my $codebase = $self->codebase;
345 my $appletId = $self->appletId;
346 my $appletName = $self->appletName;
347 my $base64_initialState = $self->base64_state;
348 my $initializeAction = $self->initializeActionAlias;
349 my $submitAction = $self->submitActionAlias;
350 my $setState = $self->setStateAlias;
351 my $getState = $self->getStateAlias;
352 my $config = $self->configAlias;
353 my $base64_config = $self->base64_config;
354 my $debugMode = ($self->debug) ? "1": "0";
355 my $returnFieldName = $self->{returnFieldName};
356# my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used.
357# my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present
358 my $headerText = $self->header();
359 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
360
361 return $headerText;
362
363
364}
365
366sub insertObject {
367 my $self = shift;
368 my $code = $self->{code};
369 my $codebase = $self->{codebase};
370 my $appletId = $self->{appletName};
371 my $appletName = $self->{appletName};
372 my $archive = $self->{archive};
373 my $width = $self->{width};
374 my $height = $self->{height};
375 my $parameters = '';
376 my $parameters = '';
377 my %param_hash = %{$self->params()};
378 foreach my $key (keys %param_hash) {
379 $parameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!
380 }
381
382 $objectText = $self->{objectText};
383 $objectText =~ s/(\$\w+)/$1/gee;
384 return $objectText;
385}
386sub initialize {
387 my $self = shift;
388 return q{
389 <script>
390 initializeAction();
391 // this should really be done in the <body> tag
392 </script>
393 };
394
395}
396
397
130use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT'; 398use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
131 <script language="javascript">AC_FL_RunContent = 0;</script> 399
132 <script src="http://hosted2.webwork.rochester.edu/webwork2_files/applets/AC_RunActiveContent.js" language="javascript">
133 </script>
134
135
136 <script language="JavaScript"> 400 <script language="JavaScript">
401 var debug = $debugMode;
402 //
403 //CONFIGURATIONS
404 //
405 // configurations are "permanent"
406 applet_config_list["$appletName"] = function() {
407 if (debug) { alert("configure $appletName . $config ( $base64_config )");}
408 try {
409 if (debug || !( typeof(getApplet("$appletName").$config) == "undefined" ) ) {
410
411 getApplet("$appletName").$config(Base64.decode("$base64_config"));
412 }
413 } catch(e) {
414 alert("error executing configuration command $config for $appletName: " + e );
415 }
416 }
417 //
418 //STATE
419 //
420 // state can vary as the applet is manipulated.
421 applet_setState_list["$appletName"] = function(state) {
422 state = state || getQE("$appletName"+"_state").value || "<xml></xml>";
423 if ( base64Q(state) ) { state=Base64.decode(state);}
424 if (debug) { alert("set state for $appletName to " + state);}
425 try {
426 if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) {
427 getApplet("$appletName").$setState( state );
428 }
429 } catch(e) {
430 alert("Error in setting state of $appletName: " + e );
431 }
432 };
433 applet_getState_list["$appletName"] = function () {
434 if (debug) { alert("getState for applet $appletName");}
435 try {
436 var applet = getApplet("$appletName");
437 var state;
438 if (!( typeof(getApplet("$appletName").$getState) =="undefined" ) ) {
439 state = applet.$getState(); // get state in xml format
440 }
441 if (!debug) {state = Base64.encode(state) }; // replace state by encoded version
442 getQE("$appletName"+"_state").value = state; //place in state htmlItem (debug: textarea, otherwise hidden)
443 } catch (e) {
444 alert("Error in getting state for $appletName " + e );
445 }
446 };
447 //
448 //INITIALIZE
449 //
450 applet_initializeAction_list["$appletName"] = function () {
451 applet_setState_list["$appletName"]();
452 };
137 453
138 var flash; 454 applet_submitAction_list["$appletName"] = function () {
139 function getFlashMovie(appletName) { 455 applet_getState_list["$appletName"]();
140 var isIE = navigator.appName.indexOf("Microsoft") != -1;
141 var obj = (isIE) ? window[appletName] : window.document[appletName];
142 //return window.document[appletName];
143 if (obj.name = appletName) {
144 return( obj );
145 } else {
146 alert ("can't find applet " + appletName);
147 }
148 }
149
150 function submitAction() {
151 getQE("$returnFieldName").value = getFlashMovie("$appletId").$submitAction(); 456 getQE("$returnFieldName").value = getApplet("$appletName").sendData();
152 }
153 function initialize() {
154 getFlashMovie("$appletId").$initializeAction("$base64_xmlString");
155 }
156 function getQE(name1) { // get Question Element in problemMainForm by name
157 var isIE = navigator.appName.indexOf("Microsoft") != -1;
158 var obj = (isIE) ? document.getElementById(name1)
159 :document.problemMainForm[name1];
160 // needed for IE -- searches id and name space so it can be unreliable if names are not unique
161 if (obj.name = name1 ) {
162 return( obj );
163 } else {
164 alert("Can't find " + name1);
165 listQuestionElements();
166 }
167
168 } 457 };
169 function getQuestionElement(name1) {
170 return getQE(name1);
171 }
172
173 function listQuestionElements() { // list all HTML elements in main problem form
174 var isIE = navigator.appName.indexOf("Microsoft") != -1;
175 var mainForm = (isIE) ? document.getElementsByTagName("input") : document.getElementsByTagName("input");
176 var str=mainForm.length +" Question Elements\n type | name = value < id > \n";
177 for( var i=0; i< mainForm.length; i++) {
178 str = str + " "+i+" " + mainForm[i].type
179 + " | " + mainForm[i].name
180 + "= " + mainForm[i].value +
181 " <" + mainForm[i].id + ">\n";
182 }
183 alert(str +"\n Place listQuestionElements() at end of document in order to get all form elements!");
184 }
185
186
187 </script> 458 </script>
188 459
189END_HEADER_SCRIPT 460END_HEADER_SCRIPT
190 461
462package FlashApplet;
463@ISA = qw(Applet);
191 464
192# <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" 465
193# width="550" height="400" id="$appletId" align="middle">
194# <param name="allowScriptAccess" value="sameDomain" />
195# <param name="allowFullScreen" value="false" />
196# <param name="movie" value="$appletName.swf" />
197# <param name="quality" value="high" />
198# <param name="bgcolor" value="#ffffcc" />
199# <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#ffffcc" width="550" height="400" name="$appletName"
200# align="middle" id="$appletId",
201# align="middle" allowScriptAccess="sameDomain"
202# allowFullScreen="false"
203# type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
204# <param name="quality" value="high" /><param name="bgcolor" value="#ffffcc" />
205# </object>
206 466
207=pod 467=pod
208 468
209The secret to making this applet work with IE in addition to normal browsers 469The secret to making this applet work with IE in addition to normal browsers
210is the addition of the C(<form></form>) construct just before the object. 470is the addition of the C(<form></form>) construct just before the object.
216This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2) 476This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
217Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated: 477Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
218http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js 478http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
219http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933 479http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
220 480
221 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT'; 481 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
222 <form></form> 482 <form></form>
223 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 483 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
224 id="$appletName" width="500" height="375" 484 id="$appletName" width="500" height="375"
225 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> 485 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
226 <param name="movie" value="$codebase/$appletName.swf" /> 486 <param name="movie" value="$codebase/$appletName.swf" />
227 <param name="quality" value="high" /> 487 <param name="quality" value="high" />
228 <param name="bgcolor" value="#869ca7" /> 488 <param name="bgcolor" value="#869ca7" />
229 <param name="allowScriptAccess" value="sameDomain" /> 489 <param name="allowScriptAccess" value="sameDomain" />
230 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7" 490 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
231 width="550" height="400" name="$appletName" align="middle" id="$appletID" 491 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
232 play="true" loop="false" quality="high" allowScriptAccess="sameDomain" 492 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
233 type="application/x-shockwave-flash" 493 type="application/x-shockwave-flash"
234 pluginspage="http://www.macromedia.com/go/getflashplayer"> 494 pluginspage="http://www.macromedia.com/go/getflashplayer">
235 </embed> 495 </embed>
236 496
237 </object> 497 </object>
238 END_OBJECT_TEXT 498 END_OBJECT_TEXT
499
239 500
240=cut 501=cut
241 502
242use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT'; 503use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
243 <form></form> 504 <form></form>
247 <param name="movie" value="$codebase/$appletName.swf" /> 508 <param name="movie" value="$codebase/$appletName.swf" />
248 <param name="quality" value="high" /> 509 <param name="quality" value="high" />
249 <param name="bgcolor" value="#869ca7" /> 510 <param name="bgcolor" value="#869ca7" />
250 <param name="allowScriptAccess" value="sameDomain" /> 511 <param name="allowScriptAccess" value="sameDomain" />
251 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7" 512 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
252 width="550" height="400" name="$appletName" align="middle" id="$appletID" 513 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
253 play="true" loop="false" quality="high" allowScriptAccess="sameDomain" 514 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
254 type="application/x-shockwave-flash" 515 type="application/x-shockwave-flash"
255 pluginspage="http://www.macromedia.com/go/getflashplayer"> 516 pluginspage="http://www.macromedia.com/go/getflashplayer">
256 </embed> 517 </embed>
257 518
258 </object> 519 </object>
259END_OBJECT_TEXT 520END_OBJECT_TEXT
260 521
261
262sub new { 522sub new {
263 my $class = shift; 523 my $class = shift;
264 my $self = {
265 host =>'',
266 port => '',
267 path => '',
268 appletName =>'',
269 codebase=>'',
270 appletId =>'',
271 params =>undef,
272 base64_xmlString => 'foobar',
273 initializeActionAlias => 'setupProblem',
274 submitActionAlias => 'checkAnswer',
275 returnFieldName => 'receivedField',
276 headerText => DEFAULT_HEADER_TEXT(),
277 objectText => DEFAULT_OBJECT_TEXT(), 524 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
278 @_, 525 @_
279 }; 526 );
280 bless $self, $class;
281 #$self -> _initialize(@_);
282 return $self;
283}
284 527
285sub header {
286 my $self = shift;
287 if ($_[0] eq "reset") { # $applet->header('reset'); erases default header text.
288 $self->{headerText}='';
289 } else {
290 $self->{headerText} .= join("",@_); # $applet->header(new_text); concatenates new_text to existing header.
291 }
292 $self->{headerText};
293} 528}
294sub object {
295 my $self = shift;
296 if ($_[0] eq "reset") {
297 $self->{objectText}='';
298 } else {
299 $self->{objectText} .= join("",@_);
300 }
301 $self->{objectText};
302}
303sub params {
304 my $self = shift;
305 if (ref($_[0]) =~/HASH/) {
306 $self->{params} = shift;
307 } elsif ( $_[0] =~ '') {
308 # do nothing (read)
309 } else {
310 warn "You must enter a reference to a hash for the parameter list";
311 }
312 $self->{params};
313}
314
315sub initializeActionAlias {
316 my $self = shift;
317 $self->{initializeActionAlias} = shift ||$self->{initializeActionAlias}; # replace the current contents if non-empty
318 $self->{initializeActionAlias};
319}
320 529
321sub submitActionAlias {
322 my $self = shift;
323 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
324 $self->{submitActionAlias};
325}
326sub returnFieldName {
327 my $self = shift;
328 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty
329 $self->{returnFieldName};
330}
331sub codebase {
332 my $self = shift;
333 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
334 $self->{codebase};
335}
336sub appletName {
337 my $self = shift;
338 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
339 $self->{appletName};
340}
341sub appletId {
342 my $self = shift;
343 $self->{appletId} = shift ||$self->{appletId}; # replace the current appletName if non-empty
344 $self->{appletId};
345}
346sub xmlString {
347 my $self = shift;
348 my $str = shift;
349 $self->{base64_xmlString} = encode_base64($str) ||$self->{base64_xmlString}; # replace the current string if non-empty
350 $self->{base64_xmlString} =~ s/\n//g;
351 decode_base64($self->{base64_xmlString});
352}
353 530
354sub base64_xmlString{ 531package JavaApplet;
355 my $self = shift; 532@ISA = qw(Applet);
356 $self->{base64_xmlString} = shift ||$self->{base64_xmlString}; # replace the current string if non-empty
357 $self->{base64_xmlString};
358}
359 533
360#FIXME
361# need to be able to adjust header material
362 534
363sub insertHeader { 535
536=pod
537
538The secret to making this applet work with IE in addition to normal browsers
539is the addition of the C(<form></form>) construct just before the object.
540
541For some reason IE has trouble locating a flash object which is contained
542within a form. Adding this second blank form with the larger problemMainForm
543seems to solve the problem.
544
545This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
546Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
547http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
548http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
549
550 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
551 <form></form>
552 <applet
553 code = "$code"
554 codebase = "$codebase"
555 archive = "$archive"
556 name = "$appletName"
557 id = "$appletName"
558 width = "$width"
559 height = "$height"
560 MAYSCRIPT
561 >
562 $parameters
563 </applet>
564 END_OBJECT_TEXT
565
566=cut
567
568use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
569 <form></form>
570 <applet
571 code = "$code"
572 codebase = "$codebase"
573 archive = "$archive"
574 name = "$appletName"
575 id = "$appletName"
576 width = "$width"
577 height = "$height"
578 MAYSCRIPT
579 >
580 $parameters
581 </applet>
582END_OBJECT_TEXT
583
584sub new {
364 my $self = shift; 585 my $class = shift;
365 my $codebase = $self->{codebase}; 586 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
366 my $appletId = $self->{appletId}; 587 @_
367 my $appletName = $self->{appletName}; 588 );
368 my $base64_xmlString = $self->{base64_xmlString};
369 my $initializeAction = $self->{initializeActionAlias};
370 my $submitAction = $self->{submitActionAlias};
371 my $returnFieldName= $self->{returnFieldName};
372 my $headerText = $self->header();
373 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
374
375 return $headerText;
376 589
377
378} 590}
379 591
380 592
381# <script language="javascript">
382# if (AC_FL_RunContent == 0) {
383# alert("This page requires AC_RunActiveContent.js.");
384# } else {
385# AC_FL_RunContent(
386# 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
387# 'width', '100%',
388# 'height', '100%',
389# 'src', 'http://$codebase/$appletName',
390# 'quality', 'high',
391# 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
392# 'align', 'middle',
393# 'play', 'true',
394# 'loop', 'true',
395# 'scale', 'showall',
396# 'wmode', 'window',
397# 'devicefont', 'false',
398# 'id', '$appletId',
399# 'bgcolor', '#ffffcc',
400# 'name', '$appletName',
401# 'menu', 'true',
402# 'allowFullScreen', 'false',
403# 'allowScriptAccess','sameDomain',
404# 'movie', '$appletName',
405# 'salign', ''
406# ); //end AC code
407# }
408# </script>
409sub insertObject {
410 my $self = shift;
411 my $codebase = $self->{codebase};
412 my $appletId = $self->{appletId};
413 my $appletName = $self->{appletName};
414 $codebase = findAppletCodebase("$appletName.swf") unless $codebase;
415 $objectText = $self->{objectText};
416 $objectText =~ s/(\$\w+)/$1/gee;
417 return $objectText;
418}
419
420sub initialize {
421 my $self = shift;
422 return q{
423 <script>
424 initialize();
425 // this should really be done in the <body> tag
426 </script>
427 };
428
429}
430 593
4311; 5941;

Legend:
Removed from v.5594  
changed lines
  Added in v.5619

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9