From f3d2fe9854d27fe6fbd726c331972a739b66ed6f Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Mon, 24 Sep 2018 03:12:44 +0000 Subject: [PATCH] Bug 15326: (follow-up) Pages navigation fixes This is the best I've managed to do with the navigation. Would be happy for someone else to give it a go because I'm aware that some parent links repeat. --- Koha/CmsPage.pm | 31 ++++++++++++++++++++++ .../prog/en/includes/cms-pages-nav.inc | 16 +++++++++++ .../prog/en/modules/tools/cmspages.tt | 15 ++--------- .../prog/en/modules/tools/tools-home.tt | 3 +++ tools/cmspages.pl | 4 +-- tools/tools-home.pl | 6 ++++- 6 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/cms-pages-nav.inc diff --git a/Koha/CmsPage.pm b/Koha/CmsPage.pm index cb333d0..498404c 100644 --- a/Koha/CmsPage.pm +++ b/Koha/CmsPage.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::CmsPages; use base qw( Koha::Object ); @@ -35,6 +36,36 @@ Koha::CmsPage - Koha Page Object class =cut +=head3 parentObj + +my $parent = $page->parentObj + +Return the parent page + +=cut + +sub parentObj { + my ( $self ) = @_; + my $p = $self->parent(); + return scalar Koha::CmsPages->find( $p ); +} + +=head3 isParent + +Returns true if page is a parent + +=cut + +sub isaParent { + my ( $self ) = @_; + my @pages_with_this_parent = Koha::CmsPages->search({ parent => $self->id() }); + if ( scalar @pages_with_this_parent > 0 ){ + return 1; + } else { + return 0; + } +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cms-pages-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cms-pages-nav.inc new file mode 100644 index 0000000..0abbfcb --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cms-pages-nav.inc @@ -0,0 +1,16 @@ +[% IF pages %] + +[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt index fb24bd7..32898d6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt @@ -59,24 +59,13 @@ [% IF ( view ) %]
- [% IF ( links ) %] + [% IF ( pages ) %]

Pages

-
    - [% FOREACH link IN links %] - [% IF ( link.location == '' || link.location == '1' ) %] - [% IF ( link.parent != '' ) %] - [% FOREACH parent IN parent_list %] - [% IF ( parent.id == link.parent ) %]
  • [% parent.title_link %][% link.title_link %]
  • [% END %] - [% END %] - [% ELSE %] -
  • [% link.title_link %]
  • - [% END %] - [% END %][% END %] -
+ [% INCLUDE 'cms-pages-nav.inc' %]
[% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index c696acc..9d09f47 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -97,6 +97,9 @@ [% IF ( CAN_user_tools_edit_pages ) %]
Pages
Create and edit additional content pages
+ [% END %] [% IF ( CAN_user_tools_schedule_tasks ) %] diff --git a/tools/cmspages.pl b/tools/cmspages.pl index 3a1f597..a8fd742 100755 --- a/tools/cmspages.pl +++ b/tools/cmspages.pl @@ -107,9 +107,9 @@ if ( $op eq 'form' ) { print $cgi->redirect( $link_self ); } elsif ( $op eq 'view' ) { my $cms_data = Koha::CmsPages->find( $id ); - my $links = Koha::CmsPages->search( {}, { order_by => 'sortorder' } ); + my $pages = Koha::CmsPages->search({ location => [ 1, { '=', undef } ] }, { order_by => 'sortorder' }); $template->param( - links => $links, + pages => $pages, cms_page => $cms_data, view => 1, id => $id, diff --git a/tools/tools-home.pl b/tools/tools-home.pl index 99fde63..bdb07df 100755 --- a/tools/tools-home.pl +++ b/tools/tools-home.pl @@ -22,6 +22,7 @@ use C4::Auth; use C4::Output; use C4::Tags qw/get_count_by_tag_status/; use Koha::Reviews; +use Koha::CmsPages; my $query = new CGI; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -38,9 +39,12 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $pendingcomments = Koha::Reviews->search_limited({ approved => 0 })->count; my $pendingtags = get_count_by_tag_status(0); +my $pages = Koha::CmsPages->search({ location => [ 1, { '=', undef } ] }, { order_by => 'sortorder' }); + $template->param( pendingcomments => $pendingcomments, - pendingtags => $pendingtags + pendingtags => $pendingtags, + pages => $pages, ); output_html_with_http_headers $query, $cookie, $template->output; -- 2.1.4