Add GetBranchLoop since so many pages use exactly the same code.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
This commit is contained in:
Joe Atzberger 2008-10-30 00:07:40 -05:00 committed by Henri-Damien LAURENT
parent 17b3535be4
commit 39188f8cd9
1 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,7 @@ BEGIN {
&GetBranchName
&GetBranch
&GetBranches
&GetBranchesLoop
&GetBranchDetail
&get_branchinfos_of
&ModBranch
@ -132,6 +133,21 @@ sub GetBranches {
return ( \%branches );
}
sub GetBranchesLoop ($$) { # since this is what most pages want anyway
my $branch = shift or return undef;
my $onlymine = shift || 0;
my $branches = GetBranches($onlymine);
my @loop;
foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
push @loop, {
value => $_,
selected => ($_ eq $branch) ? 1 : 0,
branchname => $branches->{$_}->{branchname},
};
}
return \@loop;
}
=head2 GetBranchName
=cut