2 use strict; use warnings;
4 use OpenILS::Utils::Fieldmapper;
6 my $map = $Fieldmapper::fieldmap;
8 # if a true value is provided, we generate the web (light) version of the fieldmapper
10 # List of classes needed by the opac
11 my @web_hints = qw/ex mvr au aou aout asv asva asvr asvq
12 circ acp acpl acn ccs perm_ex ahn ahr aua ac
13 actscecm crcd crmf crrf mus mbts aoc aus/;
17 // ----------------------------------------------------------------
18 // Autogenerated by fieldmapper.pl
20 // ----------------------------------------------------------------
22 function Fieldmapper() {}
24 var errorstr = "Attempt to build fieldmapper object with non-array";
26 Fieldmapper.prototype.clone = function() {
27 var obj = new this.constructor();
29 for( var i in this.a ) {
30 var thing = this.a[i];
31 if(thing == null) continue;
33 if( thing._isfieldmapper ) {
34 obj.a[i] = thing.clone();
37 if(instanceOf(thing, Array)) {
38 obj.a[i] = new Array();
40 for( var j in thing ) {
42 if( thing[j]._isfieldmapper )
43 obj.a[i][j] = thing[j].clone();
45 obj.a[i][j] = thing[j];
55 function FMEX(message) { this.message = message; }
56 FMEX.toString = function() { return "FieldmapperException: " + this.message + "\\n"; }
62 for my $object (keys %$map) {
65 my $hint = $map->{$object}->{hint};
66 next unless (grep { $_ eq $hint } @web_hints );
69 my $short_name = $map->{$object}->{hint};
72 for my $field (keys %{$map->{$object}->{fields}}) {
73 my $position = $map->{$object}->{fields}->{$field}->{position};
74 $fields[$position] = $field;
77 print "_c[\"$short_name\"] = [";
78 for my $f (@fields) { print "\"$f\","; }
89 string += cl + ".prototype = new Fieldmapper(); " +
90 cl + ".prototype.constructor = " + cl + ";" +
91 cl + ".baseClass = Fieldmapper.constructor;" +
92 "function " + cl + "(a) { " +
93 "this.classname = \\\"" + cl + "\\\";" +
94 "this._isfieldmapper = true;" +
95 "if(a) { if(a.constructor == Array) this.a = a; else throw new FMEX(errorstr);} else this.a = []}";
97 string += cl + "._isfieldmapper=true;";
99 for( var pos in _c[cl] ) {
100 var field = _c[cl][pos];
101 string += cl + ".prototype." + field +
102 "=function(n){if(arguments.length == 1)this.a[" +
103 pos + "]=n;return this.a[" + pos + "];};";