From 05d4c0e69b13a4d3500300bf027144979af813cd Mon Sep 17 00:00:00 2001 From: Bernardo Gonzalez Kriegel Date: Fri, 26 Jun 2015 16:13:52 -0300 Subject: [PATCH] Bug 12194: Add option 'Oblique title' in labels MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds a checkbox on Label creator to use or not an oblique variant of main font for title Also fix font selection for title in case an oblique variant is used. To test: Before patch 1) Go to Tools > Label creator 2) Create a new layout, default values but select any 'Oblique' variant for main font and 'Biblio/Barcode' for layout type 3) Go to Manage batches, create a batch, add items, export PDF, download 4) Check logs, you must find a line with 'ERROR in koha-conf.xml -- missing ' for example if main font Courier-Oblique 5) Open PDF, title could be right but not using selected font After patch 6) Apply the patch 7) Run updatedatabase.pl 8) Repeat 1-2, note new checkbox 'Oblique title', default checked 9) Repeat export, no new warnings on log 10) Create a new layout or edit an existent one, uncheck 'Oblique title', save, export again Check PDF has non slanted title Followed test plan, works as expected. (See comment #11). Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- C4/Creators/Layout.pm | 2 ++ C4/Labels/Label.pm | 16 ++++++++++++++-- .../bug-12194-add-column-oblique_title.sql | 10 ++++++++++ .../en/modules/labels/label-edit-layout.tt | 19 ++++++++++++++++++- labels/label-create-pdf.pl | 3 +++ labels/label-edit-layout.pl | 2 ++ 6 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug-12194-add-column-oblique_title.sql diff --git a/C4/Creators/Layout.pm b/C4/Creators/Layout.pm index a660ef6a4a..cf0b751eff 100644 --- a/C4/Creators/Layout.pm +++ b/C4/Creators/Layout.pm @@ -33,6 +33,7 @@ sub _check_params { 'printing_type', 'layout_name', 'guidebox', + 'oblique_title', 'font', 'font_size', 'callnum_split', @@ -78,6 +79,7 @@ sub new { printing_type => 'BAR', layout_name => 'DEFAULT', guidebox => 0, + oblique_title => 1, font => 'TR', font_size => 3, callnum_split => 0, diff --git a/C4/Labels/Label.pm b/C4/Labels/Label.pm index 271c6bcfcd..ca12437412 100644 --- a/C4/Labels/Label.pm +++ b/C4/Labels/Label.pm @@ -35,6 +35,7 @@ sub _check_params { 'barcode_type', 'printing_type', 'guidebox', + 'oblique_title', 'font', 'font_size', 'callnum_split', @@ -326,6 +327,7 @@ sub new { barcode_type => $params{'barcode_type'}, printing_type => $params{'printing_type'}, guidebox => $params{'guidebox'}, + oblique_title => $params{'oblique_title'}, font => $params{'font'}, font_size => $params{'font_size'}, callnum_split => $params{'callnum_split'}, @@ -408,8 +410,18 @@ sub draw_label_text { else { $field->{'data'} = _get_barcode_data($field->{'code'},$item,$record); } - #FIXME: We should not force the title to oblique; this should be selectible in the layout configuration - ($field->{'code'} eq 'title') ? (($font =~ /T/) ? ($font = 'TI') : ($font = ($font . 'O'))) : ($font = $font); + # Find apropriate font it oblique title selected, except main font is oblique + if ( ( $field->{'code'} eq 'title' ) and ( $self->{'oblique_title'} == 1 ) ) { + if ( $font =~ /^TB$/ ) { + $font .= 'I'; + } + elsif ( $font =~ /^TR$/ ) { + $font = 'TI'; + } + elsif ( $font !~ /^T/ and $font !~ /O$/ ) { + $font .= 'O'; + } + } my $field_data = $field->{'data'}; if ($field_data) { $field_data =~ s/\n//g; diff --git a/installer/data/mysql/atomicupdate/bug-12194-add-column-oblique_title.sql b/installer/data/mysql/atomicupdate/bug-12194-add-column-oblique_title.sql new file mode 100644 index 0000000000..200379ffb0 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-12194-add-column-oblique_title.sql @@ -0,0 +1,10 @@ +ALTER TABLE creator_layouts ADD COLUMN oblique_title INT(1) NULL DEFAULT 1 AFTER guidebox; + +-- $DBversion = "3.21.00.XXX"; +-- if ( CheckVersion($DBversion) ) { +-- $dbh->do(q| +-- ALTER TABLE creator_layouts ADD COLUMN oblique_title INT(1) NULL DEFAULT 1 AFTER guidebox +-- |); +-- print "Upgrade to $DBversion done (Bug 12194: Add column oblique_title to layouts)\n"; +-- SetVersion($DBversion); +-- } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt index 0b334f2024..b53fa066ec 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/label-edit-layout.tt @@ -25,6 +25,15 @@ $('#layout_string').hide(); } } + function checkOblique() { + var font = document.getElementById("font"); + var selectedfont = font.options[font.selectedIndex].value; + if ( selectedfont.match("I$") || selectedfont.match("O$") ) { + document.getElementById("oblique_title").disabled = true; + } else { + document.getElementById("oblique_title").disabled = false; + } + } //]]> @@ -164,7 +173,7 @@
  • - [% FOREACH font_type IN font_types %] [% IF ( font_type.selected ) %] @@ -178,6 +187,14 @@
  • +
  • + + [% IF ( oblique_title ) %] + + [% ELSE %] + + [% END %] +
  • diff --git a/labels/label-create-pdf.pl b/labels/label-create-pdf.pl index e69ba41e55..5589fb6c54 100755 --- a/labels/label-create-pdf.pl +++ b/labels/label-create-pdf.pl @@ -139,6 +139,7 @@ foreach my $item (@{$items}) { barcode_type => $layout->get_attr('barcode_type'), printing_type => 'BIB', guidebox => $layout->get_attr('guidebox'), + oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), @@ -162,6 +163,7 @@ foreach my $item (@{$items}) { barcode_type => $layout->get_attr('barcode_type'), printing_type => 'BAR', guidebox => $layout->get_attr('guidebox'), + oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), @@ -188,6 +190,7 @@ foreach my $item (@{$items}) { barcode_type => $layout->get_attr('barcode_type'), printing_type => $layout->get_attr('printing_type'), guidebox => $layout->get_attr('guidebox'), + oblique_title => $layout->get_attr('oblique_title'), font => $layout->get_attr('font'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), diff --git a/labels/label-edit-layout.pl b/labels/label-edit-layout.pl index 150ad3d3d7..f84a01dc3a 100755 --- a/labels/label-edit-layout.pl +++ b/labels/label-edit-layout.pl @@ -107,6 +107,7 @@ elsif ($op eq 'save') { printing_type => $cgi->param('printing_type') || 'BAR', layout_name => $cgi->param('layout_name') || 'DEFAULT', guidebox => ($cgi->param('guidebox') ? 1 : 0), + oblique_title => ($cgi->param('oblique_title') ? 1 : 0), font => $cgi->param('font') || 'TR', font_size => $cgi->param('font_size') || 3, callnum_split => ($cgi->param('callnum_split') ? 1 : 0), @@ -145,6 +146,7 @@ $template->param( layout_id => $layout->get_attr('layout_id') > -1 ? $layout->get_attr('layout_id') : '', layout_name => $layout->get_attr('layout_name'), guidebox => $layout->get_attr('guidebox'), + oblique_title => $layout->get_attr('oblique_title'), font_size => $layout->get_attr('font_size'), callnum_split => $layout->get_attr('callnum_split'), format_string => $layout->get_attr('format_string'), -- 2.39.5