Bug 30250: Use ApplyFrameworkDefaults when cataloguing
[koha.git] / authorities / authorities.pl
1 #!/usr/bin/perl
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # Koha is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21 use Modern::Perl;
22
23 use CGI qw ( -utf8 );
24 use C4::Auth qw( get_template_and_user );
25 use C4::Output qw( output_html_with_http_headers );
26 use C4::AuthoritiesMarc qw( AddAuthority ModAuthority GetAuthority GetTagsLabels GetAuthMARCFromKohaField FindDuplicateAuthority );
27 use C4::Context;
28 use Date::Calc qw( Today );
29 use MARC::File::USMARC;
30 use MARC::File::XML;
31 use C4::Biblio qw( TransformHtmlToMarc );
32 use Koha::Authority::Types;
33 use Koha::Import::Records;
34 use Koha::ItemTypes;
35 use vars qw( $tagslib);
36 use vars qw( $authorised_values_sth);
37 use vars qw( $is_a_modif );
38
39 our($authorised_values_sth,$is_a_modif,$usedTagsLib,$mandatory_z3950);
40
41 =head1 FUNCTIONS
42
43 =over
44
45 =item build_authorized_values_list
46
47 builds list, depending on authorised value...
48
49 =cut
50
51 sub build_authorized_values_list {
52     my ( $tag, $subfield, $value, $dbh, $authorised_values_sth,$index_tag,$index_subfield ) = @_;
53
54     my @authorised_values;
55     my %authorised_lib;
56
57     my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
58     push @authorised_values, q{} unless $tagslib->{$tag}->{$subfield}->{mandatory} && $value;
59
60     if ( $category eq "branches" ) {
61         my $sth = $dbh->prepare( "select branchcode,branchname from branches order by branchname" );
62         $sth->execute;
63         while ( my ( $branchcode, $branchname ) = $sth->fetchrow_array ) {
64             push @authorised_values, $branchcode;
65             $authorised_lib{$branchcode} = $branchname;
66         }
67     }
68     elsif ( $category eq "itemtypes" ) {
69         my $itemtypes = Koha::ItemTypes->search_with_localization;
70         while ( my $itemtype = $itemtypes->next ) {
71             push @authorised_values, $itemtype->itemtype;
72             $authorised_lib{$itemtype->itemtype} = $itemtype->translated_description;
73         }
74     }
75     else { # "true" authorised value
76         $authorised_values_sth->execute(
77             $tagslib->{$tag}->{$subfield}->{authorised_value}
78         );
79         while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
80             push @authorised_values, $value;
81             $authorised_lib{$value} = $lib;
82         }
83     }
84
85     return {
86         type     => 'select',
87         id       => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
88         name     => "tag_".$tag."_subfield_".$subfield."_".$index_tag."_".$index_subfield,
89         values   => \@authorised_values,
90         labels   => \%authorised_lib,
91         default  => $value,
92         ( ( grep { $_ eq $category } ( qw(branches itemtypes cn_source) ) ) ? () : ( category => $category ) ),
93     };
94 }
95
96 =item create_input
97
98 builds the <input ...> entry for a subfield.
99
100 =cut
101
102 sub create_input {
103     my ( $tag, $subfield, $value, $index_tag, $rec, $authorised_values_sth, $cgi ) = @_;
104
105     my $index_subfield = CreateKey(); # create a specifique key for each subfield
106
107     # determine maximum length; 9999 bytes per ISO 2709 except for leader and MARC21 008
108     my $max_length = 9999;
109     if ($tag eq '000') {
110         $max_length = 24;
111     } elsif ($tag eq '008' and C4::Context->preference('marcflavour') eq 'MARC21')  {
112         $max_length = 40;
113     }
114
115     # Apply optional framework default value when it is a new record,
116     # or when editing as new (duplicating a record),
117     # based on the ApplyFrameworkDefaults setting.
118     # Substitute date parts, user name
119     my $applydefaults = C4::Context->preference('ApplyFrameworkDefaults');
120     if ( $value eq '' && (
121         ( $applydefaults =~ /new/ && !$cgi->param('authid') ) ||
122         ( $applydefaults =~ /duplicate/ && $cgi->param('op') eq 'duplicate' )
123     ) ) {
124         $value = $tagslib->{$tag}->{$subfield}->{defaultvalue};
125         if (!defined $value) {
126             $value = q{};
127         }
128
129         # get today date & replace YYYY, MM, DD if provided in the default value
130         my ( $year, $month, $day ) = Today();
131         $month = sprintf( "%02d", $month );
132         $day   = sprintf( "%02d", $day );
133         $value =~ s/YYYY/$year/g;
134         $value =~ s/MM/$month/g;
135         $value =~ s/DD/$day/g;
136     }
137     my $dbh = C4::Context->dbh;
138
139     # map '@' as "subfield" label for fixed fields
140     # to something that's allowed in a div id.
141     my $id_subfield = $subfield;
142     $id_subfield = "00" if $id_subfield eq "@";
143
144     my %subfield_data = (
145         tag        => $tag,
146         subfield   => $id_subfield,
147         marc_lib       => $tagslib->{$tag}->{$subfield}->{lib},
148         tag_mandatory  => $tagslib->{$tag}->{mandatory},
149         mandatory      => $tagslib->{$tag}->{$subfield}->{mandatory},
150         repeatable     => $tagslib->{$tag}->{$subfield}->{repeatable},
151         kohafield      => $tagslib->{$tag}->{$subfield}->{kohafield},
152         index          => $index_tag,
153         id             => "tag_".$tag."_subfield_".$id_subfield."_".$index_tag."_".$index_subfield,
154         value          => $value,
155         random         => CreateKey(),
156     );
157
158     if(exists $mandatory_z3950->{$tag.$subfield}){
159         $subfield_data{z3950_mandatory} = $mandatory_z3950->{$tag.$subfield};
160     }
161     
162     $subfield_data{visibility} = "display:none;"
163         if( $tagslib->{$tag}->{$subfield}->{hidden} and $value ne ''
164             or ($value eq '' and !$tagslib->{$tag}->{$subfield}->{mandatory})
165         );
166     
167     # it's an authorised field
168     if ( $tagslib->{$tag}->{$subfield}->{authorised_value} ) {
169         $subfield_data{marc_value} =
170         build_authorized_values_list( $tag, $subfield, $value, $dbh,
171             $authorised_values_sth,$index_tag,$index_subfield );
172
173     # it's a thesaurus / authority field
174     }
175     elsif ( $tagslib->{$tag}->{$subfield}->{authtypecode} ) {
176         $subfield_data{marc_value} = {
177             type         => 'text1',
178             id           => $subfield_data{id},
179             name         => $subfield_data{id},
180             value        => $value,
181             authtypecode => $tagslib->{$tag}->{$subfield}->{authtypecode},
182         };
183     }
184     elsif ( $tagslib->{$tag}->{$subfield}->{'value_builder'} ) { # plugin
185         require Koha::FrameworkPlugin;
186         my $plugin = Koha::FrameworkPlugin->new({
187             name => $tagslib->{$tag}->{$subfield}->{'value_builder'},
188         });
189         my $pars=  { dbh => $dbh, record => $rec, tagslib =>$tagslib,
190             id => $subfield_data{id} };
191         $plugin->build( $pars );
192         if( !$plugin->errstr ) {
193             $subfield_data{marc_value} = {
194                 type       => 'text2',
195                 id        => $subfield_data{id},
196                 name      => $subfield_data{id},
197                 value     => $value,
198                 maxlength => $max_length,
199                 javascript => $plugin->javascript,
200                 noclick    => $plugin->noclick,
201             };
202         } else { # warn and supply default field
203             warn $plugin->errstr;
204             $subfield_data{marc_value} = {
205                 type      => 'text',
206                 id        => $subfield_data{id},
207                 name      => $subfield_data{id},
208                 value     => $value,
209                 maxlength => $max_length,
210             };
211         }
212     }
213     # it's an hidden field
214     elsif ( $tag eq '' ) {
215         $subfield_data{marc_value} = {
216             type      => 'hidden',
217             id        => $subfield_data{id},
218             name      => $subfield_data{id},
219             value     => $value,
220             maxlength => $max_length,
221         }
222     }
223     elsif ( $tagslib->{$tag}->{$subfield}->{'hidden'} ) {
224         $subfield_data{marc_value} = {
225             type => 'text',
226             id        => $subfield_data{id},
227             name      => $subfield_data{id},
228             value     => $value,
229             maxlength => $max_length,
230         };
231
232         # it's a standard field
233     }
234     else {
235         if (
236             length($value) > 100
237             or
238             ( C4::Context->preference("marcflavour") eq "UNIMARC" && $tag >= 300
239                 and $tag < 400 && $subfield eq 'a' )
240             or (    $tag >= 600
241                 and $tag < 700
242                 && C4::Context->preference("marcflavour") eq "MARC21" )
243         )
244         {
245             $subfield_data{marc_value} = {
246                 type => 'textarea',
247                 id        => $subfield_data{id},
248                 name      => $subfield_data{id},
249                 value     => $value,
250                 maxlength => $max_length,
251             };
252
253         }
254         else {
255             $subfield_data{marc_value} = {
256                 type => 'text',
257                 id        => $subfield_data{id},
258                 name      => $subfield_data{id},
259                 value     => $value,
260                 maxlength => $max_length,
261             };
262
263         }
264     }
265     if ($cgi->param('tagreport') && $subfield_data{tag} == $cgi->param('tagreport')) {
266         $subfield_data{marc_value}{value} = $cgi->param('tag'. $cgi->param('tagbiblio') . 'subfield' . $subfield_data{subfield});
267     }
268     $subfield_data{'index_subfield'} = $index_subfield;
269     return \%subfield_data;
270 }
271
272 =item format_indicator
273
274 Translate indicator value for output form - specifically, map
275 indicator = ' ' to ''.  This is for the convenience of a cataloger
276 using a mouse to select an indicator input.
277
278 =cut
279
280 sub format_indicator {
281     my $ind_value = shift;
282     return '' if not defined $ind_value;
283     return '' if $ind_value eq ' ';
284     return $ind_value;
285 }
286
287 =item CreateKey
288
289 Create a random value to set it into the input name
290
291 =cut
292
293 sub CreateKey {
294     return int(rand(1000000));
295 }
296
297 =item GetMandatoryFieldZ3950
298
299     This function returns a hashref which contains all mandatory field
300     to search with z3950 server.
301
302 =cut
303
304 sub GetMandatoryFieldZ3950 {
305     my $authtypecode = shift;
306     if ( C4::Context->preference('marcflavour') eq 'MARC21' ){
307         return {
308             '100a' => 'authorpersonal',
309             '110a' => 'authorcorp',
310             '111a' => 'authormeetingcon',
311             '130a' => 'uniformtitle',
312             '150a' => 'subject',
313         };
314     }else{
315         return {
316             '200a' => 'authorpersonal',
317             '210a' => 'authorcorp', #210 in UNIMARC is used for both corporation and meeting
318             '230a' => 'uniformtitle',
319         };
320     }
321 }
322
323 sub build_tabs {
324     my ( $template, $record, $dbh, $input ) = @_;
325
326     # fill arrays
327     my @loop_data = ();
328     my $tag;
329
330     my $authorised_values_sth = $dbh->prepare(
331         "SELECT authorised_value,lib
332         FROM authorised_values
333         WHERE category=? ORDER BY lib"
334     );
335     
336     # in this array, we will push all the 10 tabs
337     # to avoid having 10 tabs in the template : they will all be in the same BIG_LOOP
338     my @BIG_LOOP;
339     my %seen;
340     my @tab_data; # all tags to display
341     
342     foreach my $used ( keys %$tagslib ){
343         push @tab_data,$used if not $seen{$used};
344         $seen{$used}++;
345     }
346         
347     my $max_num_tab=9;
348     # loop through each tab 0 through 9
349     for ( my $tabloop = 0 ; $tabloop <= $max_num_tab ; $tabloop++ ) {
350         my @loop_data = (); #innerloop in the template.
351         my $i = 0;
352         foreach my $tag (sort @tab_data) {
353             $i++;
354             next if ! $tag;
355             my ($indicator1, $indicator2);
356             my $index_tag = CreateKey;
357
358             # if MARC::Record is not empty =>use it as master loop, then add missing subfields that should be in the tab.
359             # if MARC::Record is empty => use tab as master loop.
360             if ( $record && ( $record->field($tag) || $tag eq '000' ) ) {
361                 my @fields;
362                 if ( $tag ne '000' ) {
363                                 @fields = $record->field($tag);
364                 }
365                 else {
366                 push @fields, $record->leader(); # if tag == 000
367                 }
368                 # loop through each field
369                 foreach my $field (@fields) {
370                     
371                     my @subfields_data;
372                     if ( $tag < 10 ) {
373                         my ( $value, $subfield );
374                         if ( $tag ne '000' ) {
375                             $value    = $field->data();
376                             $subfield = "@";
377                         }
378                         else {
379                             $value    = $field;
380                             $subfield = '@';
381                         }
382                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
383                         next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
384                         push(
385                             @subfields_data,
386                             &create_input(
387                                 $tag, $subfield, $value, $index_tag, $record,
388                                 $authorised_values_sth,$input
389                             )
390                         );
391                     }
392                     else {
393                         my @subfields = $field->subfields();
394                         foreach my $subfieldcount ( 0 .. $#subfields ) {
395                             my $subfield = $subfields[$subfieldcount][0];
396                             my $value    = $subfields[$subfieldcount][1];
397                             next if ( length $subfield != 1 );
398                             next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
399                             next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
400                             push(
401                                 @subfields_data,
402                                 &create_input(
403                                     $tag, $subfield, $value, $index_tag,
404                                     $record, $authorised_values_sth,$input
405                                 )
406                             );
407                         }
408                     }
409
410                     # now, loop again to add parameter subfield that are not in the MARC::Record
411                     foreach my $subfield ( sort( keys %{ $tagslib->{$tag} } ) )
412                     {
413                         next if ( length $subfield != 1 );
414                         next if ( $tagslib->{$tag}->{$subfield}->{tab} ne $tabloop );
415                         next if ( $tag < 10 );
416                         next if $tagslib->{$tag}->{$subfield}->{hidden} && $subfield ne '9';
417                         next if ( defined( $field->subfield($subfield) ) );
418                         push(
419                             @subfields_data,
420                             &create_input(
421                                 $tag, $subfield, '', $index_tag, $record,
422                                 $authorised_values_sth,$input
423                             )
424                         );
425                     }
426                     if ( $#subfields_data >= 0 ) {
427                         # build the tag entry.
428                         # note that the random() field is mandatory. Otherwise, on repeated fields, you'll 
429                         # have twice the same "name" value, and cgi->param() will return only one, making
430                         # all subfields to be merged in a single field.
431                         my %tag_data = (
432                             tag           => $tag,
433                             index         => $index_tag,
434                             tag_lib       => $tagslib->{$tag}->{lib},
435                             repeatable       => $tagslib->{$tag}->{repeatable},
436                             mandatory       => $tagslib->{$tag}->{mandatory},
437                             subfield_loop => \@subfields_data,
438                             fixedfield    => ($tag < 10)?(1):(0),
439                             random        => CreateKey,
440                         );
441                         if ($tag >= 10){ # no indicator for theses tag
442                             $tag_data{indicator1} = format_indicator($field->indicator(1)),
443                             $tag_data{indicator2} = format_indicator($field->indicator(2)),
444                         }
445                         push( @loop_data, \%tag_data );
446                     }
447                 } # foreach $field end
448
449             # if breeding is empty
450             }
451             else {
452                 my @subfields_data;
453                 foreach my $subfield (
454                     sort { $a->{display_order} <=> $b->{display_order} || $a->{subfield} cmp $b->{subfield} }
455                     grep { ref($_) && %$_ } # Not a subfield (values for "important", "lib", "mandatory", etc.) or empty
456                     values %{ $tagslib->{$tag} } )
457                 {
458                     next if $subfield->{hidden} && $subfield->{subfield} ne '9';
459                     next if ( $subfield->{tab} ne $tabloop );
460                     push(
461                         @subfields_data,
462                         &create_input(
463                             $tag, $subfield->{subfield}, '', $index_tag, $record,
464                             $authorised_values_sth,$input
465                         )
466                     );
467                 }
468                 if ( $#subfields_data >= 0 ) {
469                     my %tag_data = (
470                         tag              => $tag,
471                         index            => $index_tag,
472                         tag_lib          => $tagslib->{$tag}->{lib},
473                         repeatable       => $tagslib->{$tag}->{repeatable},
474                         mandatory       => $tagslib->{$tag}->{mandatory},
475                         indicator1       => $indicator1,
476                         indicator2       => $indicator2,
477                         subfield_loop    => \@subfields_data,
478                         tagfirstsubfield => $subfields_data[0],
479                         fixedfield       => ($tag < 10)?(1):(0)
480                     );
481                     
482                     push @loop_data, \%tag_data ;
483                 }
484             }
485         }
486         if ( $#loop_data >= 0 ) {
487             push @BIG_LOOP, {
488                 number    => $tabloop,
489                 innerloop => \@loop_data,
490             };
491         }
492     }
493     $template->param( BIG_LOOP => \@BIG_LOOP );
494 }
495
496
497 sub build_hidden_data {
498     # build hidden data =>
499     # we store everything, even if we show only requested subfields.
500
501     my @loop_data =();
502     my $i=0;
503     foreach my $tag (keys %{$tagslib}) {
504         my $previous_tag = '';
505
506         # loop through each subfield
507         foreach my $subfield (keys %{$tagslib->{$tag}}) {
508             next if ($subfield eq 'lib');
509             next if ($subfield eq 'tab');
510             next if ($subfield eq 'mandatory');
511                 next if ($subfield eq 'repeatable');
512             next if ($tagslib->{$tag}->{$subfield}->{'tab'}  ne "-1");
513             my %subfield_data;
514             $subfield_data{marc_lib}=$tagslib->{$tag}->{$subfield}->{lib};
515             $subfield_data{marc_mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory};
516             $subfield_data{marc_repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable};
517             $subfield_data{marc_value} = {
518                 type => 'hidden_simple',
519                 name => 'field_value[]',
520             };
521             push(@loop_data, \%subfield_data);
522             $i++
523         }
524     }
525 }
526
527 =back
528
529 =cut
530
531
532 # ======================== 
533 #          MAIN 
534 #=========================
535 my $input = CGI->new;
536 my $z3950 = $input->param('z3950');
537 my $error = $input->param('error');
538 my $authid=$input->param('authid'); # if authid exists, it's a modif, not a new authority.
539 my $op = $input->param('op');
540 my $nonav = $input->param('nonav');
541 my $myindex = $input->param('index');
542 my $linkid=$input->param('linkid');
543 my $authtypecode = $input->param('authtypecode');
544 my $breedingid    = $input->param('breedingid');
545
546
547 my $dbh = C4::Context->dbh;
548 if(!$authtypecode) {
549     $authtypecode = $authid ? Koha::Authorities->find($authid)->authtypecode : '';
550 }
551
552 my $authobj = Koha::Authorities->find($authid);
553 my $count = $authobj ? $authobj->get_usage_count : 0;
554
555 my ($template, $loggedinuser, $cookie)
556     = get_template_and_user({template_name => "authorities/authorities.tt",
557                             query => $input,
558                             type => "intranet",
559                             flagsrequired => {editauthorities => 1},
560                             });
561 $template->param(nonav   => $nonav,index=>$myindex,authtypecode=>$authtypecode,breedingid=>$breedingid, count=>$count);
562
563 $tagslib = GetTagsLabels(1,$authtypecode);
564 $mandatory_z3950 = GetMandatoryFieldZ3950($authtypecode);
565
566 my $record;
567 if ($breedingid) {
568     my $import_record = Koha::Import::Records->find($breedingid);
569     if ($import_record) {
570         $record = $import_record->get_marc_record();
571     }
572 } elsif ($authid) {
573     $record = GetAuthority($authid);
574 }
575
576 my ($oldauthnumtagfield,$oldauthnumtagsubfield);
577 my ($oldauthtypetagfield,$oldauthtypetagsubfield);
578 $is_a_modif=0;
579 if ($authid) {
580     $is_a_modif=1;
581     ($oldauthnumtagfield,$oldauthnumtagsubfield) = GetAuthMARCFromKohaField("auth_header.authid",$authtypecode);
582     ($oldauthtypetagfield,$oldauthtypetagsubfield) = GetAuthMARCFromKohaField("auth_header.authtypecode",$authtypecode);
583 }
584 $op ||= q{};
585 #------------------------------------------------------------------------------------------------------------------------------
586 if ($op eq "add") {
587 #------------------------------------------------------------------------------------------------------------------------------
588     # rebuild
589     my @tags = $input->multi_param('tag');
590     my @subfields = $input->multi_param('subfield');
591     my @values = $input->multi_param('field_value');
592     # build indicator hash.
593     my @ind_tag = $input->multi_param('ind_tag');
594     my @indicator = $input->multi_param('indicator');
595     my $record = TransformHtmlToMarc($input, 0);
596
597     my ($duplicateauthid,$duplicateauthvalue);
598      ($duplicateauthid,$duplicateauthvalue) = FindDuplicateAuthority($record,$authtypecode) if ($op eq "add") && (!$is_a_modif);
599     my $confirm_not_duplicate = $input->param('confirm_not_duplicate');
600     # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
601     if (!$duplicateauthid or $confirm_not_duplicate) {
602         if ($is_a_modif ) {     
603             ModAuthority($authid,$record,$authtypecode);
604         } else {
605             ($authid) = AddAuthority($record,$authid,$authtypecode);
606         }
607         if ($myindex) {
608             print $input->redirect("blinddetail-biblio-search.pl?authid=$authid&index=$myindex");
609         } else {
610             print $input->redirect("detail.pl?authid=$authid");
611         }
612         exit;
613     } else {
614     # it may be a duplicate, warn the user and do nothing
615         build_tabs($template, $record, $dbh, $input);
616         build_hidden_data;
617         $template->param(authid =>$authid,
618                         duplicateauthid     => $duplicateauthid,
619                         duplicateauthvalue  => $duplicateauthvalue->{'authorized'}->[0]->{'heading'},
620                         );
621     }
622 } elsif ($op eq "delete") {
623 #------------------------------------------------------------------------------------------------------------------------------
624         DelAuthority({ authid => $authid });
625         if ($nonav){
626             print $input->redirect("auth_finder.pl");
627         }else{
628             print $input->redirect("authorities-home.pl?authid=0");
629         }
630                 exit;
631 } else {
632 if ($op eq "duplicate")
633         {
634                 $authid = "";
635         }
636         build_tabs ($template, $record, $dbh, $input);
637         build_hidden_data;
638         $template->param(oldauthtypetagfield=>$oldauthtypetagfield, oldauthtypetagsubfield=>$oldauthtypetagsubfield,
639                         oldauthnumtagfield=>$oldauthnumtagfield, oldauthnumtagsubfield=>$oldauthnumtagsubfield,
640                         authid                      => $authid , authtypecode=>$authtypecode,   );
641 }
642
643 my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
644
645 my $type = $authority_types->find($authtypecode);
646 $template->param(
647     authority_types => $authority_types,
648     authtypecode    => $authtypecode,
649     authid          => $authid,
650     linkid          => $linkid,
651     authtypetext    => $type ? $type->authtypetext : "",
652     hide_marc       => C4::Context->preference('hide_marc'),
653 );
654 output_html_with_http_headers $input, $cookie, $template->output;