Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

8263 Consistent stylesheet prefs

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.

June 20, 2012 Rebased.
July 18, 2012: Regex allows https too (thanks to Owen Leonard).

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
  • Loading branch information...
commit daeb9649966e260d9d8ecea9675faaa2940808bc 1 parent 688e81f
@mderooy mderooy authored PaulPoulain committed
View
30 C4/Auth.pm
@@ -388,16 +388,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"),
@@ -441,7 +433,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"),
@@ -946,19 +937,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"),
@@ -972,7 +956,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"),
@@ -983,7 +966,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"),
View
7 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);
View
1  admin/systempreferences.pl
@@ -335,7 +335,6 @@ =head1 systempreferences.pl
$tabsysprefs{opaclayoutstylesheet} = "OPAC";
$tabsysprefs{OpacNav} = "OPAC";
$tabsysprefs{opacsmallimage} = "OPAC";
-$tabsysprefs{opacstylesheet} = "OPAC";
$tabsysprefs{opacthemes} = "OPAC";
$tabsysprefs{opacuserjs} = "OPAC";
$tabsysprefs{opacheader} = "OPAC";
View
1  installer/data/mysql/sysprefs.sql
@@ -90,7 +90,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');
View
9 koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ -151,17 +151,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 <code>http://</code> (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 <code>http://</code> (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 <code>http://</code>.)
+ - 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 <code>http://</code> (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
View
17 koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
@@ -3,13 +3,18 @@
<meta name="generator" content="Koha [% Version %]" /> <!-- leave this for stats -->
<link rel="shortcut icon" href="[% IF ( OpacFavicon ) %][% OpacFavicon %][% ELSE %][% themelang %]/includes/favicon.ico[% END %]" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="[% themelang %]/lib/jquery/jquery-ui.css" />
-[% IF ( opacstylesheet ) %]<link rel="stylesheet" type="text/css" href="[% opacstylesheet %]" />[% ELSE %]
-[% IF ( opaclayoutstylesheet ) %]<link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opaclayoutstylesheet %]" />[% ELSE %]<link rel="stylesheet" type="text/css" href="[% themelang %]/css/opac.css" />[% END %][% END %]
-[% IF ( opaccolorstylesheet ) %]
- <link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opaccolorstylesheet %]" />
+[% SET opaclayoutstylesheet='opac.css' UNLESS opaclayoutstylesheet %]
+[% IF (opaclayoutstylesheet.match('^https?:|^\/')) %]
+ <link rel="stylesheet" type="text/css" href="[% opaclayoutstylesheet %]" />
+[% ELSE %]
+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opaclayoutstylesheet %]" />
[% END %]
-[% IF ( opacexternalsheet ) %]
- <link rel="stylesheet" type="text/css" href="[% opacexternalsheet %]" />
+[% IF ( opaccolorstylesheet ) %]
+ [% IF (opaccolorstylesheet.match('^https?:|^\/')) %]
+ <link rel="stylesheet" type="text/css" href="[% opaccolorstylesheet %]" />
+ [% ELSE %]
+ <link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opaccolorstylesheet %]" />
+ [% END %]
[% END %]
[% IF ( opac_css_override ) %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/[% opac_css_override %]" />
Please sign in to comment.
Something went wrong with that request. Please try again.