@@ -, +, @@ * Extends login screen to pass along #hash * Adds JSONP support to C4::Service * Allows XSLT filename to be extracted * Extends humanmsg to allow per-message classes * Fixes XSLT namespace for in-browser rendering and * Adds proper charset to results of svc/bib --- C4/Auth.pm | 2 ++ C4/Service.pm | 16 +++++++-- C4/XSLT.pm | 39 +++++++++++++--------- koha-tmpl/intranet-tmpl/prog/en/css/humanmsg.css | 15 +++++---- .../intranet-tmpl/prog/en/css/staff-global.css | 11 ++++-- .../prog/en/lib/jquery/plugins/humanmsg.js | 29 ++++++++-------- koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt | 8 +++++ .../prog/en/xslt/MARC21slim2intranetResults.xsl | 1 + .../intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl | 2 +- svc/bib | 2 +- 10 files changed, 82 insertions(+), 43 deletions(-) --- a/C4/Auth.pm +++ a/C4/Auth.pm @@ -302,6 +302,8 @@ sub get_template_and_user { $template->param(dateformat => C4::Context->preference('dateformat')) } + $template->param(auth_forwarded_hash => $in->{'query'}->param('auth_forwarded_hash')); + # these template parameters are set the same regardless of $in->{'type'} $template->param( "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, --- a/C4/Service.pm +++ a/C4/Service.pm @@ -55,6 +55,16 @@ BEGIN { our ( $query, $cookie ); +sub _output { + my ( $response, $status ) = @_; + + if ( $query->param( 'callback' ) ) { + output_with_http_headers $query, $cookie, $query->param( 'callback' ) . '(' . $response->output . ');', 'js'; + } else { + output_with_http_headers $query, $cookie, $response->output, 'json', $status; + } +} + =head1 METHODS =head2 init @@ -113,7 +123,7 @@ sub return_error { $response->param( message => $error ) if ( $error ); $response->param( type => $type, %flags ); - output_with_http_headers $query, $cookie, $response->output, 'json', '400 Bad Request'; + _output( $response, '400 Bad Request' ); exit; } @@ -159,7 +169,7 @@ sub return_multi { } $response->param( 'multi' => JSON::true, responses => \@responses_formatted, @flags ); - output_with_http_headers $query, $cookie, $response->output, 'json', '207 Multi-Status'; + _output( $response, '207 Multi-Status' ); } exit; @@ -177,7 +187,7 @@ exit with HTTP status 200. sub return_success { my ( $class, $response ) = @_; - output_with_http_headers $query, $cookie, $response->output, 'json'; + _output( $response ); } =head2 require_params --- a/C4/XSLT.pm +++ a/C4/XSLT.pm @@ -42,6 +42,7 @@ BEGIN { $VERSION = 3.07.00.049; @ISA = qw(Exporter); @EXPORT = qw( + &XSLTGetFilename &XSLTParse4Display &GetURI ); @@ -156,33 +157,34 @@ sub _get_best_default_xslt_filename { return $xslfilename; } -sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; - my $xslfilename = C4::Context->preference($xslsyspref); +sub XSLTGetFilename { + my ( $marcflavour, $xslsyspref ) = @_; + + my $xslfilename = $marcflavour eq C4::Context->preference('marcflavour') ? C4::Context->preference($xslsyspref) : 'default'; if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { my $htdocs; my $theme; my $lang = C4::Templates::_current_language(); my $xslfile; if ($xslsyspref eq "XSLTDetailsDisplay") { - $htdocs = C4::Context->config('intrahtdocs'); - $theme = C4::Context->preference("template"); - $xslfile = C4::Context->preference('marcflavour') . + $htdocs = C4::Context->config('intrahtdocs'); + $theme = C4::Context->preference("template"); + $xslfile = $marcflavour . "slim2intranetDetail.xsl"; } elsif ($xslsyspref eq "XSLTResultsDisplay") { - $htdocs = C4::Context->config('intrahtdocs'); - $theme = C4::Context->preference("template"); - $xslfile = C4::Context->preference('marcflavour') . + $htdocs = C4::Context->config('intrahtdocs'); + $theme = C4::Context->preference("template"); + $xslfile = $marcflavour . "slim2intranetResults.xsl"; } elsif ($xslsyspref eq "OPACXSLTDetailsDisplay") { - $htdocs = C4::Context->config('opachtdocs'); - $theme = C4::Context->preference("opacthemes"); - $xslfile = C4::Context->preference('marcflavour') . + $htdocs = C4::Context->config('opachtdocs'); + $theme = C4::Context->preference("opacthemes"); + $xslfile = $marcflavour . "slim2OPACDetail.xsl"; } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") { - $htdocs = C4::Context->config('opachtdocs'); - $theme = C4::Context->preference("opacthemes"); - $xslfile = C4::Context->preference('marcflavour') . + $htdocs = C4::Context->config('opachtdocs'); + $theme = C4::Context->preference("opacthemes"); + $xslfile = $marcflavour . "slim2OPACResults.xsl"; } $xslfilename = _get_best_default_xslt_filename($htdocs, $theme, $lang, $xslfile); @@ -193,6 +195,13 @@ sub XSLTParse4Display { $xslfilename =~ s/\{langcode\}/$lang/; } + return $xslfilename; +} + +sub XSLTParse4Display { + my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; + my $xslfilename = XSLTGetFilename( C4::Context->preference( 'marcflavour' ), $xslsyspref ); + # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); #return $record->as_formatted(); --- a/koha-tmpl/intranet-tmpl/prog/en/css/humanmsg.css +++ a/koha-tmpl/intranet-tmpl/prog/en/css/humanmsg.css @@ -9,6 +9,7 @@ html, body { } .humanMsg { + border-radius: 5px; font: normal 20px/50px Helvetica, Arial, Sans-Serif; letter-spacing: -1px; position: fixed; @@ -23,6 +24,14 @@ html, body { z-index: 100000; } +.humanError { + background-color: #400; +} + +.humanSuccess { + background-color: #040; +} + .humanMsg h3 { margin: 0.3em; margin-top: 0; @@ -30,12 +39,6 @@ html, body { font-weight: bold; } -.humanMsg .round { - border-left: solid 2px white; - border-right: solid 2px white; - font-size: 1px; height: 2px; - } - .humanMsg p { margin: 0.3em; } --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -399,13 +399,18 @@ dd { font-weight : normal; } -div#toolbar { +.btn-toolbar { background-color : #EDF4F6; padding: 5px 5px 5px 5px; border-radius: 5px 5px 0 0; border: 1px solid #E6F0F2; } +.btn-toolbar .yui-menu-button button, +.btn-toolbar .yui-button-button button { + line-height : 1.7em; +} + ul.toolbar { padding-left : 0; } @@ -2436,8 +2441,8 @@ video { background-position:-48px -166px; } -#toolbar .btn, -#toolbar .dropdown-menu { +.btn-toolbar .btn, +.btn-toolbar .dropdown-menu { font-size: 13px; } a.btn:link, --- a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/humanmsg.js +++ a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/humanmsg.js @@ -21,7 +21,7 @@ var humanMsg = { if (msgOpacity != undefined) humanMsg.msgOpacity = parseFloat(msgOpacity); // Inject the message structure - jQuery(appendTo).append('

