2 # turns the orgTree and orgTypes into a static HTML option list
4 use OpenSRF::AppSession;
6 use OpenILS::Utils::Fieldmapper;
7 use OpenSRF::Utils::SettingsClient;
8 use Unicode::Normalize;
10 die "usage: perl org_tree_html_options.pl <bootstrap_config> <output_file>" unless $ARGV[1];
11 OpenSRF::System->bootstrap_client(config_file => $ARGV[0]);
13 open FILE, ">$ARGV[1]";
15 Fieldmapper->import(IDL => OpenSRF::Utils::SettingsClient->new->config_value("IDL"));
17 my $ses = OpenSRF::AppSession->create("open-ils.actor");
18 my $tree = $ses->request("open-ils.actor.org_tree.retrieve")->gather(1);
29 return unless ($node->opac_visible =~ /^[y1t]+/i);
31 my $depth = $node->ou_type - 1;
32 my $sname = entityize($node->shortname);
33 my $name = entityize($node->name);
34 my $kids = $node->children;
36 print FILE "<option value='$sname'>" . '   'x$depth . "$name</option>\n";
37 print_option($_) for (@$kids);
41 my $stuff = shift || return "";
42 $stuff =~ s/\</</og;
43 $stuff =~ s/\>/>/og;
44 $stuff =~ s/\&/&/og;
46 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;