Bugzilla – Attachment 149957 Details for
Bug 24975
Refactor database translations
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24975: WIP remove db_t from controllers
Bug-24975-WIP-remove-dbt-from-controllers.patch (text/plain), 9.62 KB, created by
Jonathan Druart
on 2023-04-20 13:08:03 UTC
(
hide
)
Description:
Bug 24975: WIP remove db_t from controllers
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-20 13:08:03 UTC
Size:
9.62 KB
patch
obsolete
>From 735b0b91d2526a2c069f146b8d1a484d98113e93 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 20 Apr 2023 15:06:25 +0200 >Subject: [PATCH] Bug 24975: WIP remove db_t from controllers > >This is not done yet, for discussion. I don't think we should call db_t >in controllers, or we do it better, but now it's confusing. > >This patch may impact performances, as we are not caching the itemtype >object. > >Ideas? >--- > C4/Search.pm | 1 + > catalogue/moredetail.pl | 10 ++++----- > .../prog/en/modules/catalogue/moredetail.tt | 5 +++-- > .../bootstrap/en/modules/opac-detail.tt | 22 ++++++++++--------- > opac/opac-detail.pl | 14 ++---------- > 5 files changed, 23 insertions(+), 29 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 77e3e6e48cd..b75657f72d4 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -539,6 +539,7 @@ sub getRecords { > && ref( $itemtypes->{$one_facet} ) eq > "HASH" ) > { >+ # FIXME This must call $itemtype->translation_key actually > $facet_label_value = db_t('itemtype', $itemtypes->{$one_facet}->{itemtype}); > } > } >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index 20f58eb318f..51b8e98d638 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -139,10 +139,10 @@ my $ccodes = > my $copynumbers = > { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $fw, kohafield => 'items.copynumber' } ) }; > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >+my $itemtypes = { map { $_->itemtype => $_ } @{ Koha::ItemTypes->search->as_list } }; >+ >+$data->{itemtype} = $itemtypes->{ $data->{itemtype} }; > >-$data->{'itemtypename'} = db_t('itemtype', $itemtypes->{ $data->{'itemtype'} }->{itemtype}) >- if $data->{itemtype} && exists $itemtypes->{ $data->{itemtype} }; > foreach ( keys %{$data} ) { > $template->param( "$_" => defined $data->{$_} ? $data->{$_} : '' ); > } >@@ -155,8 +155,8 @@ foreach my $item (@items){ > > my $item_info = $item->unblessed; > $item_info->{object} = $item; >- $item_info->{itype} = db_t('itemtype', $itemtypes->{ $item_info->{itype} }->{itemtype}) if exists $itemtypes->{ $item_info->{itype} }; >- $item_info->{effective_itemtype} = $itemtypes->{$item->effective_itemtype}; >+ $item_info->{itemtype} = $itemtypes->{$item_info->{itype}}; >+ $item_info->{effective_itemtype} = $itemtypes->{$item->effective_itemtype}; > $item_info->{'ccode'} = $ccodes->{ $item->ccode } if $ccodes && $item->ccode && exists $ccodes->{ $item->ccode }; > if ( defined $item->copynumber ) { > $item_info->{'displaycopy'} = 1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index b220f58002d..131875851bc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -4,6 +4,7 @@ > [% USE Koha %] > [% USE Branches %] > [% USE Price %] >+[% USE ItemTypes %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Item details for [% INCLUDE 'biblio-title-head.inc' %] › Catalog › Koha</title> >@@ -53,7 +54,7 @@ > <ol class="bibliodetails"> > <li><span class="label">Biblionumber:</span> [% biblionumber | html %] </li> > [% UNLESS ( item_level_itypes ) %] >- <li><span class="label">Item type:</span> [% itemtypename | html %] </li> >+ <li><span class="label">Item type:</span> [% ItemTypes.t(itemtype.translation_key) | html %] </li> > [% END %] > [% IF ( rentalcharge ) %] > <li><span class="label">Rental charge:</span>[% rentalcharge | $Price %] </li> >@@ -125,7 +126,7 @@ > <ol class="bibliodetails"> > <li><span class="label">Home library:</span> [% Branches.GetName( ITEM_DAT.homebranch ) | html %] </li> > [% IF ( item_level_itypes ) %] >- <li><span class="label">Item type:</span> [% ITEM_DAT.itype | html %] </li> >+ <li><span class="label">Item type:</span> [% ItemTypes.t(ITEM_DAT.itemtype.translation_key) | html %] </li> > [% END %] > [% IF ( ITEM_DAT.ccode) %] > <li><span class="label">Collection:</span> [% ITEM_DAT.ccode | html %]</li> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index ab2f28e6158..836dd4e2dbc 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -6,6 +6,7 @@ > [% USE Branches %] > [% USE TablesSettings %] > [% USE AuthorisedValues %] >+[% USE ItemTypes %] > [% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnDetail ) %] > [% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnDetail ) %] > [% IF Koha.Preference('AmazonAssocTag') %] >@@ -167,14 +168,13 @@ > > [% IF ( !item_level_itypes || Koha.Preference('BiblioItemtypeInfo') ) %] > <span class="results_summary itemtype"><span class="label">Item type: </span> >- [% IF ( imageurl && !Koha.Preference('OpacNoItemTypeImages') ) %] >- <img src="[% imageurl | html %]" alt="" /> >- [% END %] >- [% IF ( description ) %] >- <span class="itypetext">[% description | html %]</span> >- [% ELSE %] >- <span class="itypetext">[% itemtype | html %]</span> >+ [% IF ( !Koha.Preference('OpacNoItemTypeImages') ) %] >+ [% SET image_url = itemtype.image_url %] >+ [% IF image_url %] >+ <img src="[% image_url | html %]" alt="" /> >+ [% END %] > [% END %] >+ <span class="itypetext">[% ItemTypes.t(itemtype.translation_key) | html %]</span> > </span> > [% END %] > >@@ -1237,12 +1237,14 @@ > > [% IF ( item_level_itypes ) %] > <td class="itype"> >+ [% SET itemtype_description = ItemTypes.t(ITEM_RESULT.itemtype.translation_key) %] > [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %] >- [% IF ( ITEM_RESULT.imageurl ) %] >- <img src="[% ITEM_RESULT.imageurl | html %]" title="[% ITEM_RESULT.description | html %]" alt="[% ITEM_RESULT.description | html %]" /> >+ [% SET image_url = ITEM_RESULT.itemtype.image_url %] >+ [% IF image_url %] >+ <img src="[% imageurl | html %]" title="[% itemtype_description | html %]" alt="[% itemtype_description | html %]" /> > [% END %] > [% END %] >- <span class="itypetext">[% ITEM_RESULT.description | html %]</span> >+ <span class="itypetext">[% itemtype_description | html %]</span> > </td> > [% END %] > [% IF ( OpacLocationBranchToDisplay == 'holding' || OpacLocationBranchToDisplay == 'both' ) %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 7d7b93685c5..2b20850bbcc 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -508,13 +508,7 @@ my $HideMARC = $record_processor->filters->[0]->should_hide_marc( > interface => 'opac', > } ); > >-my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search->unblessed } }; >-# imageurl: >-my $itemtype = $dat->{'itemtype'}; >-if ( $itemtype ) { >- $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); >- $dat->{'description'} = db_t('itemtype', $itemtypes->{$itemtype}->{itemtype}); >-} >+$dat->{itemtype} = Koha::ItemTypes->find($dat->{itemtype}); > > my $shelflocations = > { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => $dat->{frameworkcode}, kohafield => 'items.location' } ) }; >@@ -705,11 +699,7 @@ else { > $shelflocations->{ $item->location }; > } > >- my $itemtype = $item->itemtype; >- $item_info->{'imageurl'} = getitemtypeimagelocation( 'opac', >- $itemtypes->{ $itemtype->itemtype }->{'imageurl'} ); >- $item_info->{'description'} = >- db_t('itemtype', $itemtypes->{ $itemtype->itemtype }->{itemtype}); >+ $item_info->{itemtype} = $item->itemtype; > > foreach my $field ( > qw(ccode materials enumchron copynumber itemnotes location_description uri) >-- >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 24975
:
101703
|
101786
|
102387
|
102388
|
102513
|
102514
|
102688
|
102701
|
132388
|
132508
|
132509
|
132510
|
132511
|
132512
|
132513
|
132514
|
132515
|
132516
|
132517
|
132518
|
132519
|
132520
|
132521
|
132522
|
132523
|
132524
|
132525
|
132526
|
132527
|
132528
|
132529
|
132530
|
132531
|
132532
|
132533
|
132546
|
132562
|
132563
|
132564
|
132565
|
132566
|
132567
|
132568
|
132569
|
132570
|
132571
|
132572
|
132573
|
132574
|
132575
|
149941
|
149942
|
149943
|
149944
|
149945
|
149946
|
149947
|
149948
|
149949
|
149950
|
149951
|
149952
|
149953
|
149954
|
149956
|
149957
|
150015
|
150033
|
150034