View | Details | Raw Unified | Return to bug 15326
Collapse All | Expand All

(-)a/Koha/CmsPages.pm (-31 lines)
Lines 164-200 sub list { Link Here
164
    return ( $page_list, $parent_list, $data );
164
    return ( $page_list, $parent_list, $data );
165
}
165
}
166
166
167
=head3 page
168
169
Retrieves all data to show a single CMS page.
170
171
=cut
172
173
sub page {
174
    my ( $self, $id ) = @_;
175
176
    carp( 'Missing CMS page id parameter in Koha::Pages::page' ) unless defined $id;
177
178
    my $page_data = $self->_resultset()->find( $id );
179
180
    return $page_data;
181
}
182
183
=head3 child_links
184
185
Lists pages which are children of a specific id (or undef for root).
186
187
=cut
188
189
sub child_links {
190
    my ( $self, $id ) = @_;
191
192
    # 'id' can be undefined if listing top-level links.
193
    my $rs = $self->_resultset()->search({ parent => $id }, { qw/id title_link/ });
194
195
    return $rs;
196
}
197
198
=head1 AUTHOR
167
=head1 AUTHOR
199
168
200
Martin Persson <xarragon@gmail.com>
169
Martin Persson <xarragon@gmail.com>
(-)a/t/Pages.t (-31 lines)
Lines 1-31 Link Here
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Carp;
5
use Test::More tests => 2;
6
use Data::Dumper::Concise;
7
8
BEGIN {
9
    use_ok('C4::Content');
10
}
11
12
my $src = [
13
    { id => '1', parent => '' },
14
    { id => '2', parent => '1' },
15
    { id => '3', parent => '1' },
16
    { id => '4', parent => '2' },
17
    { id => '5', parent => '2' },
18
];
19
20
my $expected = [
21
    { id => '1', children => [
22
        { id => '2', children => [
23
            { id => '4', children => [] },
24
            { id => '5', children => [] } ]
25
        },
26
        { id => '3', children => [] } ]
27
    },
28
];
29
30
my $output = C4::Content::_SQLToPerl($src);
31
is_deeply($output, $expected);
(-)a/tools/cmspages.pl (-2 / +1 lines)
Lines 102-108 if ( $op eq 'form' ) { Link Here
102
    }
102
    }
103
    print $cgi->redirect( $link_self );
103
    print $cgi->redirect( $link_self );
104
} elsif ( $op eq 'view' ) {
104
} elsif ( $op eq 'view' ) {
105
    my $cms_data = Koha::CmsPages->page( $id );
105
    my $cms_data = Koha::CmsPages->find( $id );
106
    my $links = Koha::CmsPages->search( {}, { order_by => 'sortorder' } );
106
    my $links = Koha::CmsPages->search( {}, { order_by => 'sortorder' } );
107
    $template->param(
107
    $template->param(
108
        links    => $links,
108
        links    => $links,
109
- 

Return to bug 15326