From 883cedf652937679837c1c7689652996e23ccd1e Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 2 Nov 2007 13:25:45 +0000 Subject: [PATCH] adding entity encoding directly to the script, along with comment tracers git-svn-id: svn://svn.open-ils.org/ILS/trunk@7970 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/org_tree_js.pl | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Open-ILS/src/extras/org_tree_js.pl b/Open-ILS/src/extras/org_tree_js.pl index c16af515c6..fab85fa7e9 100644 --- a/Open-ILS/src/extras/org_tree_js.pl +++ b/Open-ILS/src/extras/org_tree_js.pl @@ -37,6 +37,8 @@ sub val { return 1 if $v eq 't'; return 0 if $v eq 'f'; + $v =~ s/([\x{0080}-\x{fffd}])/sprintf('\u%04x',ord($1))/sgoe; + return "\"$v\""; } @@ -44,30 +46,24 @@ my $pile = "var _l = ["; my @array; for my $o (@$tree) { - my ($i,$t,$p,$n,$v) = ($o->id,$o->ou_type,val($o->parent_ou),$o->name,val($o->opac_visible)); + my ($i,$t,$p,$n,$v) = ($o->id,$o->ou_type,$o->parent_ou,val($o->name),val($o->opac_visible)); $p ||= 'null'; - push @array, "[$i,$t,$p,\"$n\",$v]"; + push @array, "[$i,$t,$p,$n,$v]"; } $pile .= join ',', @array; -$pile .= "];\n"; +$pile .= "]; /* Org Units */ \n"; $pile .= 'globalOrgTypes = ['; for my $t (@$types) { - $pile .= 'new aout([null,null,null,null,'. - val($t->can_have_users).','. - val($t->can_have_vols).','. - val($t->depth).','. - val($t->id).','. - val($t->name).','. - val($t->opac_label).','. - val($t->parent).']), '; + my ($u,$v,$d,$i,$n,$o,$p) = (val($t->can_have_users),val($t->can_have_vols),$t->depth,$t->id,val($t->name),val($t->opac_label),$t->parent); + $p ||= 'null'; + $pile .= "new aout([null,null,null,null,$u,$v,$d,$i,$n,$o,$p]), "; } $pile =~ s/, $//; # remove trailing comma -$pile .= '];'; +$pile .= ']; /* OU Types */'; -binmode STDOUT, ':utf8'; print "$pile\n"; -- 2.11.0