'+logName+'

') + jQuery(appendTo).append('

'+logName+'

'); jQuery('#'+humanMsg.logID+' p').click( function() { jQuery(this).siblings('ul').slideToggle() } @@ -29,28 +29,29 @@ var humanMsg = { }, displayAlert: function(msg, options) { - humanMsg.displayMsg(msg, options, true); + humanMsg.displayMsg('

' + msg + '

', $.extend({log: false}, options), true); }, - displayMsg: function(msg, options, is_alert) { + displayMsg: function(msg, options) { if (msg == '') return; - if (options != undefined) { - delay = 'delay' in options ? parseInt(options.delay) * 1000 : 1000 - life = 'life' in options ? parseInt(options.life) * 1000 : Infinity - } else { - delay = 1000 - life = Infinity - } + options = $.extend({ + delay: 1000, + life: Infinity, + log: true, + className: '', + }, options); + clearTimeout(humanMsg.t1); clearTimeout(humanMsg.t2); // Inject message - jQuery('#'+humanMsg.msgID+'-contents').html(is_alert ? ('

' + msg + '

') : msg) + jQuery('#'+humanMsg.msgID+'-contents').html(msg); // Show message - jQuery('#'+humanMsg.msgID).show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { + jQuery('#'+humanMsg.msgID).attr('class', 'humanMsg ' + options.className).show().animate({ opacity: humanMsg.msgOpacity}, 200, function() { + if ( !options.log ) return true; jQuery('#'+humanMsg.logID) .show().children('ul').prepend('
  • '+msg+'
  • ') // Prepend message to log .children('li:first').slideDown(200) // Slide it down @@ -64,9 +65,9 @@ var humanMsg = { }) // Watch for mouse & keyboard in `delay` - humanMsg.t1 = setTimeout("humanMsg.bindEvents()", delay) + humanMsg.t1 = setTimeout("humanMsg.bindEvents()", options.delay) // Remove message after `life` - humanMsg.t2 = setTimeout("humanMsg.removeMsg()", life) + humanMsg.t2 = setTimeout("humanMsg.removeMsg()", options.life) }, bindEvents: function() { --- a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/auth.tt @@ -78,4 +78,12 @@ + + [% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl +++ a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl @@ -5,6 +5,7 @@ xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:items="http://www.koha-community.org/items" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="marc items"> --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl +++ a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl @@ -1,6 +1,6 @@ ]> - + --- a/svc/bib +++ a/svc/bib @@ -62,7 +62,7 @@ sub fetch_bib { my $biblionumber = shift; my $record = GetMarcBiblio( $biblionumber, $query->url_param('items') ); if (defined $record) { - print $query->header(-type => 'text/xml'); + print $query->header(-type => 'text/xml', -charset => 'utf-8'); print $record->as_xml_record(); } else { print $query->header(-type => 'text/xml', -status => '404 Not Found'); --