From aa33fc0ef3f2d80de7474a6815ee629c9d0fca8a Mon Sep 17 00:00:00 2001 From: Bill Erickson <berick@esilibrary.com> Date: Fri, 16 Mar 2012 12:00:58 -0400 Subject: [PATCH] kpac : config and template work Signed-off-by: Bill Erickson <berick@esilibrary.com> Signed-off-by: Mike Rylander <mrylander@gmail.com> --- Open-ILS/examples/apache/eg_vhost.conf | 1 + Open-ILS/examples/{kpac.xml => kpac.xml.example} | 0 Open-ILS/src/Makefile.am | 1 + .../src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm | 57 ++++++++++++++++------ Open-ILS/src/templates/kpac/getit.tt2 | 26 +++++----- 5 files changed, 59 insertions(+), 26 deletions(-) rename Open-ILS/examples/{kpac.xml => kpac.xml.example} (100%) diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf index 5d5551be8e..62980a2783 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf +++ b/Open-ILS/examples/apache/eg_vhost.conf @@ -603,6 +603,7 @@ RewriteRule ^/openurl$ ${openurl:%1} [NE,PT] # Expire the HTML quickly since we're loading dynamic data for each page ExpiresActive On ExpiresByType text/html "access plus 5 seconds" + PerlSetVar KPacConfigFile "/openils/conf/kpac.xml.example" # For use with embedded Content Cafe content #SetEnv OILS_CONTENT_CAFE_USER 123 diff --git a/Open-ILS/examples/kpac.xml b/Open-ILS/examples/kpac.xml.example similarity index 100% rename from Open-ILS/examples/kpac.xml rename to Open-ILS/examples/kpac.xml.example diff --git a/Open-ILS/src/Makefile.am b/Open-ILS/src/Makefile.am index d250f58c47..8fe83020ff 100644 --- a/Open-ILS/src/Makefile.am +++ b/Open-ILS/src/Makefile.am @@ -46,6 +46,7 @@ sysconf_DATA = $(examples)/action_trigger_filters.json.example \ $(examples)/oils_sip.xml.example \ $(examples)/lib_ips.txt.example \ $(examples)/oils_yaz.xml.example \ + $(examples)/kpac.xml.example \ $(examples)/oils_z3950.xml.example #---------------------------- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm index 34a81f6278..7622374247 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGKPacLoader.pm @@ -15,9 +15,9 @@ my $kpac_config; sub load { my $self = shift; - $self->init_ro_object_cache; + $self->init_ro_object_cache; - my $stat = $self->load_common; + my $stat = $self->load_common; return $stat unless $stat == Apache2::Const::OK; $self->load_kpac_config; @@ -27,22 +27,16 @@ sub load { return $self->load_simple("home") if $path =~ m|kpac/home|; return $self->load_simple("category") if $path =~ m|kpac/category|; - return $self->load_rresults if $path =~ m|kpac/results|; # inherited - return $self->load_record(no_search => 1) if $path =~ m|kpac/record|; # inherited + return $self->load_rresults if $path =~ m|kpac/results|; + return $self->load_record(no_search => 1) if $path =~ m|kpac/record|; # ---------------------------------------------------------------- # Everything below here requires SSL # ---------------------------------------------------------------- return $self->redirect_ssl unless $self->cgi->https; - # XXX auth vs. no-auth, pending list answers return $self->load_simple("getit_results") if $path =~ m|kpac/getit_results|; - - if ($path =~ m|kpac/getit|) { # after getit_results - my $stat = $self->load_record(no_search => 1); - $self->ctx->{page} = 'getit'; # repair the page - return $stat; - } + return $self->load_getit if $path =~ m|kpac/getit|; # ---------------------------------------------------------------- # Everything below here requires authentication @@ -54,12 +48,46 @@ sub load { return Apache2::Const::OK; } +sub load_getit { + my $self = shift; + my $ctx = $self->ctx; + + # first load the record + my $stat = $self->load_record(no_search => 1); + return $stat unless $stat == Apache2::Const::OK; + + $self->ctx->{page} = 'getit'; # repair the page + + # if the user is logged in, fetch his bookbags + if ($ctx->{user}) { + $ctx->{bookbags} = $self->editor->search_container_biblio_record_entry_bucket( + [{ + owner => $ctx->{user}->id, + btype => 'bookbag' + }, { + order_by => {cbreb => 'name'}, + limit => $self->cgi->param('bbag_limit') || 100, + }], + {substream => 1} + ); + } + + $self->ctx->{page} = 'getit'; # repair the page + return Apache2::Const::OK; +} + sub load_kpac_config { my $self = shift; - my $path = '/home/berick/code/Evergreen/Open-ILS/examples/kpac.xml'; # TODO: apache config - unless ($kpac_config) { + if (!$kpac_config) { + my $path = $self->apache->dir_config('KPacConfigFile'); + + if (!$path) { + $self->apache->log->error("KPacConfigFile required!"); + return; + } + $kpac_config = XMLin( $path, KeyAttr => ['id'], @@ -68,8 +96,7 @@ sub load_kpac_config { ); } - # TODO: make generic "whereami" sub for EGCatLoader. - my $ou = $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id; + my $ou = $self->ctx->{physical_loc} || $self->_get_search_lib; my $layout; # Search up the org tree to find the nearest config for the context org unit diff --git a/Open-ILS/src/templates/kpac/getit.tt2 b/Open-ILS/src/templates/kpac/getit.tt2 index 71ab91b800..d665da5b5f 100644 --- a/Open-ILS/src/templates/kpac/getit.tt2 +++ b/Open-ILS/src/templates/kpac/getit.tt2 @@ -75,22 +75,26 @@ </div> </td> - <!-- TODO --> <td valign="top"> <div class="right_brain"> <div class="top_side"> - <h2>save it!</h2> - <p>If you would like to save this item to a list to be requested later, please choose a location and click<br />Submit below.</p> + <h2>[% l('save it!') %]</h2> + <p>[% l('If you would like to save this item to a list to be requested later, please choose a location and click <br/>Submit below.') %]</p> </div> - <div class="checkout_box"> - <div class="box1_top"> </div> - <div class="box_inside"> - <p>Choose a Pickup Library:</p> - <div class="pickup_lib"><select name="library"><option>Fairwood</option></select></div> - <div class="hr"> </div> - <div><a href="javascript:;">View all KCLS libraries</a></div> + [% IF ctx.user AND ctx.bookbags.size > 0 %] + <div class="checkout_box"> + <div class="box1_top"> </div> + <div class="box_inside"> + <p>[% l('Add to one of your lists?') %]</p> + <select name='bookbag'> + <option selected='selected'>[% l('-- Select a List --') %]</option> + [% FOR bbag IN ctx.bookbags %] + <option value="[% bbag.id %]">[% bbag.name | html %]</option> + [% END %] + </select> + </div> </div> - </div> + [% END %] <div class="submit_btn"> <a href="javascript:;"><img src="[% ctx.media_prefix %]/images/kpac/review_submit_btn.png" alt="submit" /></a> </div> -- 2.11.0