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 = ("mvr", "au", "aou","aout", "asv", "asva", "asvr", "asvq");
15 // ----------------------------------------------------------------
16 // Autogenerated by fieldmapper.pl
18 // ----------------------------------------------------------------
20 function FieldmapperException(message) {
21 this.message = message;
23 FieldmapperException.toString = function() {
24 return "FieldmapperException: " + this.message + "\\n";
30 for my $object (keys %$map) {
33 my $hint = $map->{$object}->{hint};
34 next unless (grep { $_ eq $hint } @web_hints );
35 #next unless( $hint eq "mvr" or $hint eq "aou" or $hint eq "aout" );
38 my $short_name = $map->{$object}->{hint};
42 // ----------------------------------------------------------------
44 // ----------------------------------------------------------------
50 function $short_name(array) {
52 this.classname = "$short_name";
53 this._isfieldmapper = true;
56 if( array.constructor == Array)
60 throw new FieldmapperException(
61 "Attempt to build fieldmapper object with non-array");
63 } else { this.array = []; }
67 $short_name._isfieldmapper = true;
69 $short_name.prototype.clone = function() {
70 var obj = new $short_name();
72 for( var i in this.array ) {
73 var thing = this.array[i];
74 if(thing == null) continue;
76 if( thing._isfieldmapper ) {
77 obj.array[i] = thing.clone();
80 if(instanceOf(thing, Array)) {
81 obj.array[i] = new Array();
83 for( var j in thing ) {
85 if( thing[j]._isfieldmapper )
86 obj.array[i][j] = thing[j].clone();
88 obj.array[i][j] = thing[j];
101 for my $field (keys %{$map->{$object}->{fields}}) {
103 my $position = $map->{$object}->{fields}->{$field}->{position};
106 $short_name.prototype.$field = function(new_value) {
107 if(arguments.length == 1) { this.array[$position] = new_value; }
108 return this.array[$position];