Bugzilla – Attachment 130067 Details for
Bug 29695
Centralize columns' descriptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29695: Remove C4::Reports::Guided::_get_column_defs
Bug-29695-Remove-C4ReportsGuidedgetcolumndefs.patch (text/plain), 5.02 KB, created by
Jonathan Druart
on 2022-02-02 09:47:51 UTC
(
hide
)
Description:
Bug 29695: Remove C4::Reports::Guided::_get_column_defs
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-02 09:47:51 UTC
Size:
5.02 KB
patch
obsolete
>From af578746f42569d4a89310323a4e20c59715eed8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Dec 2021 15:52:22 +0100 >Subject: [PATCH] Bug 29695: Remove C4::Reports::Guided::_get_column_defs > >This subroutine was mostly the same as GetColumnDefs, we replace it >identically as in the previous patch. > >Test plan: >Translate some strings in another language > % gulp po:update --lang es-ES > % cd misc/translate > # Translate the relevant strings in po/es-ES-messages.po > # For instance "Alternate contact: Surname" > % perl translate install es-ES > >Select the language for the interface (enable it in the 'language' syspref >first) > >Create a new guided report and confirm that the columns for the borrowers >table are translated >--- > C4/Reports/Guided.pm | 49 ++++++++++++-------------------------------- > 1 file changed, 13 insertions(+), 36 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index 8a6964446b1..903cf551de3 100644 >--- a/C4/Reports/Guided.pm >+++ b/C4/Reports/Guided.pm >@@ -32,6 +32,7 @@ use C4::Output; > use C4::Log qw( logaction ); > use Koha::Notice::Templates; > >+use Koha::Database::Columns; > use Koha::Logger; > use Koha::AuthorisedValues; > use Koha::Patron::Categories; >@@ -212,7 +213,7 @@ sub _get_columns { > my $sth = $dbh->prepare("show columns from $tablename"); > $sth->execute(); > my @columns; >- my $column_defs = _get_column_defs($cgi); >+ my $columns = Koha::Database::Columns->columns; > my %tablehash; > $tablehash{'table'}=$tablename; > $tablehash{'__first__'} = $first; >@@ -220,7 +221,7 @@ sub _get_columns { > while ( my $data = $sth->fetchrow_arrayref() ) { > my %temphash; > $temphash{'name'} = "$tablename.$data->[0]"; >- $temphash{'description'} = $column_defs->{"$tablename.$data->[0]"}; >+ $temphash{'description'} = $columns->{$tablename}->{$data->[0]}; > push @columns, \%temphash; > } > $sth->finish(); >@@ -353,25 +354,26 @@ sub get_criteria { > > > my $crit = $criteria{$area}; >- my $column_defs = _get_column_defs($cgi); >+ my $columns = Koha::Database::Columns->columns; > my @criteria_array; > foreach my $localcrit (@$crit) { > my ( $value, $type ) = split( /\|/, $localcrit ); > my ( $table, $column ) = split( /\./, $value ); >+ my $description = $columns->{$table}->{$column}; > if ($type eq 'textrange') { > my %temp; > $temp{'name'} = $value; > $temp{'from'} = "from_" . $value; > $temp{'to'} = "to_" . $value; > $temp{'textrange'} = 1; >- $temp{'description'} = $column_defs->{$value}; >+ $temp{'description'} = $description; > push @criteria_array, \%temp; > } > elsif ($type eq 'date') { > my %temp; > $temp{'name'} = $value; > $temp{'date'} = 1; >- $temp{'description'} = $column_defs->{$value}; >+ $temp{'description'} = $description; > push @criteria_array, \%temp; > } > elsif ($type eq 'daterange') { >@@ -380,7 +382,7 @@ sub get_criteria { > $temp{'from'} = "from_" . $value; > $temp{'to'} = "to_" . $value; > $temp{'daterange'} = 1; >- $temp{'description'} = $column_defs->{$value}; >+ $temp{'description'} = $description; > push @criteria_array, \%temp; > } > else { >@@ -407,12 +409,11 @@ sub get_criteria { > } > $sth->finish(); > >- my %temp; >- $temp{'name'} = $value; >- $temp{'description'} = $column_defs->{$value}; >- $temp{'values'} = \@values; >- >- push @criteria_array, \%temp; >+ push @criteria_array, { >+ name => $value, >+ description => $description, >+ values => \@values, >+ }; > } > } > return ( \@criteria_array ); >@@ -896,30 +897,6 @@ sub get_results { > |, { Slice => {} }, $report_id); > } > >-sub _get_column_defs { >- my ($cgi) = @_; >- my %columns; >- my $columns_def_file = "columns.def"; >- my $htdocs = C4::Context->config('intrahtdocs'); >- my $section = 'intranet'; >- >- # We need the theme and the lang >- # Since columns.def is not in the modules directory, we cannot sent it for the $tmpl var >- my ($theme, $lang, $availablethemes) = C4::Templates::themelanguage($htdocs, 'about.tt', $section, $cgi); >- >- my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; >- open (my $fh, '<:encoding(utf-8)', $full_path_to_columns_def_file); >- while ( my $input = <$fh> ){ >- chomp $input; >- if ( $input =~ m|<field name="(.*)">(.*)</field>| ) { >- my ( $field, $translation ) = ( $1, $2 ); >- $columns{$field} = $translation; >- } >- } >- close $fh; >- return \%columns; >-} >- > =head2 GetReservedAuthorisedValues > > my %reserved_authorised_values = GetReservedAuthorisedValues(); >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29695
:
128522
|
128523
|
128524
|
128525
|
128526
|
128527
|
128528
|
128529
|
128559
|
128560
|
128561
|
128562
|
128563
|
128564
|
128565
|
130065
|
130066
|
130067
|
130068
|
130069
|
130070
|
130071
|
130107
|
130108
|
130109
|
130110
|
130111
|
130112
|
130113
|
131918
|
131919
|
131920
|
131921
|
131922
|
131923
|
131924
|
131925