Bugzilla – Attachment 83319 Details for
Bug 15326
Add CMS feature
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15326: (follow-up) Add CMS feature
Bug-15326-follow-up-Add-CMS-feature.patch (text/plain), 62.51 KB, created by
Aleisha Amohia
on 2018-12-17 21:16:40 UTC
(
hide
)
Description:
Bug 15326: (follow-up) Add CMS feature
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2018-12-17 21:16:40 UTC
Size:
62.51 KB
patch
obsolete
>From 36b2a84e90e259744ba061380a738bc3c1bd10a2 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Mon, 12 Dec 2016 02:41:59 +0000 >Subject: [PATCH] Bug 15326: (follow-up) Add CMS feature > >This patch builds on Martin Persson's patch. I made a few changes that >improve the patch and make this feature functional. >The only thing I am not completely satisfied with (and doesn't reliably >work) is the navigation for the CMS pages on both the staff side and the >OPAC side. This needs work. Otherwise the CMS feature works. > >- Make sure you update database after applying patch >- After adding a few pages, confirm that filtering results works (play > with different combinations of display location, library and language) >- Confirm that pages with specific locations ONLY show up in those >locations, i.e. OPAC pages can only be accessed in OPAC and staff interface >pages can only be accessed on staff client >- Confirm that table is showing correct data, particularly language, >location and library >- Confirm that if page has not been published and user does not have >permission to edit pages, page content will not display on OPAC side. On >staff side, a message will show saying that page has not been published >- Confirm pagination for table shows and works >- Confirm deleting pages works as expected (confirm message before >delete) >- Confirm link title must be unique when adding new pages >- Confirm that editing the details of an existing page works >- Confirm that adding a child page will only work if the location of >child page matches location of parent page, i.e., if parent page is an >OPAC page then child page must also be OPAC page. if parent page is in >all locations then child page can be in all or either interface(s) >- Confirm Select All/Clear All toggle works >- Confirm viewing of CMS pages in OPAC and in staff client works and >looks nice > >Sponsored-by: Region Halland > >Bug 15326: [FOLLOW-UP] Many fixes > >This patch: >- moves action buttons into a dropdown, adds a delete button to dropdown >- fixes the tests (they should now all pass) >- fixes qa tool problems >- removes the Koha::CmsPages->remove() method (unnecessary) >- makes changes to the Koha::CmsPages->add() method (now simpler, easier >to test) > >This is now ready to test. > >Sponsored-by: Catalyst IT > >Bug 15326: [FOLLOW-UP] More fixes > >This patch removes the t/Pages.t file because it isn't required, and >other unused methods. > >This patch is ready to test. The appropriate tests are in >t/db_dependent/Pages.t > >Bug 15326: [FOLLOW-UP] adding and editing fixes > >Sorry, did not see the second half of your comment. This patch should >fix the adding and editing issues in Comment 16. > >Bug 15326: [FOLLOW-UP] Fixing library field in form, opac publishing > >Fixes issues from Comment 19, please test > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > Koha/CmsPage.pm | 2 +- > Koha/CmsPages.pm | 124 ++++----- > Koha/Schema/Result/Branch.pm | 16 +- > Koha/Schema/Result/CmsPage.pm | 150 +++++++++++ > .../bug15326-add_cms_pages_permission.sql | 1 + > .../intranet-tmpl/prog/en/includes/tools-menu.inc | 70 ++++-- > .../prog/en/modules/tools/cmspages.tt | 276 ++++++++++++++------- > .../opac-tmpl/bootstrap/en/includes/masthead.inc | 14 -- > .../opac-tmpl/bootstrap/en/includes/navigation.inc | 27 +- > .../bootstrap/en/modules/opac-cmspages.tt | 56 ++--- > koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 40 +-- > opac/opac-cmspages.pl | 14 +- > opac/opac-main.pl | 14 +- > t/Pages.t | 31 --- > t/db_dependent/Pages.t | 123 +++++---- > tools/cmspages.pl | 59 ++++- > 16 files changed, 624 insertions(+), 393 deletions(-) > create mode 100644 Koha/Schema/Result/CmsPage.pm > create mode 100644 installer/data/mysql/atomicupdate/bug15326-add_cms_pages_permission.sql > delete mode 100644 t/Pages.t > >diff --git a/Koha/CmsPage.pm b/Koha/CmsPage.pm >index fd5b52a..cb333d0 100644 >--- a/Koha/CmsPage.pm >+++ b/Koha/CmsPage.pm >@@ -39,7 +39,7 @@ Koha::CmsPage - Koha Page Object class > > =cut > >-sub type { >+sub _type { > return 'CmsPage'; > } > >diff --git a/Koha/CmsPages.pm b/Koha/CmsPages.pm >index b49881e..6af9203 100644 >--- a/Koha/CmsPages.pm >+++ b/Koha/CmsPages.pm >@@ -40,7 +40,7 @@ Koha::CmsPage - Koha CMS Page Object Class > > =cut > >-sub type { >+sub _type { > return 'CmsPage'; > } > >@@ -49,27 +49,46 @@ sub object_class { > } > > =head3 add >+ > Adds a new page to the CMS database based on the input data. >+ > =cut > > sub add { > my ( $self, $input ) = @_; >-warn "input: ", scalar $input->param('location'); > carp( 'Koha::CmsPages::add() undefined parameter: input' ) unless defined $input; >+ > my $data = { >- parent => scalar $input->param( 'parent' ) eq '' ? undef : scalar $input->param( 'parent' ), >- location => scalar $input->param( 'location' ) eq '' ? undef : scalar $input->param( 'location'), >- branchcode => scalar $input->param( 'branchcode' ) eq '' ? undef : scalar $input->param( 'branchcode' ), >- lang => scalar $input->param( 'lang' ), >- sortorder => scalar $input->param( 'sortorder' ), >- title => scalar $input->param( 'title' ), >- title_link => scalar $input->param( 'title_link' ), >- publish => defined (scalar $input->param( 'publish' )), >- content => scalar $input->param( 'content' ) >+ parent => $input->{parent} eq '' ? undef : $input->{parent}, >+ location => $input->{location} eq '' ? undef : $input->{location}, >+ branchcode => $input->{branchcode} eq '' ? undef : $input->{branchcode}, >+ lang => $input->{lang}, >+ sortorder => $input->{sortorder}, >+ title => $input->{title}, >+ title_link => $input->{title_link}, >+ publish => $input->{publish} eq 'on' ? 1 : 0, >+ content => $input->{content} > }; > >- if (defined $input->param( 'id' )) { >- $data->{'id'} = scalar $input->param( 'id' ); >+ if (defined $input->{id}){ >+ $data->{id} = $input->{id}; >+ } >+ >+ # Ensuring link titles are unique >+ my $title_link = $input->{title_link}; >+ if ( Koha::CmsPages->find({ title_link => $title_link }) ){ >+ my $link = Koha::CmsPages->find({ title_link => $title_link }); >+ unless ( $link->id eq $input->{id} ){ >+ return; >+ } >+ } >+ >+ # Ensuring that, if page has parent, provided location suits parent location >+ my $parent = Koha::CmsPages->find($input->{parent}); >+ if ( $parent && $parent->location ne "" ){ >+ if ( $parent->location ne $input->{location} ){ >+ return; >+ } > } > > my $new_page = $self->_resultset()->update_or_create( $data, { key => 'primary' }); >@@ -79,22 +98,31 @@ warn "input: ", scalar $input->param('location'); > > =head3 list > >-Lists pages based input filtering paramters for location, branch and language. >+Lists pages based input filtering parameters for location, branch and language. > > =cut > > sub list { > my ( $self, $id, $disp, $branch, $lang ) = @_; > >- my $filter = { }; >- $filter->{'location'} = $disp unless not defined $disp; >- $filter->{'branch'} = $branch unless not defined $branch; >- $filter->{'lang'} = $lang unless not defined $lang; >+ my %filter; >+ if ($branch) { >+ my $branch_push = [ $branch, undef ]; >+ push @{$filter{'branchcode'}}, $branch_push; >+ } >+ if ($lang) { >+ my $lang_push = [ $lang, undef ]; >+ push @{$filter{'lang'}}, $lang_push; >+ } >+ if ($disp) { >+ my $disp_push = [ $disp, undef ]; >+ push @{$filter{'location'}}, $disp_push; >+ } > >- my $pages = $self->_resultset()->search( undef, { >+ my $pages = $self->_resultset()->search( {}, { > order_by => { >- -asc => [qw/parent location branchcode lang sortorder/] >- }, where => $filter >+ -asc => [qw/parent location branchcode lang sortorder/] >+ }, where => { %filter } > } ); > > my $page_list = []; >@@ -136,60 +164,6 @@ sub list { > return ( $page_list, $parent_list, $data ); > } > >-=head3 page >- >-Retrieves all data to show a single CMS page. >- >-=cut >- >-sub page { >- my ( $self, $id ) = @_; >- >- carp( 'Missing CMS page id parameter in Koha::Pages::page' ) unless defined $id; >- >- # Probably want to merge these to a single query: >- my $top_links = $self->_resultset()->search( >- { parent => undef }, { qw/id title_link/ }); >- >- my $page_links = $self->_resultset()->search( >- { parent => $id }, { qw/id title_link/ }); >- >- my $page_data = $self->_resultset()->find( $id ); >- >- return ( $top_links, $page_links, $page_data ); >-} >- >-=head3 child_links >- >-Lists pages which are children of a specific id (or undef for root). >- >-=cut >- >-sub child_links { >- my ( $self, $id ) = @_; >- >- # 'id' can be undefined if listing top-level links. >- my $rs = $self->_resultset()->search({ parent => $id }, >- { columns => [qw/id title_link/] } ); >- >- return $rs; >-} >- >-=head3 remove >- >-Removes a page identified by id from the CMS database. >- >-=cut >- >-sub remove { >- my ( $self, @ids ) = @_; >- >- carp( 'Koha::CmsPages::remove() undefined parameter ids' ) unless @ids; >- >- my $pages = $self->_resultset()->search({ id => \@ids }); >- $pages->delete; >-} >- > =head1 AUTHOR > > Martin Persson <xarragon@gmail.com> >diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm >index 13fe183..b0fd521 100644 >--- a/Koha/Schema/Result/Branch.pm >+++ b/Koha/Schema/Result/Branch.pm >@@ -436,6 +436,21 @@ __PACKAGE__->has_many( > { cascade_copy => 0, cascade_delete => 0 }, > ); > >+=head2 cms_pages >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::CmsPage> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "cms_pages", >+ "Koha::Schema::Result::CmsPage", >+ { "foreign.branchcode" => "self.branchcode" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > =head2 collections > > Type: has_many >@@ -665,7 +680,6 @@ __PACKAGE__->has_many( > # Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-09 15:50:42 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0yMUX1UukdV7eMol06JXTQ > >- > # You can replace this text with custom code or comments, and it will be preserved on regeneration > > sub koha_objects_class { >diff --git a/Koha/Schema/Result/CmsPage.pm b/Koha/Schema/Result/CmsPage.pm >new file mode 100644 >index 0000000..1136c1d >--- /dev/null >+++ b/Koha/Schema/Result/CmsPage.pm >@@ -0,0 +1,150 @@ >+use utf8; >+package Koha::Schema::Result::CmsPage; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::CmsPage >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<cms_pages> >+ >+=cut >+ >+__PACKAGE__->table("cms_pages"); >+ >+=head1 ACCESSORS >+ >+=head2 id >+ >+ data_type: 'integer' >+ is_auto_increment: 1 >+ is_nullable: 0 >+ >+=head2 parent >+ >+ data_type: 'integer' >+ is_nullable: 1 >+ >+=head2 branchcode >+ >+ data_type: 'varchar' >+ is_foreign_key: 1 >+ is_nullable: 1 >+ size: 10 >+ >+=head2 lang >+ >+ data_type: 'varchar' >+ default_value: (empty string) >+ is_nullable: 0 >+ size: 25 >+ >+=head2 title >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 255 >+ >+=head2 title_link >+ >+ data_type: 'varchar' >+ is_nullable: 1 >+ size: 64 >+ >+=head2 sortorder >+ >+ data_type: 'integer' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 location >+ >+ data_type: 'tinyint' >+ is_nullable: 1 >+ >+=head2 publish >+ >+ data_type: 'tinyint' >+ default_value: 0 >+ is_nullable: 0 >+ >+=head2 content >+ >+ data_type: 'text' >+ is_nullable: 1 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "id", >+ { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, >+ "parent", >+ { data_type => "integer", is_nullable => 1 }, >+ "branchcode", >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, >+ "lang", >+ { data_type => "varchar", default_value => "", is_nullable => 0, size => 25 }, >+ "title", >+ { data_type => "varchar", is_nullable => 1, size => 255 }, >+ "title_link", >+ { data_type => "varchar", is_nullable => 1, size => 64 }, >+ "sortorder", >+ { data_type => "integer", default_value => 0, is_nullable => 0 }, >+ "location", >+ { data_type => "tinyint", is_nullable => 1 }, >+ "publish", >+ { data_type => "tinyint", default_value => 0, is_nullable => 0 }, >+ "content", >+ { data_type => "text", is_nullable => 1 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</id> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("id"); >+ >+=head1 RELATIONS >+ >+=head2 branchcode >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::Branch> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "branchcode", >+ "Koha::Schema::Result::Branch", >+ { branchcode => "branchcode" }, >+ { >+ is_deferrable => 1, >+ join_type => "LEFT", >+ on_delete => "CASCADE", >+ on_update => "CASCADE", >+ }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-12 02:41:09 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9044j1OZyypCpGV71FgvYg >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/installer/data/mysql/atomicupdate/bug15326-add_cms_pages_permission.sql b/installer/data/mysql/atomicupdate/bug15326-add_cms_pages_permission.sql >new file mode 100644 >index 0000000..72ce00f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug15326-add_cms_pages_permission.sql >@@ -0,0 +1 @@ >+INSERT IGNORE INTO permissions (`module_bit`, `code`, `description`) VALUES ('13', 'edit_pages', 'Create, edit and delete CMS pages for OPAC and staff interfaces'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >index 64f2a53..de16cc7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc >@@ -1,4 +1,23 @@ > [% USE Koha %] >+<script type="text/javascript">//<![CDATA[ >+ $(document).ready(function() { >+ var path = location.pathname.substring(1); >+ if (path.indexOf("labels") >= 0 && path.indexOf("spine") < 0 ) { >+ $('#navmenulist a[href$="/cgi-bin/koha/labels/label-home.pl"]').css('font-weight','bold'); >+ } else if (path.indexOf("patroncards") >= 0 ) { >+ $('#navmenulist a[href$="/cgi-bin/koha/patroncards/home.pl"]').css('font-weight','bold'); >+ } else if (path.indexOf("patron_lists") >= 0 ) { >+ $('#navmenulist a[href$="/cgi-bin/koha/patron_lists/lists.pl"]').css('font-weight','bold'); >+ } else if ((path+location.search).indexOf("batchMod.pl?del=1") >= 0 ) { >+ $('#navmenulist a[href$="/cgi-bin/koha/tools/batchMod.pl?del=1"]').css('font-weight','bold'); >+ } else if (path.indexOf("cmspages") >= 0 ) { >+ $('#navmenulist a[href$="/cgi-bin/koha/tools/cmspages.pl"]').css('font-weight','bold'); >+ } else { >+ $('#navmenulist a[href$="/' + path + '"]').css('font-weight','bold'); >+ } >+ }); >+//]]> >+</script> > > <div id="navmenu"> > <div id="navmenulist"> >@@ -8,46 +27,46 @@ > <h5>Patrons and circulation</h5> > <ul> > [% IF ( CAN_user_tools_manage_patron_lists ) %] >- <li><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a></li> >+ <li><a href="/cgi-bin/koha/patron_lists/lists.pl">Patron lists</a></li> > [% END %] > [% IF (CAN_user_clubs) %] > <li><a href="/cgi-bin/koha/clubs/clubs.pl">Patron clubs</a></li> > [% END %] > [% IF ( CAN_user_tools_moderate_comments ) %] >- <li><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a></li> >+ <li><a href="/cgi-bin/koha/reviews/reviewswaiting.pl">Comments</a></li> > [% END %] > [% IF ( CAN_user_tools_import_patrons ) %] >- <li><a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a></li> >+ <li><a href="/cgi-bin/koha/tools/import_borrowers.pl">Import patrons</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_notices ) %] >- <li><a href="/cgi-bin/koha/tools/letter.pl">Notices & slips</a></li> >+ <li><a href="/cgi-bin/koha/tools/letter.pl">Notices & slips</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_notice_status_triggers ) %] >- <li><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></li> >+ <li><a href="/cgi-bin/koha/tools/overduerules.pl">Overdue notice/status triggers</a></li> > [% END %] > [% IF ( CAN_user_tools_label_creator ) %] >- <li><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></li> >+ <li><a href="/cgi-bin/koha/patroncards/home.pl">Patron card creator</a></li> > [% END %] > [% IF ( CAN_user_tools_delete_anonymize_patrons ) %] >- <li><a href="/cgi-bin/koha/tools/cleanborrowers.pl">Batch patron deletion/anonymization</a></li> >+ <li><a href="/cgi-bin/koha/tools/cleanborrowers.pl">Batch patron deletion/anonymization</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_patrons ) %] >- <li><a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a></li> >+ <li><a href="/cgi-bin/koha/tools/modborrowers.pl">Batch patron modification</a></li> > [% END %] > [% IF ( CAN_user_tools_moderate_tags ) %] >- <li><a href="/cgi-bin/koha/tags/review.pl">Tag moderation</a></li> >+ <li><a href="/cgi-bin/koha/tags/review.pl">Tag moderation</a></li> > [% END %] > [% IF ( CAN_user_tools_batch_upload_patron_images ) %] >- <li><a href="/cgi-bin/koha/tools/picture-upload.pl">Upload patron images</a></li> >+ <li><a href="/cgi-bin/koha/tools/picture-upload.pl">Upload patron images</a></li> > [% END %] > </ul> > <h5>Catalog</h5> > <ul> > [% IF ( CAN_user_tools_items_batchdel ) %] >- <li><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a></li> >+ <li><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a></li> > [% END %] > [% IF ( CAN_user_tools_items_batchmod ) %] >- <li><a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a></li> >+ <li><a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a></li> > [% END %] > [% IF CAN_user_tools_records_batchdel %] > <li><a href="/cgi-bin/koha/tools/batch_delete_records.pl">Batch record deletion</a></li> >@@ -59,17 +78,17 @@ > <li><a href="/cgi-bin/koha/tools/automatic_item_modification_by_age.pl">Automatic item modifications by age</a></li> > [% END %] > [% IF ( CAN_user_tools_export_catalog ) %] >- <li><a href="/cgi-bin/koha/tools/export.pl">Export data</a></li> >+ <li><a href="/cgi-bin/koha/tools/export.pl">Export data</a></li> > [% END %] > [% IF ( CAN_user_tools_inventory ) %] > <li><a href="/cgi-bin/koha/tools/inventory.pl">Inventory</a></li> > [% END %] > [% IF ( CAN_user_tools_label_creator ) %] >- <li><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></li> >- <li><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></li> >+ <li><a href="/cgi-bin/koha/labels/label-home.pl">Label creator</a></li> >+ <li><a href="/cgi-bin/koha/labels/spinelabel-home.pl">Quick spine label creator</a></li> > [% END %] > [% IF ( CAN_user_tools_rotating_collections ) %] >- <li><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></li> >+ <li><a href="/cgi-bin/koha/rotating_collections/rotatingCollections.pl">Rotating collections</a></li> > [% END %] > [% IF ( CAN_user_stockrotation_manage_rotas && Koha.Preference('StockRotation') ) %] > <li><a href="/cgi-bin/koha/tools/stockrotation.pl">Stock rotation</a></li> >@@ -78,31 +97,34 @@ > <li><a href="/cgi-bin/koha/tools/marc_modification_templates.pl">Manage MARC modification templates</a></li> > [% END %] > [% IF ( CAN_user_tools_stage_marc_import ) %] >- <li><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC for import</a></li> >+ <li><a href="/cgi-bin/koha/tools/stage-marc-import.pl">Stage MARC for import</a></li> > [% END %] > [% IF ( CAN_user_tools_manage_staged_marc ) %] >- <li><a href="/cgi-bin/koha/tools/manage-marc-import.pl">Staged MARC management</a></li> >+ <li><a href="/cgi-bin/koha/tools/manage-marc-import.pl">Staged MARC management</a></li> > [% END %] > [% IF ( CAN_user_tools_upload_local_cover_images ) %] >- <li><a href="/cgi-bin/koha/tools/upload-cover-image.pl">Upload local cover image</a></li> >+ <li><a href="/cgi-bin/koha/tools/upload-cover-image.pl">Upload local cover image</a></li> > [% END %] > </ul> > <h5>Additional tools</h5> > <ul> > [% IF ( CAN_user_tools_edit_calendar ) %] >- <li><a href="/cgi-bin/koha/tools/holidays.pl">Calendar</a></li> >+ <li><a href="/cgi-bin/koha/tools/holidays.pl">Calendar</a></li> > [% END %] > [% IF ( CAN_user_tools_manage_csv_profiles ) %] >- <li><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></li> >+ <li><a href="/cgi-bin/koha/tools/csv-profiles.pl">CSV profiles</a></li> > [% END %] > [% IF ( CAN_user_tools_view_system_logs ) %] >- <li><a href="/cgi-bin/koha/tools/viewlog.pl">Log viewer</a></li> >+ <li><a href="/cgi-bin/koha/tools/viewlog.pl">Log viewer</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_news ) %] >- <li><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></li> >+ <li><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></li> >+ [% END %] >+ [% IF ( CAN_user_tools_edit_pages ) %] >+ <li><a href="/cgi-bin/koha/tools/cmspages.pl">Pages</a></li> > [% END %] > [% IF ( CAN_user_tools_schedule_tasks ) %] >- <li><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></li> >+ <li><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></li> > [% END %] > [% IF ( CAN_user_tools_edit_quotes ) %] > <li><a href="/cgi-bin/koha/tools/quotes.pl">Quote editor</a></li> >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 99f539d..d67bc0f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt >@@ -5,26 +5,39 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Pages</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% IF ( opac_page_count ) %] >- <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >- [% INCLUDE 'datatables.inc' %] >- <script type="text/javascript">//<![CDATA[ >- $(document).ready(function() { >- $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ 0,-1,-2 ], "bSortable": false }, >- { "aTargets": [ 0, -1 ], "bSearchable": false }, >- { 'sType': "title-string", 'aTargets' : [ 'title-string'] } >- ], >- "sPaginationType": "full_numbers" >- })); >- }); >- //]]> >- </script> >-[% END %] >+<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >+[% INCLUDE 'datatables.inc' %] > <script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script> > <script type="text/javascript">//<![CDATA[ >-var MSG_CONFIRM_DELETE_PAGE = _("Are you sure you want to delete the selected page?"); >+$(document).ready(function() { >+ $("#pages_table").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ 0, -1 ], "bSortable": false, "bSearchable": false }, >+ ], >+ "sPaginationType": "full_numbers" >+ })); >+ >+ $("#del_button").on("click",function(){ >+ if ($("input[name='ids'][type='checkbox']:checked").length){ >+ return confirmDelete(_("Are you sure you want to delete the selected page(s)?")); >+ } else { >+ alert(_("No pages have been selected.")); >+ return false; >+ } >+ }); >+ >+ $(".del_single").on("click", function(){ >+ return confirmDelete(_("Are you sure you want to delete this page?")); >+ }); >+ >+ $(".SelectAll").on("click", function(){ >+ $("input[name='ids'][type='checkbox']").prop("checked", true); >+ }); >+ >+ $(".ClearAll").on("click", function(){ >+ $("input[name='ids'][type='checkbox']").prop("checked", false); >+ }); >+}); > > tinyMCE.init({ > mode : "textareas", >@@ -47,20 +60,31 @@ tinyMCE.init({ > width : "700" > //]]> > }); >-//]]> > </script> > </head> > <body id="tools_koha-content" class="tools"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] >-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › [% IF ( form ) %]<a href="[% link_self %]">Pages</a> › [% IF ( id ) %] >-Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div> >+<div id="breadcrumbs"> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> › >+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> › >+ [% IF ( form ) %]<a href="[% link_self %]">Pages</a> › >+ [% IF ( id ) %]Edit page[% ELSE %]Add page[% END %] >+ [% ELSIF ( view ) %] >+ <a href="[% link_self %]">Pages</a> › >+ [% IF ( cms_page.parent ) %] >+ [% FOREACH parent IN parent_list %] >+ [% IF parent.id == cms_page.parent %]<a href="[% link_self %]?op=view&id=[% cms_page.parent %]">[% parent.title_link %]</a> ›[% END %] >+ [% END %] >+ [% END %] >+ [% cms_page.title_link %] >+ [% ELSE %]Pages[% END %] >+</div> > > [% IF ( form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %] > <div id="bd"> > <div id="yui-main"> > <div class="yui-b"> >- > [% UNLESS ( link_opac_base && link_self) %] > <div class="dialog alert"> > [% UNLESS ( link_opac_base ) %] >@@ -70,17 +94,55 @@ Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div> > Warning: Variable <em>link_self</em> not set, some links might not work!</div> > [% END %] > [% END %] >-[% UNLESS ( form ) %] >- [% IF error_message == 'title_missing' %] >- <div class="dialog alert">Error: Required page title missing!</div> >- [% END %] >+[% UNLESS ( form || view ) %] > <div id="toolbar" class="btn-toolbar"> >- <a class="btn btn-small" id="newentry" href="[% link_self %]?op=form"><i class="icon-plus"></i> New page</a> >+ <a class="btn btn-default btn-sm" id="newentry" href="[% link_self %]?op=form"><i class="fa fa-plus"></i> New page</a> > </div> > [% END %] >-<pre>DEBUG: [% debug %]</pre> >-<pre>DEBUG2: data.location: [% data.location %] data.branchcode: [% data.branchcode %]</pre> >-[% IF ( form ) %] >+[% IF ( failed_add ) %] >+<div class="dialog alert"> >+ Failed to add page. Check that: >+ <ul> >+ <li>Your link title is unique</li> >+ <li>If specifying a parent page, the location is the same as your new page</li> >+ </ul> >+</div> >+[% END %] >+[% IF ( view ) %] >+<div class="yui-ge"> >+<div id="pagesnav" class="yui-u"> >+ [% IF ( links ) %] >+ <fieldset> >+ <ul> >+ <li><a href="[% link_self %]">Pages home</a></li> >+ </ul> >+ <h4>Pages</h4> >+ <ul id="cms_nav"> >+ [% FOREACH link IN links %] >+ [% IF ( link.location == '' || link.location == '1' ) %] >+ [% IF ( link.parent != '' ) %] >+ [% FOREACH parent IN parent_list %] >+ [% IF ( parent.id == link.parent ) %]<li style="margin-left:20px;"><a href="[% link_self %]?op=view&id=[% link.parent %]">[% parent.title_link %]</a> › <a href="[% link_self %]?op=view&id=[% link.id %]">[% link.title_link %]</a></li>[% END %] >+ [% END %] >+ [% ELSE %] >+ <li><a href="[% link_self %]?op=view&id=[% link.id %]">[% link.title_link %]</a></li> >+ [% END %] >+ [% END %][% END %] >+ </ul> >+ </fieldset> >+ [% END %] >+</div> >+<div class="yui-u first"> >+<h1>Pages: [% cms_page.title %]</h1> >+[% IF ( cms_page.publish == 1 ) %] >+ [% cms_page.content %] >+[% ELSE %] >+ <div class="dialog message">This page has not been published.</div> >+ [% cms_page.content %] >+[% END %] >+</div> >+</div> >+[% ELSIF ( form ) %] > <form name="form" method="post" enctype="multipart/form-data" action="[% link_self %]" > > <input type="hidden" name="op" value="[% op %]" /> > <input type="hidden" name="id" value="[% id %]" /> >@@ -88,39 +150,38 @@ Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div> > <legend>Page</legend> > <ol> > <li> >- <label for="disp">Display location</label> >+ <label for="disp">Display location:</label> > <select id="disp" name="disp"> >- <option value="" [% IF ( data.disp == "" ) %]selected="selected"[% END %]>All</option> >- <option value="1" [% IF ( data.disp == "1" ) %]selected="selected"[% END %]>Intranet</option> >- <option value="2" [% IF ( data.disp == "2" ) %]selected="selected"[% END %]>OPAC</option> >+ [% IF ( data.location == "" ) %]<option value="" selected="selected">All</option>[% ELSE %]<option value="">All</option>[% END %] >+ [% IF ( data.location == "1" ) %]<option value="1" selected="selected">Staff interface</option>[% ELSE %]<option value="1">Staff interface</option>[% END %] >+ [% IF ( data.location == "2" ) %]<option value="2" selected="selected">OPAC</option>[% ELSE %]<option value="2">OPAC</option>[% END %] > </select> > </li> > <li> >- <label for="branch">Library: </label> >+ <label for="branch">Library:</label> > <select id="branch" name="branch"> >- <option value=""[% IF ( data.branchcode == '' ) %] selected="selected"[% END %]>All libraries</option> >- [% FOREACH branch_lis IN branch_list %] >- <option value="[% branch_lis.branchcode %]"[% IF ( branch_lis.branchcode == data.branchcode ) %] selected="selected"[% END %]>[% branch_lis.branchname %]</option> >- [% END %] >+ [% IF ( data.branchcode.branchcode == "" ) %]<option value="" selected="selected">All libraries</option>[% ELSE %]<option value="">All libraries</option>[% END %] >+ [% FOREACH branch IN branch_list %] >+ [% IF ( branch.branchcode == data.branchcode.branchcode ) %]<option value="[% branch.branchcode %]" selected="selected">[% branch.branchname %]</option>[% ELSE %]<option value="[% branch.branchcode %]">[% branch.branchname %]</option>[% END %] >+ [% END %] > </select> > </li> > <li> >- <label for="lang">Language</label> >-<pre>LANG: [% lang %]</pre> >+ <label for="lang">Language:</label> > <select id="lang" name="lang"> >- <option value="" [% IF ( data.lang == "" ) %]selected="selected"[% END %]>All</option> >- [% FOREACH lang_lis IN lang_list %] >- <option value="[% lang_lis.rfc4646_subtag %]" [% IF ( lang_lis.rfc4646_subtag == data.lang ) %]selected="selected"[% END %]>[% lang_lis.native_description %] ([% lang_lis.rfc4646_subtag %])</option> >+ [% IF ( data.lang == "" ) %]<option value="" selected="selected">All</option>[% ELSE %]<option value="">All</option>[% END %] >+ [% FOREACH lang IN lang_list %] >+ [% IF ( lang.rfc4646_subtag == data.lang ) %]<option value="[% lang.rfc4646_subtag %]" selected="selected">[% lang.native_description %] ([% lang.rfc4646_subtag %])</option>[% ELSE %]<option value="[% lang.rfc4646_subtag %]">[% lang.native_description %] ([% lang.rfc4646_subtag %])</option>[% END %] > [% END %] > </select> > </li> > <li> > <label for="parent">Parent page: </label> > <select id="parent" name="parent"> >- <option value="" [% IF ( data.id == "" ) %]selected="selected"[% END %]>No parent</option> >- [% FOREACH parent_lis IN parent_list %] >- <option value="[% parent_lis.id %]" [% IF ( data.parent.id == parent_lis.id ) %]selected="selected"[% END %]>[% parent_lis.title_link %]</option> >- [% END %] >+ [% IF ( data.id == "" ) %]<option value="" selected="selected">No parent</option>[% ELSE %]<option value="">No parent</option>[% END %] >+ [% FOREACH parent IN parent_list %] >+ [% IF ( data.parent.id == parent.id ) %]<option value="[% parent.id %]" selected="selected">[% parent.title_link %]</option>[% ELSE %]<option value="[% parent.id %]">[% parent.title_link %]</option>[% END %] >+ [% END %] > </select> > </li> > <li> >@@ -133,11 +194,11 @@ Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div> > </li> > <li> > <label for="number">Appear in position: </label> >- <input id="sortorder" size="3" name="sortorder" type="text" value="[% IF ( data.sortorder ) %][% data.sortorder %][% ELSE %]0[% END %]" /> >+ [% IF ( data.sortorder ) %]<input id="number" size="3" name="number" type="text" value="[% data.sortorder %]" />[% ELSE %]<input id="number" size="3" name="number" type="text" value="0" />[% END %] > </li> > <li> > <label for="publish">Publish: </label> >- <input type="checkbox" id="publish" name="publish"[% IF ( data.publish ) %] checked="checked"[% END %]/> >+ [% IF ( data.publish ) %]<input type="checkbox" id="publish" name="publish" checked="checked" />[% ELSE %]<input type="checkbox" id="publish" name="publish" />[% END %] > </li> > <li><label for="new">Content: </label> > <textarea name="content" id="content" cols="75" rows="10">[% data.content %]</textarea> >@@ -147,84 +208,111 @@ Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div> > <fieldset class="action"><input class="button" type="submit" value="Save" /> <a class="cancel" href="[% link_self %]">Cancel</a></fieldset> > </form> > [% ELSE %] >+ >+ <h1>Pages</h1> > <div style="margin-bottom:5px;"> >- <form name="form" method="post" action="[% link_self %]" > >+ <form name="filter" method="post" action="[% link_self %]"> > <label for="disp">Display location:</label> > <select name="disp" id="disp"> >- <option value="" [% IF ( disp == "" ) %]selected="selected"[% END %]>All</option> >- <option value="0" [% IF ( disp == "0" ) %]selected="selected"[% END %]>OPAC</option> >- <option value="1" [% IF ( disp == "1" ) %]selected="selected"[% END %]>Librarian interface</option> >+ [% IF ( disp == "" ) %]<option value="" selected="selected">All</option>[% ELSE %]<option value="">All</option>[% END %] >+ [% IF ( disp == "1" ) %]<option value="1" selected="selected">Staff interface</option>[% ELSE %]<option value="1">Staff interface</option>[% END %] >+ [% IF ( disp == "2" ) %]<option value="2" selected="selected">OPAC</option>[% ELSE %]<option value="2">OPAC</option>[% END %] > </select> > >- <label for="branch">Library: </label> >+ <label for="branch">Library:</label> > <select id="branch" name="branch"> >- <option value=""[% IF ( branch == "" ) %] selected="selected"[% END %]>All libraries</option> >- [% FOREACH branch_lis IN branch_list %] >- <option value="[% branch_lis.branchcode %]"[% IF ( branch_lis.branchcode == branch ) %] selected="selected"[% END %]>[% branch_lis.branchname %]</option> >+ [% IF ( branch == "" ) %]<option value="" selected="selected">All libraries</option>[% ELSE %]<option value="">All libraries</option>[% END %] >+ [% FOREACH br IN branch_list %] >+ [% IF ( br.branchcode == branch ) %] >+ <option value="[% br.branchcode %]" selected="selected">[% br.branchname %]</option> >+ [% ELSE %] >+ <option value="[% br.branchcode %]">[% br.branchname %]</option> >+ [% END %] > [% END %] > </select> > > <label for="lang">Language:</label> > <select name="lang" id="lang"> >- <option value="" [% IF ( lang == "" ) %]selected="selected"[% END %]>All</option> >- [% FOREACH lang_lis IN lang_list %] >- <option value="[% lang_lis.rfc4646_subtag %]" [% IF ( lang_lis.rfc4646_subtag == lang ) %]selected="selected"[% END %]>[% lang_lis.native_description %] ([% lang_lis.rfc4646_subtag %])</option> >+ [% IF ( lang == "" ) %]<option value="" selected="selected">All</option>[% ELSE %]<option value="">All</option>[% END %] >+ [% FOREACH language IN lang_list %] >+ [% IF ( language.rfc4646_subtag == lang ) %] >+ <option value="[% language.rfc4646_subtag %]" selected="selected">[% language.native_description %] ([% language.rfc4646_subtag %])</option> >+ [% ELSE %] >+ <option value="[% language.rfc4646_subtag %]">[% language.native_description %] ([% language.rfc4646_subtag %])</option> >+ [% END %] > [% END %] > </select> >+ <input type="hidden" name="op" value="filter" /> > <input type="submit" class="button" value="Filter" /> > </form> > </div> >- [% IF ( page_list_count ) %] >- <form name="del_form" method="post" action="[% link_self %]" onsubmit='return confirm(MSG_CONFIRM_DELETE_PAGE)'> >- <table id="newst"> >+ [% IF ( page_list.size ) %] >+ <form name="del_form" method="post" action="[% link_self %]"> >+ <table id="pages_table"> > <thead><tr> > <th> </th> >- <th>Pub.</th> >+ <th>Published</th> > <th>Parent</th> >- <th>Loc.</th> >- <th>Lib.</th> >- <th>Lang.</th> >- <th>Num.</th> >+ <th>Location</th> >+ <th>Library</th> >+ <th>Language</th> >+ <th>Number</th> > <th>Link title</th> > <th>Page title</th> > <th> </th> >- <th> </th> > </tr></thead> >- <tbody>[% FOREACH page_lis IN page_list %] >+ <tbody>[% FOREACH page IN page_list %] > <tr> >- <td> >- <input type="checkbox" name="ids" id="ids" value="[% page_lis.id %]" /> >- </td> >- <td>[% IF ( page_lis.publish ) %]Yes[% ELSE %]No[% END %]</td> >- <td>[% page_lis.parent.title_link %]</td> >- <td>[% SWITCH page_lis.display %] >- [% CASE "0" %] >- OPAC >- [% CASE "1" %] >- Staff interface >+ <td><input type="checkbox" name="ids" id="ids" value="[% page.id %]" /></td> >+ <td>[% IF ( page.publish ) %]Yes[% ELSE %]No[% END %]</td> >+ <td>[% page.parent.title_link %]</td> >+ <td>[% SWITCH page.location %] > [% CASE "" %] > All >+ [% CASE "1" %] >+ Staff interface >+ [% CASE "2" %] >+ OPAC >+ [% END %] >+ </td> >+ <td>[% IF ( page.branchcode == "" ) %]All[% ELSE %][% page.branchcode.branchname %][% END %]</td> >+ <td>[% IF ( page.lang == "" ) %]All[% ELSE %] >+ [% FOREACH lang IN lang_list %] >+ [% IF ( lang.rfc4646_subtag == page.lang ) %][% lang.native_description %] ([% lang.rfc4646_subtag %])[% END %] > [% END %] >+ [% END %]</td> >+ <td>[% page.sortorder %]</td> >+ <td><a href="[% link_self %]?op=form&id=[% page.id %]">[% page.title_link %]</a></td> >+ <td>[% page.title %]</td> >+ <td class="actions"> >+ <div class="btn-group"> >+ <a class="btn btn-default btn-xs dropdown-toggle" id="opencmspageactions[% page.id %]" role="button" data-toggle="dropdown" href="#"> >+ Actions <b class="caret"></b></a> >+ <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="opencmspageactions[% page.id %]"> >+ <li><a href="[% link_self %]?op=form&id=[% page.id %]"><i class="fa fa-pencil"></i> Edit</a></li> >+ <li><a href="[% link_self %]?op=delSingle&id=[% page.id %]" class="del_single"><i class="fa fa-trash"></i> Delete</a></li> >+ [% IF ( page.location == "" ) %] >+ <li><a href="[% link_opac %]?id=[% page.id %]"><i class="fa fa-eye"></i> OPAC</a></li> >+ <li><a href="[% link_self %]?op=view&id=[% page.id %]"><i class="fa fa-eye"></i> Intranet</a></li> >+ [% ELSIF ( page.location == "1" ) %] >+ <li><a href="[% link_self %]?op=view&id=[% page.id %]"><i class="fa fa-eye"></i> Intranet</a></li> >+ [% ELSIF ( page.location == "2" ) %] >+ <li><a href="[% link_opac %]?id=[% page.id %]"><i class="fa fa-eye"></i> OPAC</a></li> >+ [% END %] >+ </ul> >+ </div> > </td> >- <td>[% IF ( page_lis.branch == "" ) %] >- All >- [% ELSE %][% page_lis.branchname %] >- [% END %]</td> >- <td>[% IF ( page_lis.langcode == "" ) %]All[% ELSE %] >- [% page_lis.langcode %][% END %]</td> >- <td>[% page_lis.sortorder %]</td> >- <td><a href="[% link_self %]?op=form&id=[% page_lis.id %]">[% page_lis.title_link %]</a></td> >- <td>[% page_lis.title %]</td> >- <td><a href="[% link_self %]?op=form&id=[% page_lis.id %]">Edit</a></td> >- <td><a href="[% link_opac %]?id=[% page_lis.id %]">View</a></td> > </tr> > [% END %]</tbody> > </table> > <input type="hidden" name="op" value="del" /> >- <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset> >+ <fieldset class="action"> >+ <a class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a class="ClearAll"><i class="fa fa-remove"></i> Clear all</a> >+ <input type="submit" class="button" id="del_button" value="Delete selected" /> >+ </fieldset> > </form> > [% ELSE %] >- <p>No pages exists</p> >+ <div class="dialog message">No pages exist. <a href="[% link_self %]?op=form">Create a new page?</a></div> > [% END %] > [% END %] > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index cd82fd4..9466c2d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >@@ -286,20 +286,6 @@ > [% END %] > </ul> > </div> <!-- /#moresearches --> >- <div id="cms_nav_top"> >- [% IF ( cms_nav_top ) %] >- <ul> >- [% WHILE ( cms_item = cms_nav_top.next ) %] >- [% IF ( cms_item.id == cms_page.id ) %] >- <li class="cms_nav_top_active"> >- [% ELSE %] >- <li> >- [% END %] >- <a href="/cgi-bin/koha/opac-cmspages.pl?id=[% cms_item.id %]">[% cms_item.title_link %]</a></li> >- [% END %] >- </ul> >- [% END %] >- </div> > </div> <!-- /.row-fluid --> > > [% END # / OpacPublic %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/navigation.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/navigation.inc >index 2f58c25..e70ef67 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/navigation.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/navigation.inc >@@ -1,13 +1,24 @@ > [% USE raw %] > <div id="opacnav"> >-[% IF ( cms_nav_left ) %] >-<ul id="cms_nav_left"> >-[% WHILE ( item = cms_nav_left.next ) %] >- <li><a href="/cgi-bin/koha/opac-cmspages.pl?id=[% item.id %]">[% item.title_link | html %]</a></li> >-[% END %] >-</ul> >-[% END %] >-[% OpacNav | $raw %]</div> >+ [% IF ( links ) %] >+ <h4>Pages</h4> >+ <ul id="cms_nav"> >+ [% FOREACH link IN links %] >+ [% IF ( link.publish == '1' || link.publish == '0' && CAN_user_tools_edit_pages ) %] >+ [% IF ( link.location == '' || link.location == '2' ) %] >+ [% IF ( link.parent != '' ) %] >+ [% FOREACH parent IN parent_list %] >+ [% IF ( parent.id == link.parent ) %]<li style="margin-left:20px;"><a href="/cgi-bin/koha/opac-cmspages.pl?id=[% link.parent %]">[% parent.title_link | html %]</a> › <a href="/cgi-bin/koha/opac-cmspages.pl?id=[% link.id %]">[% link.title_link | html %]</a></li>[% END %] >+ [% END %] >+ [% ELSE %] >+ <li><a href="/cgi-bin/koha/opac-cmspages.pl?id=[% link.id %]">[% link.title_link | html %]</a></li> >+ [% END %] >+ [% END %][% END %] >+ [% END %] >+ </ul> >+ [% END %] >+ [% OpacNav | $raw %] >+</div> > [% IF IsPatronPage %] > <div id="usermenu">[% INCLUDE usermenu.inc %]</div> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-cmspages.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-cmspages.tt >index 9bc3e35..88811ef 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-cmspages.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-cmspages.tt >@@ -1,7 +1,7 @@ > [% USE Koha %] > [% USE Branches %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %][% IF (cms_page.title) %] - [% cms_page.title %][% ELSE %] catalog[% END%]</title> >+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online catalog[% END %][% IF (cms_page.title) %] › [% cms_page.title %][% END%]</title> > [% INCLUDE 'doc-head-close.inc' %] > [% BLOCK cssinclude %][% END %] > </head> >@@ -10,8 +10,12 @@ > > <div class="main"> > <ul class="breadcrumb"> >- <li><a href="/cgi-bin/koha/opac-main.pl">Home</a></li> >- <li><span class="divider">›</span></li> >+ <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> >+ [% IF ( cms_page.parent ) %] >+ [% FOREACH parent IN parents %] >+ [% IF parent.id == cms_page.parent %]<li><a href="/cgi-bin/koha/opac-cmspages.pl?id=[% cms_page.parent %]">[% parent.title_link %]</a> <span class="divider">›</span></li>[% END %] >+ [% END %] >+ [% END %] > <li><a href="#">[% cms_page.title_link %]</a></li> > </ul> > >@@ -39,48 +43,16 @@ > [% ELSE %] > <div class="span9"> > [% END %] >- [% cms_page.content %] >+ >+ [% IF ( cms_page.publish == 1 ) || ( cms_page.publish == 0 && CAN_user_tools_edit_pages ) %] >+ [% cms_page.content %] >+ [% ELSE %] >+ This page has not been published. >+ [% END %] >+ > [% IF ( OpacMainUserBlock ) %]<div id="opacmainuserblock">[% OpacMainUserBlock %]</div>[% END %] > </div> <!-- / .span 7/9 --> > >- [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) || OpacNavRight ) %] >- <div class="span3"> >- [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] >- [% UNLESS ( loggedinusername ) %] >- [% UNLESS ( casAuthentication || shibbolethAuthentication ) %] >- <div id="login"> >- <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth"> >- <input type="hidden" name="koha_login_context" value="opac" /> >- <fieldset class="brief"> >- <legend>Log in to your account:</legend> >- <label for="userid">Login:</label><input type="text" id="userid" name="userid" /> >- <label for="password">Password:</label><input type="password" id="password" name="password" /> >- <fieldset class="action"> >- <input type="submit" value="Log in" class="btn" /> >- </fieldset> >- [% IF PatronSelfRegistration && PatronSelfRegistrationDefaultCategory %]<div id="patronregistration"><p>Don't have an account? <a href="/cgi-bin/koha/opac-memberentry.pl">Register here.</a></p></div>[% END %] >- </fieldset> >- [% IF Koha.Preference( 'NoLoginInstructions' ) %] >- <div id="nologininstructions-main"> >- [% Koha.Preference( 'NoLoginInstructions' ) %] >- </div> >- [% END %] >- </form> >- </div> <!-- /#login --> >- [% END # /casAuthentication %] >- [% IF persona %] >- <a href="#" class="persona-button" id="browserid" ><span>Sign in with your email</span></a> >- [% END # /persona %] >- [% END # / loggedinusername %] >- [% END # /opacuserlogin %] >- [% IF ( OpacNavRight ) %] >- <div id="opacnavright"> >- [% OpacNavRight %] >- </div> >- [% END # /OpacNavRight %] >- </div> <!-- / .span3 --> >- [% END # /opacuserlogin || OpacNavRight %] >- > </div> <!-- /.container-fluid --> > </div> <!-- /.row-fluid --> > </div> <!-- /.main --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >index 2d0982e..4355902 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >+++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >@@ -225,37 +225,15 @@ td { > } > > #cms_nav_top { >- li { >- margin-bottom: -1em; >- display: inline; >- white-space: nowrap; >- border-top-left-radius: 5px; >- border-top-right-radius: 5px; >- background-color: #eee; >- border: 1px solid #D2D2CF; >- border-bottom: none; >- padding: 0.1em 0.8em 0em 0.8em; >- font-weight: bold; >- font-size: 1.2em; >- border-bottom: 1px solid #D2D2CF; >- a { >- text-decoration: none; >- } >- &.cms_nav_top_active { >- background-color: #fff; >- border-bottom: 1px solid #FFF; >- } >- } >- ul { >- margin: 0; >- display: inline; >- } >- display: inline; >-} >- >-ul#cms_nav_left { >- list-style-type: none; >- padding: 0; >+ list-style-type: circle; >+ padding: 0; >+ margin: 0; >+ a { >+ text-decoration: none; >+ } >+ a:hover { >+ text-decoration: underline; >+ } > } > > #news { >diff --git a/opac/opac-cmspages.pl b/opac/opac-cmspages.pl >index eaace18..37d5e9f 100755 >--- a/opac/opac-cmspages.pl >+++ b/opac/opac-cmspages.pl >@@ -23,6 +23,7 @@ use C4::Auth; > use C4::Output; > use C4::Languages qw( getTranslatedLanguages accept_language ); > use Koha::CmsPages; >+use Data::Dumper; > > my $input = new CGI; > my $id = scalar $input->param( 'id' ) // ''; >@@ -42,11 +43,14 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > my ( $theme, $news_lang, $availablethemes ) = C4::Templates::themelanguage( > C4::Context->config( 'opachtdocs'), 'opac-cmspages.tt', 'opac', $input ); > >-my ($cms_nav_top, $cms_nav_left, $cms_data) = Koha::CmsPages->page( $id ); >+# List all pages, if id is set generate parent page list and data. >+my ( $page_list, $parent_list, $page_data ) = Koha::CmsPages->list( $id ); >+ >+my $links = Koha::CmsPages->search( {}, { order_by => 'sortorder' } ); >+my $cms_data = Koha::CmsPages->find( $id ); > $template->param( >- cms_page => $cms_data, >- cms_nav_top => $cms_nav_top, >- cms_nav_left => $cms_nav_left, >+ links => $links, >+ cms_page => $cms_data, >+ parent_list => $parent_list, > ); >- > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 9fe7bd6..20833f1 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -29,7 +29,7 @@ use C4::Members; > use C4::Overdues; > use Koha::Checkouts; > use Koha::Holds; >-use Koha::CmsPages qw( list ); >+use Koha::CmsPages; > > my $input = new CGI; > my $dbh = C4::Context->dbh; >@@ -98,9 +98,17 @@ $template->param( > daily_quote => $quote, > ); > >+my $id = scalar $input->param( 'id' ) // ''; >+my ( $page_list, $parent_list, $page_data ) = Koha::CmsPages->list( $id ); >+my $links = Koha::CmsPages->search( {}, { order_by => 'parent' } ); >+my $cms_data = Koha::CmsPages->page( $id ); > $template->param( >- cms_nav_top => Koha::CmsPages->child_links( undef ), >-); >+ links => $links, >+ cms_page => $cms_data, >+ parent_list => $parent_list, >+ ); >+ >+ > > if (C4::Context->preference('GoogleIndicTransliteration')) { > $template->param('GoogleIndicTransliteration' => 1); >diff --git a/t/Pages.t b/t/Pages.t >deleted file mode 100644 >index 5e6d463..0000000 >--- a/t/Pages.t >+++ /dev/null >@@ -1,31 +0,0 @@ >-#!/usr/bin/perl >- >-use Modern::Perl; >-use Carp; >-use Test::More tests => 2; >-use Data::Dumper::Concise; >- >-BEGIN { >- use_ok('C4::Content'); >-} >- >-my $src = [ >- { id => '1', parent => '' }, >- { id => '2', parent => '1' }, >- { id => '3', parent => '1' }, >- { id => '4', parent => '2' }, >- { id => '5', parent => '2' }, >-]; >- >-my $expected = [ >- { id => '1', children => [ >- { id => '2', children => [ >- { id => '4', children => [] }, >- { id => '5', children => [] } ] >- }, >- { id => '3', children => [] } ] >- }, >-]; >- >-my $output = C4::Content::_SQLToPerl($src); >-is_deeply($output, $expected); >diff --git a/t/db_dependent/Pages.t b/t/db_dependent/Pages.t >index 2c98c38..bad7477 100644 >--- a/t/db_dependent/Pages.t >+++ b/t/db_dependent/Pages.t >@@ -18,75 +18,96 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 10; > use Test::Warn; >-use Data::Dumper::Concise; > > use C4::Context; > use Koha::Database; > use t::lib::TestBuilder; > > BEGIN { >- use_ok('Koha::Objects'); > use_ok('Koha::CmsPages'); >+ use_ok('Koha::CmsPage'); > } > >-my $builder = t::lib::TestBuilder->new(); >+my $database = Koha::Database->new(); >+my $schema = $database->schema(); >+my $dbh = C4::Context->dbh; >+my $builder = t::lib::TestBuilder->new(); > >-# Start transaction >-my $dbh = C4::Context->dbh; >-$dbh->{ AutoCommit } = 0; >-$dbh->{ RaiseError } = 1; >-$dbh->do( 'DELETE FROM items' ); >+$schema->storage->txn_begin(); >+$dbh->do( 'DELETE FROM cms_pages' ); >+$dbh->do( 'DELETE FROM issues' ); > $dbh->do( 'DELETE FROM borrowers' ); >+$dbh->do( 'DELETE FROM items' ); > $dbh->do( 'DELETE FROM branches' ); >-$dbh->do( 'DELETE FROM cms_pages' ); > >-my $branchcode = $builder->build({ source => 'Branch' }); >- >-my $page10 = $builder->build({ >- source => 'CmsPage', >- value => { >- parent => undef, >- title_link => 'page 10', >- title => 'full page 10', >- published => 1, >- sortorder => 1, >- } >-}); >-my $page11 = $builder->build({ >- source => 'CmsPage', >- value => { >- parent => $page10->{'id'}, >- title_link => 'subpage 11', >- title => 'full subpage 11', >- published => 1, >- sortorder => 0, >- } >+my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'}; >+my $borrowernumber = $builder->build({ source => 'Borrower' })->{'borrowernumber'}; >+ >+# new parent page >+my $parent_page = Koha::CmsPages->add({ >+ id => 1, >+ branchcode => $branchcode, >+ location => 2, >+ lang => '', >+ parent => undef, >+ title_link => 'page1', >+ title => 'Page 1', >+ publish => 0, >+ sortorder => 1, >+ content => "This is the first page.", > }); >-my $page12 = $builder->build({ >- source => 'CmsPage', >- value => { >- parent => $page10->{'id'}, >- title_link => 'subpage 12', >- title => 'full subpage 12', >- published => 1, >- sortorder => 1, >- } >+ >+is($parent_page->title, 'Page 1', "First page created"); >+ >+# new child page >+my $child_page = Koha::CmsPages->add({ >+ id => 2, >+ branchcode => $branchcode, >+ location => 2, >+ lang => '', >+ parent => $parent_page->id, >+ title_link => 'page2', >+ title => 'Page 2', >+ publish => 1, >+ sortorder => 2, >+ content => "This is the second page.", > }); >-my $page20 = $builder->build({ >- source => 'CmsPage', >- value => { >- parent => undef, >- title_link => 'page 20', >- title => 'full page 20', >- published => 0, >- sortorder => 2, >- } >+ >+# $page->parent specifies who this page is the parent of >+is(Koha::CmsPages->find($child_page->parent)->title, 'Page 1', 'Child and parent page connected'); >+ >+# Koha::CmsPages->list() with no specified ID should return all pages >+my ( $page_list, $parent_list, $data ) = Koha::CmsPages->list( '' ); >+is(scalar @{ $page_list }, 2, "Two pages have been created"); >+ >+# Koha::CmsPages->list() is used for filtering (filter display location) >+( $page_list, $parent_list, $data ) = Koha::CmsPages->list( '', 2, '', '' ); >+is(scalar @{ $page_list }, 2, "Both pages can be seen on staff interface"); >+ >+is($parent_list->[0]->{id}, $parent_page->id, "Correct page is returned as a parent"); >+is($data, undef, "Data is undefined because no ID was given"); >+ >+# Koha::CmsPages->list() is used to show data about a page when given an ID >+( $page_list, $parent_list, $data ) = Koha::CmsPages->list( 2 ); >+is($data->{content}, "This is the second page.", "Data is defined when given an ID"); >+ >+# Try to add a child page under a page where their locations do not match up >+my $test_page = Koha::CmsPages->add({ >+ id => 3, >+ branchcode => $branchcode, >+ location => 1, >+ lang => '', >+ parent => $child_page->id, >+ title_link => 'failedadd', >+ title => 'Failed add', >+ publish => 0, >+ sortorder => 3, >+ content => "This page should not be added", > }); > >-my $result = Koha::CmsPages->child_links( undef ); >-is_deeply( $result, [ $page10, $page20 ]); >+is($test_page, undef, "Child page cannot be added under a page if their locations do not match"); > > $dbh->rollback(); > >diff --git a/tools/cmspages.pl b/tools/cmspages.pl >index 314724a..0f7258b 100755 >--- a/tools/cmspages.pl >+++ b/tools/cmspages.pl >@@ -23,8 +23,9 @@ use CGI qw( -utf8 ); > use C4::Auth; > use C4::Output; > use C4::Languages qw( getTranslatedLanguages ); >-use Koha::Database; > use Koha::CmsPages; >+use Koha::Libraries; >+use Koha::CmsPage; > > my $link_self = '/cgi-bin/koha/tools/cmspages.pl'; > >@@ -50,17 +51,14 @@ $template->param( > disp => $disp > ); > >-my $schema = Koha::Database->new->schema; >-my @branches = $schema->resultset( 'Branch' )->all; >-$template->param( branch_list => @branches ); >- > my $lang_list = getTranslatedLanguages; >+my $branches = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); > > # List all pages, if id is set generate parent page list and data. > my ( $page_list, $parent_list, $page_data ) = Koha::CmsPages->list( $id ); > > $template->param( >- page_list_count => scalar $page_list, >+ branch_list => $branches, > page_list => $page_list, > parent_list => $parent_list, > data => $page_data, >@@ -74,17 +72,52 @@ if ( $op eq 'form' ) { > id => $id, > op => 'add' > ); >-} >- >-if ( $op eq 'add' ) { >- Koha::CmsPages->add( $cgi ); >+} elsif ( $op eq 'add' ) { >+ my $success = Koha::CmsPages->add({ >+ id => scalar $cgi->param('id'), >+ parent => scalar $cgi->param('parent'), >+ location => scalar $cgi->param('disp'), >+ branchcode => scalar $cgi->param('branch'), >+ lang => scalar $cgi->param('lang'), >+ sortorder => scalar $cgi->param('number'), >+ title => scalar $cgi->param('title'), >+ title_link => scalar $cgi->param('title_link'), >+ publish => scalar $cgi->param('publish'), >+ content => scalar $cgi->param('content'), >+ }); >+ unless ($success) { >+ $template->param( failed_add => 1 ); >+ } >+ if ($success) { >+ print $cgi->redirect( $link_self ); >+ } >+} elsif ( $op eq 'delSingle' ) { >+ Koha::CmsPages->find( $id )->delete(); > print $cgi->redirect( $link_self ); >- > } elsif ( $op eq 'del' ) { > # param => multi_param; no list-ctx warnings >- Koha::CmsPages->remove( $cgi->multi_param( 'ids' ) ); >+ my @ids = $cgi->multi_param('ids'); >+ foreach (@ids){ >+ Koha::CmsPages->find($_)->delete; >+ } > print $cgi->redirect( $link_self ); >+} elsif ( $op eq 'view' ) { >+ my $cms_data = Koha::CmsPages->find( $id ); >+ my $links = Koha::CmsPages->search( {}, { order_by => 'sortorder' } ); >+ $template->param( >+ links => $links, >+ cms_page => $cms_data, >+ view => 1, >+ id => $id, >+ op => 'view', >+ ); >+} elsif ( $op eq 'filter' ) { >+ my ( $page_list, $parent_list, $page_data ) = Koha::CmsPages->list( $id, $disp, $branch, $lang ); >+ $template->param( >+ page_list => $page_list, >+ parent_list => $parent_list, >+ data => $page_data, >+ ); > } >- > $template->param( link_self => $link_self ); > output_html_with_http_headers $cgi, $cookie, $template->output; >-- >2.1.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 15326
:
45621
|
58272
|
58607
|
58608
|
58609
|
58787
|
63904
|
63905
|
64241
|
64941
|
64942
|
66255
|
70866
|
70867
|
70868
|
70869
|
70870
|
70871
|
76387
|
76388
|
76389
|
76390
|
76391
|
76392
|
78232
|
78233
|
78234
|
78235
|
78236
|
78237
|
78238
|
78240
|
79269
|
83318
|
83319
|
83320
|
83321
|
83322
|
83323
|
83324
|
83325
|
83326
|
83404
|
83405
|
83406
|
83407
|
83408
|
83409
|
83410
|
83411
|
83412
|
84682
|
84683
|
84684
|
84685
|
84686
|
84687
|
84688
|
84689
|
84690
|
84691
|
87494
|
87495
|
87496
|
87497
|
87498
|
87499
|
87500
|
87501
|
87502
|
87503
|
87608
|
87609
|
87610
|
87617
|
96084
|
96085
|
96086
|
96087
|
96088
|
96089
|
96090
|
96091
|
96092
|
96093
|
96094
|
96095
|
96096
|
96097
|
96098
|
97237
|
101565
|
101566
|
101567
|
101568
|
101569
|
101570
|
101571
|
101572
|
101573
|
101574
|
101575
|
101576
|
101577
|
101578
|
101579
|
101580
|
128341
|
128342
|
128343
|
128344
|
128345
|
128346
|
128347
|
128348
|
128349
|
128350
|
128351
|
128352
|
128353
|
128354
|
128355
|
128356
|
128357
|
128585
|
128642
|
136432
|
136757
|
136768
|
138489
|
138493
|
139028
|
139029
|
139030
|
139031
|
139111
|
139123
|
139124
|
139125
|
139172
|
139173
|
139174