[system] / trunk / webwork2 / lib / WeBWorK / ContentGenerator.pm Repository:
ViewVC logotype

Diff of /trunk/webwork2/lib/WeBWorK/ContentGenerator.pm

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

Revision 1016 Revision 1017
16use Apache::Constants qw(:common); 16use Apache::Constants qw(:common);
17use CGI qw(); 17use CGI qw();
18use URI::Escape; 18use URI::Escape;
19use WeBWorK::DB; 19use WeBWorK::DB;
20use WeBWorK::Utils qw(readFile); 20use WeBWorK::Utils qw(readFile);
21use WeBWorK::Authz;
21 22
22################################################################################ 23################################################################################
23# This is a very unruly file, so I'm going to use very large comments to divide 24# This is a very unruly file, so I'm going to use very large comments to divide
24# it into logical sections. 25# it into logical sections.
25################################################################################ 26################################################################################
38 my $class = ref($invocant) || $invocant; 39 my $class = ref($invocant) || $invocant;
39 my $self = { 40 my $self = {
40 r => $r, 41 r => $r,
41 ce => $ce, 42 ce => $ce,
42 db => $db, 43 db => $db,
44 authz => WeBWorK::Authz->new($r, $ce, $db)
43 }; 45 };
44 bless $self, $class; 46 bless $self, $class;
45 return $self; 47 return $self;
46} 48}
47 49
123 $ifstack[-1] = not $ifstack[-1]; 125 $ifstack[-1] = not $ifstack[-1];
124 } elsif ($function eq "endif" and @ifstack > 1) { 126 } elsif ($function eq "endif" and @ifstack > 1) {
125 pop @ifstack; 127 pop @ifstack;
126 } elsif ($ifstack[-1]) { 128 } elsif ($ifstack[-1]) {
127 if ($self->can($function)) { 129 if ($self->can($function)) {
128 print $self->$function(@_, {@args}); 130 my $result = $self->$function(@_, {@args});
131 unless (defined $result) {
132 warn "Template escape $function returned an undefined value.";
133 }
134 print $result;
129 } 135 }
130 } 136 }
131 } 137 }
132 138
133 if ($ifstack[-1]) { 139 if ($ifstack[-1]) {
456 CGI::a({-href=>$help}, "Help"). CGI::br(). 462 CGI::a({-href=>$help}, "Help"). CGI::br().
457 CGI::a({-href=>$logout}, "Log Out"). CGI::br() 463 CGI::a({-href=>$logout}, "Log Out"). CGI::br()
458 ; 464 ;
459} 465}
460 466
467sub submiterror {
468 warn "submiterror\n";
469 my ($self) = @_;
470 if (exists $self->{submitError}) {
471 warn "returning ".$self->{submitError}."\n";
472 return $self->{submitError};
473 } else {
474 warn "returning \"\"\n";
475 return "";
476 }
477}
478
461# &if_can will return 1 if the current object->can("do $_[1]") 479# &if_can will return 1 if the current object->can("do $_[1]")
462sub if_can ($$) { 480sub if_can ($$) {
463 my ($self, $arg) = (@_); 481 my ($self, $arg) = (@_);
464 482
465 if ($self->can("$arg")) { 483 if ($self->can("$arg")) {
474 my ($self, $arg) = (@_); 492 my ($self, $arg) = (@_);
475 493
476 return $arg; 494 return $arg;
477} 495}
478 496
497sub if_submiterror($$) {
498 warn "if_submiterror\n";
499 my ($self, $arg) = @_;
500 if (exists $self->{submitError}) {
501 warn "returning $arg\n";
502 return $arg;
503 } else {
504 warn "returning ".!$arg."\n";
505 return !$arg;
506 }
507}
508
4791; 5091;
480 510
481__END__ 511__END__
482 512
483=head1 AUTHOR 513=head1 AUTHOR

Legend:
Removed from v.1016  
changed lines
  Added in v.1017

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9