]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/WWW/TemplateBatchBibUpdate.pm
fix user session management for MARC Batch Edit
[working/Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / WWW / TemplateBatchBibUpdate.pm
1 package OpenILS::WWW::TemplateBatchBibUpdate;
2 use strict;
3 use warnings;
4 use bytes;
5
6 use Apache2::Log;
7 use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log);
8 use APR::Const    -compile => qw(:error SUCCESS);
9 use APR::Table;
10
11 use Apache2::RequestRec ();
12 use Apache2::RequestIO ();
13 use Apache2::RequestUtil;
14 use CGI;
15 use Data::Dumper;
16 use Text::CSV;
17
18 use OpenSRF::EX qw(:try);
19 use OpenSRF::Utils qw/:datetime/;
20 use OpenSRF::Utils::Cache;
21 use OpenSRF::System;
22 use OpenSRF::AppSession;
23 use XML::LibXML;
24 use XML::LibXSLT;
25
26 use Encode;
27 use Unicode::Normalize;
28 use OpenILS::Utils::Fieldmapper;
29 use OpenSRF::Utils::Logger qw/$logger/;
30
31 use MARC::Record;
32 use MARC::File::XML ( BinaryEncoding => 'UTF-8' );
33
34 use UNIVERSAL::require;
35
36 our @formats = qw/USMARC UNIMARC XML BRE/;
37
38 # set the bootstrap config and template include directory when
39 # this module is loaded
40 my $bootstrap;
41
42 sub import {
43     my $self = shift;
44     $bootstrap = shift;
45 }
46
47
48 sub child_init {
49     OpenSRF::System->bootstrap_client( config_file => $bootstrap );
50     Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
51     return Apache2::Const::OK;
52 }
53
54 sub handler {
55     my $r = shift;
56     my $cgi = new CGI;
57
58     my $authid = $cgi->cookie('ses') || $cgi->param('ses');
59     my $usr = verify_login($authid);
60     return show_template($r) unless ($usr);
61
62     my $template = $cgi->param('template');
63     return show_template($r) unless ($template);
64
65
66     my $rsource = $cgi->param('recordSource');
67     # find some IDs ...
68     my @records;
69
70     if ($rsource eq 'r') {
71         @records = map { $_ ? ($_) : () } $cgi->param('recid');
72     }
73
74     if ($rsource eq 'c') { # try for a file
75         my $file = $cgi->param('idfile');
76         if ($file) {
77             my $col = $cgi->param('idcolumn') || 0;
78             my $csv = new Text::CSV;
79
80             while (<$file>) {
81                 $csv->parse($_);
82                 my @data = $csv->fields;
83                 my $id = $data[$col];
84                 $id =~ s/\D+//o;
85                 next unless ($id);
86                 push @records, $id;
87             }
88         }
89     }
90
91     my $e = OpenSRF::AppSession->connect('open-ils.cstore');
92     $e->request('open-ils.cstore.transaction.begin')->gather(1);
93     $e->request('open-ils.cstore.set_audit_info', $authid, $usr->id, $usr->wsid)->gather(1);
94
95     # still no records ...
96     my $container = $cgi->param('containerid');
97     if ($rsource eq 'b') {
98         if ($container) {
99             my $bucket = $e->request(
100                 'open-ils.cstore.direct.container.biblio_record_entry_bucket.retrieve',
101                 $container
102             )->gather(1);
103             unless($bucket) {
104                 $e->request('open-ils.cstore.transaction.rollback')->gather(1);
105                 $e->disconnect;
106                 $r->log->error("No such bucket $container");
107                 $logger->error("No such bucket $container");
108                 return Apache2::Const::NOT_FOUND;
109             }
110             my $recs = $e->request(
111                 'open-ils.cstore.direct.container.biblio_record_entry_bucket_item.search.atomic',
112                 { bucket => $container }
113             )->gather(1);
114             @records = map { ($_->target_biblio_record_entry) } @$recs;
115         }
116     }
117
118     unless (@records) {
119         $e->request('open-ils.cstore.transaction.rollback')->gather(1);
120         $e->disconnect;
121         return show_template($r);
122     }
123
124     # we have a template and some record ids, so...
125
126     # insert the template record
127     my $min_id = $e->request(
128         'open-ils.cstore.json_query',
129         { select => { bre => [{ column => 'id', transform => 'min', aggregate => 1}] }, from => 'bre' }
130     )->gather(1)->{id} - 1;
131
132     warn "new template bib id = $min_id\n";
133
134     my $tmpl_rec = Fieldmapper::biblio::record_entry->new;
135     $tmpl_rec->id($min_id);
136     $tmpl_rec->deleted('t');
137     $tmpl_rec->active('f');
138     $tmpl_rec->marc($template);
139     $tmpl_rec->creator($usr->id);
140     $tmpl_rec->editor($usr->id);
141
142     warn "about to create bib $min_id\n";
143     $e->request('open-ils.cstore.direct.biblio.record_entry.create', $tmpl_rec )->gather(1);
144
145     # create the new container for the records and the template
146     my $bucket = Fieldmapper::container::biblio_record_entry_bucket->new;
147     $bucket->owner($usr->id);
148     $bucket->btype('template_merge');
149
150     my $bname = $cgi->param('bname') || 'Temporary Merge Bucket '. localtime() . ' ' . $usr->id;
151     $bucket->name($bname);
152
153     $bucket = $e->request('open-ils.cstore.direct.container.biblio_record_entry_bucket.create', $bucket )->gather(1);
154
155     # create items in the bucket
156     my $item = Fieldmapper::container::biblio_record_entry_bucket_item->new;
157     $item->bucket($bucket->id);
158     $item->target_biblio_record_entry($min_id);
159
160     $e->request('open-ils.cstore.direct.container.biblio_record_entry_bucket_item.create', $item )->gather(1);
161
162     my %seen;
163     for my $r (@records) {
164         next if ($seen{$r});
165         $item->target_biblio_record_entry($r);
166         $e->request('open-ils.cstore.direct.container.biblio_record_entry_bucket_item.create', $item )->gather(1);
167         $seen{$r}++;
168     }
169
170     $e->request('open-ils.cstore.transaction.commit')->gather(1);
171     $e->disconnect;
172
173     # fire the background bucket processor
174     my $cache_key = OpenSRF::AppSession
175         ->create('open-ils.cat')
176         ->request('open-ils.cat.container.template_overlay.background', $authid, $bucket->id)
177         ->gather(1);
178
179     return show_processing_template($r, $bucket->id, \@records, $cache_key);
180 }
181
182 sub verify_login {
183         my $auth_token = shift;
184         return undef unless $auth_token;
185
186         my $user = OpenSRF::AppSession
187                 ->create("open-ils.auth")
188                 ->request( "open-ils.auth.session.retrieve", $auth_token )
189                 ->gather(1);
190
191         if (ref($user) eq 'HASH' && $user->{ilsevent} == 1001) {
192                 return undef;
193         }
194
195         return $user if ref($user);
196         return undef;
197 }
198
199 sub show_processing_template {
200     my $r = shift;
201     my $bid = shift;
202     my $recs = shift;
203     my $cache_key = shift;
204
205     my $rec_string = @$recs;
206
207     $r->content_type('text/html');
208     $r->print(<<HTML);
209 <html xmlns="http://www.w3.org/1999/xhtml">
210
211     <head>
212         <title>Merging records...</title>
213         <style type="text/css">
214             \@import '/js/dojo/dojo/resources/dojo.css';
215             \@import '/js/dojo/dijit/themes/tundra/tundra.css';
216             .hide_me { display: none; visibility: hidden; }
217             th       { font-weight: bold; }
218         </style>
219
220         <script type="text/javascript">
221             var djConfig= {
222                 isDebug: false,
223                 parseOnLoad: true,
224                 AutoIDL: ['aou','aout','pgt','au','cbreb']
225             }
226         </script>
227
228         <script src='/js/dojo/dojo/dojo.js'></script>
229         <!-- <script src="/js/dojo/dojo/openils_dojo.js"></script> -->
230
231         <script type="text/javascript">
232
233             dojo.require('fieldmapper.AutoIDL');
234             dojo.require('fieldmapper.dojoData');
235             dojo.require('openils.User');
236             dojo.require('openils.XUL');
237             dojo.require('dojo.cookie');
238             dojo.require('openils.CGI');
239             dojo.require('openils.widget.ProgressDialog');
240
241             var cgi = new openils.CGI();
242             var authtoken = dojo.cookie('ses') || cgi.param('ses');
243             if (!authtoken && openils.XUL.isXUL()) {
244                 var stash = openils.XUL.getStash();
245                 authtoken = stash.session.key;
246             }
247             var u = new openils.User({ authtoken: authtoken });
248
249             dojo.addOnLoad(function () {
250                 progress_dialog.show(true);
251                 progress_dialog.update({maximum:$rec_string});
252
253                 var interval;
254                 interval = setInterval( function() {
255                     fieldmapper.standardRequest(
256                         ['open-ils.actor','open-ils.actor.anon_cache.get_value'],
257                         { async : false,
258                           params: [ u.authtoken, 'res_list' ],
259                           onerror : function (r) { progress_dialog.hide(); },
260                           onresponse : function (r) {
261                             var counter = { success : 0, fail : 0, total : 0 };
262                             dojo.forEach( openils.Util.readResponse(r), function(x) {
263                                 if (x.complete) {
264                                     clearInterval(interval);
265                                     progress_dialog.hide();
266                                     if (x.success == 't') dojo.byId('complete_msg').innerHTML = 'Overlay completed successfully';
267                                     else dojo.byId('complete_msg').innerHTML = 'Overlay did not complet successfully';
268                                 } else {
269                                     counter.total++;
270                                     switch (x.success) {
271                                         case 't':
272                                             counter.success++;
273                                             break;
274                                         default:
275                                             counter.fail++;
276                                             break;
277                                     }
278                                 }
279                             });
280
281                             // update the progress dialog
282                             progress_dialog.update({progress:counter.total});
283                             dojo.byId('success_count').innerHTML = counter.success;
284                             dojo.byId('fail_count').innerHTML = counter.fail;
285                             dojo.byId('total_count').innerHTML = counter.total;
286                           }
287                         }
288                     );
289                 }, 1000);
290
291             });
292         </script>
293     </head>
294
295     <body style="margin:10px;" class='tundra'>
296         <div class="hide_me"><div dojoType="openils.widget.ProgressDialog" jsId="progress_dialog"></div></div>
297
298         <table style="width:100%; margin-top:100px;">
299             <th>
300                 <td>Status</td>
301                 <td>Record Count</td>
302             </th>
303             <tr>
304                 <td>Success</td>
305                 <td id='success_count'></td>
306             </tr>
307             <tr>
308                 <td>Failure</td>
309                 <td id='fail_count'></td>
310             </tr>
311             <tr>
312                 <td></td>
313                 <td id='total_count'></td>
314             </tr>
315         </table>
316
317         <div id='complete_msg'></div>
318
319     </body>
320 </html>
321 HTML
322
323     return Apache2::Const::OK;
324 }
325
326
327 sub show_template {
328     my $r = shift;
329
330     $r->content_type('text/html');
331     $r->print(<<'HTML');
332 <html xmlns="http://www.w3.org/1999/xhtml">
333
334     <head>
335         <title>Merge Template Builder</title>
336         <style type="text/css">
337             @import '/js/dojo/dojo/resources/dojo.css';
338             @import '/js/dojo/dijit/themes/tundra/tundra.css';
339             .hide_me { display: none; visibility: hidden; }
340             table.ruleTable th { padding: 5px; border-collapse: collapse; border-bottom: solid 1px gray; font-weight: bold; }
341             table.ruleTable td { padding: 5px; border-collapse: collapse; border-bottom: solid 1px gray; }
342         </style>
343
344         <script type="text/javascript">
345             var djConfig= {
346                 isDebug: false,
347                 parseOnLoad: true,
348                 AutoIDL: ['aou','aout','pgt','au','cbreb']
349             }
350         </script>
351
352         <script src='/js/dojo/dojo/dojo.js'></script>
353         <!-- <script src="/js/dojo/dojo/openils_dojo.js"></script> -->
354
355         <script type="text/javascript">
356
357             dojo.require('dojo.data.ItemFileReadStore');
358             dojo.require('dijit.form.Form');
359             dojo.require('dijit.form.NumberSpinner');
360             dojo.require('dijit.form.FilteringSelect');
361             dojo.require('dijit.form.TextBox');
362             dojo.require('dijit.form.Textarea');
363             dojo.require('dijit.form.Button');
364             dojo.require('MARC.Batch');
365             dojo.require('fieldmapper.AutoIDL');
366             dojo.require('fieldmapper.dojoData');
367             dojo.require('openils.User');
368             dojo.require('openils.CGI');
369             dojo.require('openils.XUL');
370             dojo.require('dojo.cookie');
371
372             var cgi = new openils.CGI();
373             var authtoken = dojo.cookie('ses') || cgi.param('ses');
374             if (!authtoken && openils.XUL.isXUL()) {
375                 var stash = openils.XUL.getStash();
376                 authtoken = stash.session.key;
377             }
378             var u = new openils.User({ authtoken: authtoken });
379
380             var bucketStore = new dojo.data.ItemFileReadStore(
381                 { data : cbreb.toStoreData(
382                         fieldmapper.standardRequest(
383                             ['open-ils.actor','open-ils.actor.container.retrieve_by_class.authoritative'],
384                             [u.authtoken, u.user.id(), 'biblio', 'staff_client']
385                         )
386                     )
387                 }
388             );
389
390             function render_preview () {
391                 var rec = ruleset_to_record();
392                 dojo.byId('marcPreview').innerHTML = rec.toBreaker();
393             }
394
395             function render_from_template () {
396                 var kid_number = dojo.byId('ruleList').childNodes.length;
397                 var clone = dojo.query('*[name=ruleTable]', dojo.byId('ruleTemplate'))[0].cloneNode(true);
398
399                 var typeSelect = dojo.query('*[name=typeSelect]',clone).instantiate(dijit.form.FilteringSelect, {
400                     onChange : function (val) {
401                         switch (val) {
402                             case 'a':
403                             case 'r':
404                                 dijit.byNode(dojo.query('*[name=marcDataContainer] .dijit',clone)[0]).attr('disabled',false);
405                                 break;
406                             default :
407                                 dijit.byNode(dojo.query('*[name=marcDataContainer] .dijit',clone)[0]).attr('disabled',true);
408                         };
409                         render_preview();
410                     }
411                 })[0];
412
413                 var marcData = dojo.query('*[name=marcData]',clone).instantiate(dijit.form.TextBox, {
414                     onChange : render_preview
415                 })[0];
416
417
418                 var tag = dojo.query('*[name=tag]',clone).instantiate(dijit.form.TextBox, {
419                     onChange : function (newtag) {
420                         var md = dijit.byNode(dojo.query('*[name=marcDataContainer] .dijit',clone)[0]);
421                         var current_marc = md.attr('value');
422
423                         if (newtag.length == 3) {
424                             if (current_marc.length == 0) newtag += ' \\\\';
425                             if (current_marc.substr(0,3) != newtag) current_marc = newtag + current_marc.substr(3);
426                         }
427                         md.attr('value', current_marc);
428                         render_preview();
429                     }
430                 })[0];
431
432                 var sf = dojo.query('*[name=sf]',clone).instantiate(dijit.form.TextBox, {
433                     onChange : function (newsf) {
434                         var md = dijit.byNode(dojo.query('*[name=marcDataContainer] .dijit',clone)[0]);
435                         var current_marc = md.attr('value');
436                         var sf_list = newsf.split('');
437
438                         for (var i in sf_list) {
439                             var re = '\\$' + sf_list[i];
440                             if (current_marc.match(re)) continue;
441                             current_marc += '$' + sf_list[i];
442                         }
443
444                         md.attr('value', current_marc);
445                         render_preview();
446                     }
447                 })[0];
448
449                 var matchSF = dojo.query('*[name=matchSF]',clone).instantiate(dijit.form.TextBox, {
450                     onChange : render_preview
451                 })[0];
452
453                 var matchRE = dojo.query('*[name=matchRE]',clone).instantiate(dijit.form.TextBox, {
454                     onChange : render_preview
455                 })[0];
456
457                 var removeButton = dojo.query('*[name=removeButton]',clone).instantiate(dijit.form.Button, {
458                     onClick : function() {
459                         dojo.addClass(
460                             dojo.byId('ruleList').childNodes[kid_number],
461                             'hide_me'
462                         );
463                         render_preview();
464                     }
465                 })[0];
466
467                 dojo.place(clone,'ruleList');
468             }
469
470             function ruleset_to_record () {
471                 var rec = new MARC.Record ({ delimiter : '$' });
472
473                 dojo.forEach( 
474                     dojo.query('#ruleList *[name=ruleTable]').filter( function (node) {
475                         if (node.className.match(/hide_me/)) return false;
476                         return true;
477                     }),
478                     function (tbl) {
479                         var rule_tag = new MARC.Field ({
480                             tag : '905',
481                             ind1 : ' ',
482                             ind2 : ' '
483                         });
484                         var rule_txt = dijit.byNode(dojo.query('*[name=tagContainer] .dijit',tbl)[0]).attr('value');
485                         rule_txt += dijit.byNode(dojo.query('*[name=sfContainer] .dijit',tbl)[0]).attr('value');
486
487                         var reSF = dijit.byNode(dojo.query('*[name=matchSFContainer] .dijit',tbl)[0]).attr('value');
488                         if (reSF) {
489                             var reRE = dijit.byNode(dojo.query('*[name=matchREContainer] .dijit',tbl)[0]).attr('value');
490                             rule_txt += '[' + reSF + '~' + reRE + ']';
491                         }
492
493                         var rtype = dijit.byNode(dojo.query('*[name=typeSelectContainer] .dijit',tbl)[0]).attr('value');
494                         rule_tag.addSubfields( rtype, rule_txt )
495                         rec.appendFields( rule_tag );
496
497                         if (rtype == 'a' || rtype == 'r') {
498                             rec.appendFields(
499                                 new MARC.Record ({
500                                     delimiter : '$',
501                                     marcbreaker : dijit.byNode(dojo.query('*[name=marcDataContainer] .dijit',tbl)[0]).attr('value')
502                                 }).fields[0]
503                             );
504                         }
505                     }
506                 );
507
508                 return rec;
509             }
510         </script>
511     </head>
512
513     <body style="margin:10px;" class='tundra'>
514
515         <div dojoType="dijit.form.Form" id="myForm" jsId="myForm" encType="multipart/form-data" action="" method="POST">
516                 <script type='dojo/method' event='onSubmit'>
517                     var rec = ruleset_to_record();
518
519                     if (rec.subfield('905','r') == '') { // no-op to force replace mode
520                         rec.appendFields(
521                             new MARC.Field ({
522                                 tag : '905',
523                                 ind1 : ' ',
524                                 ind2 : ' ',
525                                 subfields : [['r','901c']]
526                             })
527                         );
528                     }
529
530                     dojo.byId('template_value').value = rec.toXmlString();
531                     return true;
532                 </script>
533
534             <input type='hidden' id='template_value' name='template'/>
535
536             <label for='inputTypeSelect'>Record source:</label>
537             <select name='recordSource' dojoType='dijit.form.FilteringSelect'>
538                 <script type='dojo/method' event='onChange' args="val">
539                     switch (val) {
540                         case 'b':
541                             dojo.removeClass('bucketListContainer','hide_me');
542                             dojo.addClass('csvContainer','hide_me');
543                             dojo.addClass('recordContainer','hide_me');
544                             break;
545                         case 'c':
546                             dojo.addClass('bucketListContainer','hide_me');
547                             dojo.removeClass('csvContainer','hide_me');
548                             dojo.addClass('recordContainer','hide_me');
549                             break;
550                         case 'r':
551                             dojo.addClass('bucketListContainer','hide_me');
552                             dojo.addClass('csvContainer','hide_me');
553                             dojo.removeClass('recordContainer','hide_me');
554                             break;
555                     };
556                 </script>
557                 <script type='dojo/method' event='postCreate'>
558                     if (cgi.param('recordSource')) {
559                         this.attr('value',cgi.param('recordSource'));
560                         this.onChange(cgi.param('recordSource'));
561                     }
562                 </script>
563                 <option value='b'>a Bucket</option>
564                 <option value='c'>a CSV File</option>
565                 <option value='r'>a specific record ID</option>
566             </select>
567
568             <table style='margin:10px; margin-bottom:20px;'>
569 <!--
570                 <tr>
571                     <th>Merge template name (optional):</th>
572                     <td><input id='bucketName' jsId='bucketName' type='text' dojoType='dijit.form.TextBox' name='bname' value=''/></td>
573                 </tr>
574 -->
575                 <tr class='' id='bucketListContainer'>
576                     <td>Bucket named: 
577                         <div name='containerid' jsId='bucketList' dojoType='dijit.form.FilteringSelect' store='bucketStore' searchAttr='name' id='bucketList'>
578                             <script type='dojo/method' event='postCreate'>
579                                 if (cgi.param('containerid')) this.attr('value',cgi.param('containerid'));
580                             </script>
581                         </div>
582                     </td>
583                 </tr>
584                 <tr class='hide_me' id='csvContainer'>
585                     <td>
586                         Column <input style='width:75px;' type='text' dojoType='dijit.form.NumberSpinner' name='idcolumn' value='0' constraints='{min:0,max:100,places:0}' /> of: 
587                         <input id='idfile' type="file" name="idfile"/>
588                         <br/>
589                         <br/>
590                         Columns are numbered starting at 0.  For instance, when looking at a CSV file in Excel, the column labeled A is the same as column 0, and the column labeled B is the same as column 1.
591                     </td>
592                 </tr>
593                 <tr class='hide_me' id='recordContainer'>
594                     <td>Record ID: <input dojoType='dijit.form.TextBox' name='recid' style='width:75px;' type='text' value=''/></td>
595                 </tr>
596             </table>
597
598             <button type="submit" dojoType='dijit.form.Button'>GO!</button> (After setting up your template below.)
599
600             <br/>
601             <br/>
602
603         </div> <!-- end of the form -->
604
605         <hr/>
606         <table style='width: 100%'>
607             <tr>
608                 <td style='width: 50%'><div id='ruleList'></div></td>
609                 <td valign='top'>Update Template Preview:<br/><pre id='marcPreview'></pre></td>
610             </tr>
611         </table>
612
613         <button dojoType='dijit.form.Button'>Add Merge Rule
614             <script type='dojo/connect' event='onClick'>render_from_template()</script>
615             <script type='dojo/method' event='postCreate'>render_from_template()</script>
616         </button>
617
618         <div class='hide_me' id='ruleTemplate'>
619         <div name='ruleTable'>
620             <table class='ruleTable'>
621                 <tbody>
622                     <tr>
623                         <th style="text-align:center;">Rule Setup</th>
624                         <th style="text-align:center;">Data</th>
625                         <th style="text-align:center;">Help</th>
626                     </tr>
627                     <tr>
628                         <th>Action (Rule Type)</th>
629                         <td name='typeSelectContainer'>
630                             <select name='typeSelect'>
631                                 <option value='r'>Replace</option>
632                                 <option value='a'>Add</option>
633                                 <option value='d'>Delete</option>
634                             </select>
635                         </td>
636                         <td>How to change the existing records</td>
637                     </tr>
638                     <tr>
639                         <th>MARC Tag</th>
640                         <td name='tagContainer'><input style='with: 2em;' name='tag' type='text'></input</td>
641                         <td>Three characters, no spaces, no indicators, etc. eg: 245</td>
642                     </td>
643                     <tr>
644                         <th>Subfields (optional)</th>
645                         <td name='sfContainer'><input name='sf' type='text'/></td>
646                         <td>No spaces, no delimiters, eg: abcnp</td>
647                     </tr>
648                     <tr>
649                         <th>MARC Data</th>
650                         <td name='marcDataContainer'><input name='marcData' type='text'/></td>
651                         <td>MARC-Breaker formatted data with indicators and subfield delimiters, eg:<br/>245 04$aThe End</td>
652                     </tr>
653                     <tr>
654                         <th colspan='3' style='padding-top: 20px; text-align: center;'>Advanced Matching Restriction (Optional)</th>
655                     </tr>
656                     <tr>
657                         <th>Subfield</th>
658                         <td name='matchSFContainer'><input style='with: 2em;' name='matchSF' type='text'></input</td>
659                         <td>A single subfield code, no delimiters, eg: a</td>
660                     <tr>
661                         <th>Regular Expression</th>
662                         <td name='matchREContainer'><input name='matchRE' type='text'/></td>
663                         <td>See <a href="http://perldoc.perl.org/perlre.html#Regular-Expressions" target="_blank">the Perl documentation</a>
664                             for an explanation of Regular Expressions.
665                         </td>
666                     </tr>
667                     <tr>
668                         <td colspan='3' style='padding-top: 20px; text-align: center;'>
669                             <button name='removeButton'>Remove this Template Rule</button>
670                         </td>
671                     </tr>
672                 </tbody>
673             </table>
674         <hr/>
675         </div>
676         </div>
677
678     </body>
679 </html>
680 HTML
681
682     return Apache2::Const::OK;
683 }
684
685 1;
686
687