Bugzilla – Attachment 56452 Details for
Bug 15801
Move the framework related code to Koha::BiblioFramework[s] - part 2
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15801: Koha::BiblioFrameworks - Remove C4::Koha::GetFrameworksLoop
Bug-15801-KohaBiblioFrameworks---Remove-C4KohaGetF.patch (text/plain), 9.84 KB, created by
Marcel de Rooy
on 2016-10-14 07:41:44 UTC
(
hide
)
Description:
Bug 15801: Koha::BiblioFrameworks - Remove C4::Koha::GetFrameworksLoop
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2016-10-14 07:41:44 UTC
Size:
9.84 KB
patch
obsolete
>From 68c2205189d4479ff4f1588e19681a61187aa491 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 10 Feb 2016 16:06:14 +0000 >Subject: [PATCH] Bug 15801: Koha::BiblioFrameworks - Remove > C4::Koha::GetFrameworksLoop >Content-Type: text/plain; charset=utf-8 > >The C4::Koha::GetFrameworksLoop retrieves biblio frameworks and returns >them ordered by the description (frameworktext). If a parameter is >passed, a selected flag is set. The selection of the options should be >done on the template side. >These 2 calls can be replaced with > Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); > >Test plan: >1/ Go on a Labeled MARC biblio view (catalogue/labeledMARCdetail.pl) >You should see a dropdown list with the biblio frameworks. The framework >of the record should be selected by default >2/ Create a sql report using the biblio_framework parameter, something >like: > SELECT COUNT(*) FROM biblio WHERE frameworkcode=<<framework|biblio_framework>> >Save and execute the report. >You should get a dropdown list with the framework list. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Both dropdowns Ok >No errors > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Koha.pm | 50 -------------------- > catalogue/labeledMARCdetail.pl | 10 ++-- > .../prog/en/modules/catalogue/labeledMARCdetail.tt | 8 ++-- > reports/guided_reports.pl | 10 ++-- > t/db_dependent/Koha.t | 45 +----------------- > 5 files changed, 17 insertions(+), 106 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 5c93cc2..106abfa 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -41,7 +41,6 @@ BEGIN { > &GetItemTypes &getitemtypeinfo > &GetItemTypesCategorized &GetItemTypesByCategory > &getframeworks &getframeworkinfo >- &GetFrameworksLoop > &getallthemes > &getFacets > &getnbpages >@@ -282,55 +281,6 @@ sub getframeworks { > return ( \%itemtypes ); > } > >-=head2 GetFrameworksLoop >- >- $frameworks = GetFrameworksLoop( $frameworkcode ); >- >-Returns the loop suggested on getframework(), but ordered by framework description. >- >-build a HTML select with the following code : >- >-=head3 in PERL SCRIPT >- >- $template->param( frameworkloop => GetFrameworksLoop( $frameworkcode ) ); >- >-=head3 in TEMPLATE >- >- Same as getframework() >- >- <form action="[% script_name %] method=post> >- <select name="frameworkcode"> >- <option value="">Default</option> >- [% FOREACH framework IN frameworkloop %] >- [% IF ( framework.selected ) %] >- <option value="[% framework.value %]" selected="selected">[% framework.description %]</option> >- [% ELSE %] >- <option value="[% framework.value %]">[% framework.description %]</option> >- [% END %] >- [% END %] >- </select> >- <input type=text name=searchfield value="[% searchfield %]"> >- <input type="submit" value="OK" class="button"> >- </form> >- >-=cut >- >-sub GetFrameworksLoop { >- my $frameworkcode = shift; >- my $frameworks = getframeworks(); >- my @frameworkloop; >- foreach my $thisframework (sort { uc($frameworks->{$a}->{'frameworktext'}) cmp uc($frameworks->{$b}->{'frameworktext'}) } keys %$frameworks) { >- my $selected = ( $thisframework eq $frameworkcode ) ? 1 : undef; >- my %row = ( >- value => $thisframework, >- selected => $selected, >- description => $frameworks->{$thisframework}->{'frameworktext'}, >- ); >- push @frameworkloop, \%row; >- } >- return \@frameworkloop; >-} >- > =head2 getframeworkinfo > > $frameworkinfo = &getframeworkinfo($frameworkcode); >diff --git a/catalogue/labeledMARCdetail.pl b/catalogue/labeledMARCdetail.pl >index 7c488e0..c4b9019 100755 >--- a/catalogue/labeledMARCdetail.pl >+++ b/catalogue/labeledMARCdetail.pl >@@ -30,7 +30,8 @@ use C4::Items; > use C4::Members; # to use GetMember > use C4::Search; # enabled_staff_search_views > use C4::Acquisition qw(GetOrdersByBiblionumber); >-use C4::Koha qw( GetFrameworksLoop ); >+ >+use Koha::BiblioFrameworks; > > my $query = new CGI; > my $dbh = C4::Context->dbh; >@@ -82,8 +83,11 @@ my $itemcount = GetItemsCount($biblionumber); > $template->param( count => $itemcount, > bibliotitle => $biblio->{title}, ); > >-#Getting framework loop >-$template->param(frameworkloop => GetFrameworksLoop( $frameworkcode ) ); >+my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); >+$template->param( >+ frameworks => $frameworks, >+ frameworkcode => $frameworkcode, >+); > > my @marc_data; > my $prevlabel = ''; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >index 72d29e9..c56a3cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/labeledMARCdetail.tt >@@ -65,11 +65,11 @@ > <p><b>With framework: > <select name="Frameworks" id="Frameworks" size="1" onchange="Changefwk(this);"> > <option value="">Default</option> >- [% FOREACH framework IN frameworkloop %] >- [% IF ( framework.selected ) %] >- <option value="[% framework.value %]" selected="selected">[% framework.description %]</option> >+ [% FOREACH framework IN frameworks %] >+ [% IF framework.frameworkcode == frameworkcode %] >+ <option value="[% framework.frameworkcode %]" selected="selected">[% framework.frameworktext %]</option> > [% ELSE %] >- <option value="[% framework.value %]">[% framework.description %]</option> >+ <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option> > [% END %] > [% END %] > </select> >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 64e7632..9c42863 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -28,13 +28,13 @@ use C4::Reports::Guided; > use C4::Auth qw/:DEFAULT get_session/; > use C4::Output; > use C4::Debug; >-use C4::Koha qw/GetFrameworksLoop/; > use C4::Context; > use Koha::Caches; > use C4::Log; > use Koha::DateUtils qw/dt_from_string output_pref/; > use Koha::AuthorisedValue; > use Koha::AuthorisedValues; >+use Koha::BiblioFrameworks; > use Koha::Libraries; > use Koha::Patron::Categories; > >@@ -686,13 +686,13 @@ elsif ($phase eq 'Run this report'){ > } > } > elsif ( $authorised_value eq "biblio_framework" ) { >- my $frameworks = GetFrameworksLoop(); >+ my @frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); > my $default_source = ''; > push @authorised_values,$default_source; > $authorised_lib{$default_source} = 'Default'; >- foreach my $framework (@$frameworks) { >- push @authorised_values, $framework->{value}; >- $authorised_lib{$framework->{value}} = $framework->{description}; >+ foreach my $framework (@frameworks) { >+ push @authorised_values, $framework->frameworkcode; >+ $authorised_lib{$framework->frameworkcode} = $framework->frameworktext; > } > } > elsif ( $authorised_value eq "cn_source" ) { >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >index 8392ef8..418a9f8 100644 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -9,7 +9,7 @@ use Koha::DateUtils qw(dt_from_string); > use Koha::AuthorisedValue; > use Koha::AuthorisedValueCategories; > >-use Test::More tests => 9; >+use Test::More tests => 8; > use DateTime::Format::MySQL; > > BEGIN { >@@ -246,49 +246,6 @@ subtest 'ISBN tests' => sub { > > }; > >-subtest 'GetFrameworksLoop() tests' => sub { >- plan tests => 6; >- >- $dbh->do("DELETE FROM biblio_framework"); >- >- my $frameworksloop = GetFrameworksLoop(); >- is ( scalar(@$frameworksloop), 0, 'No frameworks' ); >- >- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'A', 'Third framework' )"); >- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'B', 'Second framework' )"); >- $dbh->do("INSERT INTO biblio_framework ( frameworkcode, frameworktext ) VALUES ( 'C', 'First framework' )"); >- >- $frameworksloop = GetFrameworksLoop(); >- is ( scalar(@$frameworksloop), 3, 'All frameworks' ); >- is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 0, 'None selected' ); >- >- $frameworksloop = GetFrameworksLoop( 'B' ); >- is ( scalar ( grep { defined $_->{'selected'} } @$frameworksloop ), 1, 'One selected' ); >- my @descriptions = map { $_->{'description'} } @$frameworksloop; >- is ( $descriptions[0], 'First framework', 'Ordered result' ); >- cmp_deeply( >- $frameworksloop, >- [ >- { >- 'value' => 'C', >- 'description' => 'First framework', >- 'selected' => undef, >- }, >- { >- 'value' => 'B', >- 'description' => 'Second framework', >- 'selected' => 1, # selected >- }, >- { >- 'value' => 'A', >- 'description' => 'Third framework', >- 'selected' => undef, >- } >- ], >- 'Full check, sorted by description with selected val (Bug 12675)' >- ); >-}; >- > subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ > plan tests => 7; > >-- >1.7.10.4
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 15801
:
47923
|
47924
|
47925
|
48938
|
48939
|
48940
|
50259
|
51385
|
51386
|
51387
|
51426
|
51427
|
51432
|
51433
|
51434
|
51435
|
54348
|
54349
|
54350
|
54351
|
55688
|
55689
|
55690
|
55691
|
56452
|
56453
|
56454
|
56455
|
56766
|
56767
|
56768
|
56769