From 7377273b54b60110bb061153f01bd1e72eb6e6ae Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 18 Jun 2012 11:42:50 +0200 Subject: [PATCH] 8263 Consistent stylesheet prefs Content-Type: text/plain; charset="utf-8" This patch makes the use of opaccolorstylesheet and opaclayoutstylesheet more consistent. They may be: 1) just a file name, 2) a complete local path or 3) a full URL starting with http: for a remote css file. This makes the syspref opacstylesheet that was only used for a remote css file obsolete. --- C4/Auth.pm | 30 ++++---------------- C4/Templates.pm | 7 ++-- admin/systempreferences.pl | 1 - installer/data/mysql/sysprefs.sql | 1 - .../prog/en/modules/admin/preferences/opac.pref | 9 +---- .../opac-tmpl/prog/en/includes/doc-head-close.inc | 17 +++++++---- opac/opac-authoritiesdetail.pl | 2 - 7 files changed, 22 insertions(+), 45 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index c97046a..e2d8b32 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -386,16 +386,8 @@ sub get_template_and_user { } elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { $opac_name = C4::Context->userenv->{'branch'}; } - my $checkstyle = C4::Context->preference("opaccolorstylesheet"); - if ($checkstyle =~ /http/) - { - $template->param( opacexternalsheet => $checkstyle); - } else - { - my $opaccolorstylesheet = C4::Context->preference("opaccolorstylesheet"); - $template->param( opaccolorstylesheet => $opaccolorstylesheet); - } $template->param( + opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), AmazonContent => "" . C4::Context->preference("AmazonContent"), AnonSuggestions => "" . C4::Context->preference("AnonSuggestions"), AuthorisedValueImages => C4::Context->preference("AuthorisedValueImages"), @@ -438,7 +430,6 @@ sub get_template_and_user { hidelostitems => C4::Context->preference("hidelostitems"), mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '', opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), - opacstylesheet => "" . C4::Context->preference("opacstylesheet"), opacbookbag => "" . C4::Context->preference("opacbookbag"), opaccredits => "" . C4::Context->preference("opaccredits"), OpacFavicon => C4::Context->preference("OpacFavicon"), @@ -943,19 +934,12 @@ sub checkauth { } my $template_name = ( $type eq 'opac' ) ? 'opac-auth.tmpl' : 'auth.tmpl'; - my $template = C4::Templates::gettemplate( $template_name, $type, $query ); - $template->param(branchloop => \@branch_loop,); - my $checkstyle = C4::Context->preference("opaccolorstylesheet"); - if ($checkstyle =~ /\//) - { - $template->param( opacexternalsheet => $checkstyle); - } else - { - my $opaccolorstylesheet = C4::Context->preference("opaccolorstylesheet"); - $template->param( opaccolorstylesheet => $opaccolorstylesheet); - } + my $template = C4::Templates::gettemplate($template_name, $type, $query ); $template->param( - login => 1, + branchloop => \@branch_loop, + opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), + opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"), + login => 1, INPUTS => \@inputs, casAuthentication => C4::Context->preference("casAuthentication"), suggestion => C4::Context->preference("suggestion"), @@ -968,7 +952,6 @@ sub checkauth { OpacFavicon => C4::Context->preference("OpacFavicon"), opacreadinghistory => C4::Context->preference("opacreadinghistory"), opacsmallimage => C4::Context->preference("opacsmallimage"), - opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"), opaclanguagesdisplay => C4::Context->preference("opaclanguagesdisplay"), opacuserjs => C4::Context->preference("opacuserjs"), opacbookbag => "" . C4::Context->preference("opacbookbag"), @@ -979,7 +962,6 @@ sub checkauth { opacheader => C4::Context->preference("opacheader"), TagsEnabled => C4::Context->preference("TagsEnabled"), OPACUserCSS => C4::Context->preference("OPACUserCSS"), - opacstylesheet => C4::Context->preference("opacstylesheet"), intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), intranetstylesheet => C4::Context->preference("intranetstylesheet"), diff --git a/C4/Templates.pm b/C4/Templates.pm index 47bda04..e0baf2f 100644 --- a/C4/Templates.pm +++ b/C4/Templates.pm @@ -104,9 +104,10 @@ sub output { ( $self->{interface} ne 'intranet' ? '/opac-tmpl' : '/intranet-tmpl' ); $vars->{theme} = $self->theme; $vars->{opaccolorstylesheet} = - C4::Context->preference('opaccolorstylesheet'); + C4::Context->preference('opaccolorstylesheet'); $vars->{opacsmallimage} = C4::Context->preference('opacsmallimage'); - $vars->{opacstylesheet} = C4::Context->preference('opacstylesheet'); + $vars->{opaclayoutstylesheet} = + C4::Context->preference('opaclayoutstylesheet'); # add variables set via param to $vars for processing # and clean any utf8 mess @@ -211,7 +212,6 @@ sub _get_template_file { my $is_intranet = $interface eq 'intranet'; my $htdocs = C4::Context->config($is_intranet ? 'intrahtdocs' : 'opachtdocs'); my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $interface, $query); - my $opacstylesheet = C4::Context->preference('opacstylesheet'); # if the template doesn't exist, load the English one as a last resort my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; @@ -227,7 +227,6 @@ sub gettemplate { my ( $tmplbase, $interface, $query ) = @_; ($query) or warn "no query in gettemplate"; my $path = C4::Context->preference('intranet_includes') || 'includes'; - my $opacstylesheet = C4::Context->preference('opacstylesheet'); $tmplbase =~ s/\.tmpl$/.tt/; my ($htdocs, $theme, $lang, $filename) = _get_template_file($tmplbase, $interface, $query); diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 3659791..fb5f9ba 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -335,7 +335,6 @@ $tabsysprefs{opaccredits} = "OPAC"; $tabsysprefs{opaclayoutstylesheet} = "OPAC"; $tabsysprefs{OpacNav} = "OPAC"; $tabsysprefs{opacsmallimage} = "OPAC"; -$tabsysprefs{opacstylesheet} = "OPAC"; $tabsysprefs{opacthemes} = "OPAC"; $tabsysprefs{opacuserjs} = "OPAC"; $tabsysprefs{opacheader} = "OPAC"; diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index c4060fe..c9f5f57 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -89,7 +89,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacreadinghistory',1,'If ON, enables display of Patron Circulation History in OPAC','','YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACResultsSidebar','','Define HTML to be included on the search results page, underneath the facets sidebar','70|10','Textarea'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacsmallimage','','Enter a complete URL to an image to replace the default Koha logo','','free'); -INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacstylesheet','','Enter a complete URL to use an alternate layout stylesheet in OPAC','','free'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('opacthemes','prog','Define the current theme for the OPAC interface.','','Themes'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacTopissue',0,'If ON, enables the \'most popular items\' link on OPAC. Warning, this is an EXPERIMENTAL feature, turning ON may overload your server',NULL,'YesNo'); INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacPublic',1,'Turn on/off public OPAC',NULL,'YesNo'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index e4ea15b..372837a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -138,17 +138,12 @@ OPAC: - Include the additional CSS stylesheet - pref: opaccolorstylesheet class: file - - to override specified settings from the default stylesheet (leave blank to disable). Enter a filename or a complete URL beginning with http:// (if the file lives on a remote server). Please note that if you enter a filename, the file should be in the css subdirectory for each active theme and language within the Koha templates directory. + - to override specified settings from the default stylesheet (leave blank to disable). Enter just a filename, a full local path or a complete URL starting with http:// (if the file lives on a remote server). Please note that if you just enter a filename, the file should be in the css subdirectory for each active theme and language within the Koha templates directory. A full local path is expected to start from your HTTP document root. - - Use the CSS stylesheet - pref: opaclayoutstylesheet class: file - - on all pages in the OPAC, instead of the default (leave blank to disable). Please enter filename only. The file should be in the css subdirectory for each active theme and language within the Koha templates directory. - - - - Use the remote CSS stylesheet - - pref: opacstylesheet - class: file - - on all pages in the OPAC, instead of the default. (This should be a complete URL, starting with http://.) + - on all pages in the OPAC, instead of the default css (used when leaving this field blank). Enter just a filename, a full local path or a complete URL starting with http:// (if the file lives on a remote server). Please note that if you just enter a filename, the file should be in the css subdirectory for each active theme and language within the Koha templates directory. A full local path is expected to start from your HTTP document root. - - "Include the following CSS on all pages in the OPAC:" - pref: OPACUserCSS diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc index 8634cfd..f067dc1 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc @@ -3,13 +3,18 @@ -[% IF ( opacstylesheet ) %][% ELSE %] -[% IF ( opaclayoutstylesheet ) %][% ELSE %][% END %][% END %] -[% IF ( opaccolorstylesheet ) %] - +[% SET opaclayoutstylesheet='opac.css' UNLESS opaclayoutstylesheet %] +[% IF (opaclayoutstylesheet.match('^http:|^\/')) %] + +[% ELSE %] + [% END %] -[% IF ( opacexternalsheet ) %] - +[% IF ( opaccolorstylesheet ) %] + [% IF (opaccolorstylesheet.match('^http:|^\/')) %] + + [% ELSE %] + + [% END %] [% END %] [% IF ( opac_css_override ) %] diff --git a/opac/opac-authoritiesdetail.pl b/opac/opac-authoritiesdetail.pl index 6610dfd..e4abeef 100755 --- a/opac/opac-authoritiesdetail.pl +++ b/opac/opac-authoritiesdetail.pl @@ -190,8 +190,6 @@ $template->param( OpacNav => C4::Context->preference("OpacNav"), opaccredits => C4::Context->preference("opaccredits"), opacsmallimage => C4::Context->preference("opacsmallimage"), - opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"), - opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), ); output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.7.6