[system] / trunk / xmlrpc / modules / WWd.pm Repository:
ViewVC logotype

Diff of /trunk/xmlrpc/modules/WWd.pm

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

Revision 314 Revision 315
21 return( Webwork::listLib($in) ); 21 return( Webwork::listLib($in) );
22} 22}
23sub renderProblem { 23sub renderProblem {
24 shift if UNIVERSAL::isa($_[0] => __PACKAGE__); 24 shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
25 my $in = shift; 25 my $in = shift;
26 return( Webwork::renderProblem($in) ); 26 return( Filter::filterObject( Webwork::renderProblem($in) ) );
27} 27}
28sub readFile { 28sub readFile {
29 shift if UNIVERSAL::isa($_[0] => __PACKAGE__); 29 shift if UNIVERSAL::isa($_[0] => __PACKAGE__);
30 my $in = shift; 30 my $in = shift;
31 return( Webwork::readFile($in) ); 31 return( Webwork::readFile($in) );
83 #return "<!-- \r\n" . $in . "\r\n-->\r\n\r\n" . $out . "\r\n\r\n"; 83 #return "<!-- \r\n" . $in . "\r\n-->\r\n\r\n" . $out . "\r\n\r\n";
84 return $out; 84 return $out;
85 85
86} 86}
87 87
88package Filter;
89
90
91
92
93
94
95
96
97
98
99sub is_hash_ref {
100 my $in =shift;
101 my $save_SIG_die_trap = $SIG{__DIE__};
102 $SIG{__DIE__} = sub {CORE::die(@_) };
103 my $out = eval{ %{ $in } };
104 $out = ($@ eq '') ? 1 : 0;
105 $@='';
106 $SIG{__DIE__} = $save_SIG_die_trap;
107 $out;
108}
109sub is_array_ref {
110 my $in =shift;
111 my $save_SIG_die_trap = $SIG{__DIE__};
112 $SIG{__DIE__} = sub {CORE::die(@_) };
113 my $out = eval{ @{ $in } };
114 $out = ($@ eq '') ? 1 : 0;
115 $@='';
116 $SIG{__DIE__} = $save_SIG_die_trap;
117 $out;
118}
119sub filterObject {
120
121 my $is_hash = 0;
122 my $is_array =0;
123 $obj = shift;
124 #print "Enter filterObject ", ref($obj), "\n";
125 my $type = ref($obj);
126 unless ($type) {
127 #print "leave filterObject with nothing\n";
128 return($obj);
129 }
130
131
132 if ( is_hash_ref($obj) ) {
133 #print "enter hash ", %{$obj},"\n";
134 my %obj_container= %{$obj};
135 foreach my $key (keys %obj_container) {
136 $obj_container{$key} = filterObject( $obj_container{$key} );
137 #print $key, " ", ref($obj_container{$key})," ", $obj_container{$key}, "\n";
138 }
139 #print "leave filterObject with HASH\n";
140 return( bless(\%obj_container,'HASH'));
141 };
142
143
144
145 if ( is_array_ref($obj) ) {
146 #print "enter array ( ", @{$obj}," )\n";
147 my @obj_container= @{$obj};
148 foreach $i (0..$#obj_container) {
149 $obj_container[$i] = filterObject( $obj_container[$i] );
150 #print "\[$i\] ", ref($obj_container[$i])," ", $obj_container[$i], "\n";
151 }
152 #print "leave filterObject with ARRAY\n";
153 return( bless(\@obj_container,'ARRAY'));
154 };
155
156}
88 157
89 158
901; 1591;
91 160
92 161

Legend:
Removed from v.314  
changed lines
  Added in v.315

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9