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

(-)a/Koha/CmsPage.pm (+53 lines)
Line 0 Link Here
1
package Koha::CmsPage;
2
3
# Copyright Halland County Library 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp;
23
24
use Koha::Database;
25
26
use base qw( Koha::Object );
27
28
=head1 NAME
29
30
Koha::CmsPage - Koha Page Object class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub type {
43
    return 'CmsPage';
44
}
45
46
=head1 AUTHOR
47
48
Martin Persson <xarragon@gmail.com>
49
Halland County Library
50
51
=cut
52
53
1;
(-)a/Koha/CmsPages.pm (+200 lines)
Line 0 Link Here
1
package Koha::CmsPages;
2
3
# Copyright Halland County Library 2015
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use Carp qw( carp );
23
24
use Koha::Database;
25
use Koha::CmsPage;
26
27
use base qw( Koha::Objects );
28
29
=head1 NAME
30
31
Koha::CmsPage - Koha CMS Page Object Class
32
33
=head1 API
34
35
=head2 Class Methods
36
37
=cut
38
39
=head3 type
40
41
=cut
42
43
sub type {
44
    return 'CmsPage';
45
}
46
47
sub object_class {
48
    return 'Koha::CmsPage';
49
}
50
51
=head3 add
52
Adds a new page to the CMS database based on the input data.
53
=cut
54
55
sub add {
56
    my ( $self, $input ) = @_;
57
warn "input: ", scalar $input->param('location');
58
    carp( 'Koha::CmsPages::add() undefined parameter: input' ) unless defined $input;
59
    my $data = {
60
        parent     =>   scalar          $input->param( 'parent' )     eq '' ? undef : scalar $input->param( 'parent' ),
61
        location   =>   scalar          $input->param( 'location' )   eq '' ? undef : scalar $input->param( 'location'),
62
        branchcode =>   scalar          $input->param( 'branchcode' ) eq '' ? undef : scalar $input->param( 'branchcode' ),
63
        lang       =>   scalar          $input->param( 'lang' ),
64
        sortorder  =>   scalar          $input->param( 'sortorder' ),
65
        title      =>   scalar          $input->param( 'title' ),
66
        title_link =>   scalar          $input->param( 'title_link' ),
67
        publish    =>   defined (scalar $input->param( 'publish' )),
68
        content    =>   scalar          $input->param( 'content' )
69
    };
70
71
    if (defined $input->param( 'id' )) {
72
        $data->{'id'} = scalar $input->param( 'id' );
73
    }
74
75
    my $new_page = $self->_resultset()->update_or_create( $data, { key => 'primary' });
76
77
    return $new_page;
78
}
79
80
=head3 list
81
82
Lists pages based input filtering paramters for location, branch and language.
83
84
=cut
85
86
sub list {
87
    my ( $self, $id, $disp, $branch, $lang ) = @_;
88
89
    my $filter = { };
90
    $filter->{'location'} = $disp   unless not defined $disp;
91
    $filter->{'branch'}   = $branch unless not defined $branch;
92
    $filter->{'lang'}     = $lang   unless not defined $lang;
93
94
    my $pages = $self->_resultset()->search( undef, {
95
        order_by => {
96
		    -asc => [qw/parent location branchcode lang sortorder/]
97
        }, where => $filter
98
    } );
99
100
    my $page_list = [];
101
    my $parent_list = [];
102
    my %index;
103
    my $data;
104
    while ( my $page = $pages->next ) {
105
        my $new_page = {
106
            id         => scalar $page->id,
107
            parent     => scalar $page->parent,
108
            branchcode => scalar $page->branchcode,
109
            lang       => scalar $page->lang,
110
            title_link => scalar $page->title_link,
111
            title      => scalar $page->title,
112
            sortorder  => scalar $page->sortorder,
113
            location   => scalar $page->location,
114
            publish    => scalar $page->publish,
115
            content    => scalar $page->content,
116
        };
117
        push(@{ $page_list }, $new_page );
118
119
        # If requested id, store in 'data' output (used for editing a page):
120
        if ( defined $id && $id eq $new_page->{'id'} ) {
121
            $data = $new_page;
122
        } else {
123
            push(@{ $parent_list }, $new_page );
124
        }
125
        $index{ $page->id } = $new_page;
126
    }
127
128
    # Replace parent id with a hash with id and title_link in it.
129
    foreach my $page (@{ $page_list }) {
130
        my $old_id = $page->{'parent'};
131
        my $parent = { id => $old_id };
132
        $parent->{'title_link'} = $index{ $old_id }->{'title_link'} unless not defined $old_id;
133
        $page->{'parent'} = $parent;
134
    }
135
136
    return ( $page_list, $parent_list, $data );
137
}
138
139
=head3 page
140
141
Retrieves all data to show a single CMS page.
142
143
=cut
144
145
sub page {
146
	my ( $self, $id ) = @_;
147
148
	carp( 'Missing CMS page id parameter in Koha::Pages::page' ) unless defined $id;
149
150
	# Probably want to merge these to a single query:
151
	my $top_links = $self->_resultset()->search(
152
			{ parent => undef }, { qw/id title_link/ });
153
154
	my $page_links = $self->_resultset()->search(
155
			{ parent => $id }, { qw/id title_link/ });
156
157
	my $page_data = $self->_resultset()->find( $id );
158
159
	return ( $top_links, $page_links, $page_data );
160
}
161
162
=head3 child_links
163
164
Lists pages which are children of a specific id (or undef for root).
165
166
=cut
167
168
sub child_links {
169
    my ( $self, $id ) = @_;
170
171
	# 'id' can be undefined if listing top-level links.
172
    my $rs = $self->_resultset()->search({ parent => $id },
173
            { columns => [qw/id title_link/] } );
174
175
    return $rs;
176
}
177
178
=head3 remove
179
180
Removes a page identified by id from the CMS database.
181
182
=cut
183
184
sub remove {
185
    my ( $self, @ids ) = @_;
186
187
    carp( 'Koha::CmsPages::remove() undefined parameter ids' ) unless @ids;
188
189
    my $pages = $self->_resultset()->search({ id => \@ids });
190
    $pages->delete;
191
}
192
193
=head1 AUTHOR
194
195
Martin Persson <xarragon@gmail.com>
196
Halland County Library
197
198
=cut
199
200
1;
(-)a/installer/data/mysql/atomicupdate/bug15326-add_cms_pages.sql (+17 lines)
Line 0 Link Here
1
 CREATE TABLE `cms_pages` (
2
  `id` int(6) NOT NULL AUTO_INCREMENT,
3
  `parent` int(6) DEFAULT NULL,
4
  `branchcode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
5
  `lang` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
6
  `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
7
  `title_link` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
8
  `sortorder` int(3) NOT NULL DEFAULT 0,
9
  `location` tinyint(1) DEFAULT NULL,
10
  `publish` tinyint(1) NOT NULL DEFAULT 0,
11
  `content` text COLLATE utf8_unicode_ci,
12
  PRIMARY KEY (`id`),
13
  INDEX `parent_index` (`parent`),
14
  INDEX `lang_index` (`lang`),
15
  INDEX `branchcode_index` (`branchcode`),
16
  CONSTRAINT `cmspages_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
17
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
(-)a/installer/data/mysql/kohastructure.sql (+23 lines)
Lines 4193-4198 CREATE TABLE `oauth_access_tokens` ( Link Here
4193
    PRIMARY KEY (`access_token`)
4193
    PRIMARY KEY (`access_token`)
4194
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4194
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4195
4195
4196
--
4197
-- Table structure for table 'cms_pages', used for CMS functionality.
4198
--
4199
4200
DROP TABLE IF EXISTS `cms_pages`;
4201
 CREATE TABLE `cms_pages` (
4202
  `id` int(6) NOT NULL AUTO_INCREMENT,
4203
  `parent` int(6) DEFAULT NULL,
4204
  `branchcode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,
4205
  `lang` varchar(25) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
4206
  `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
4207
  `title_link` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL,
4208
  `sortorder` int(3) NOT NULL DEFAULT 0,
4209
  `location` tinyint(1) DEFAULT NULL,
4210
  `publish` tinyint(1) NOT NULL DEFAULT 0,
4211
  `content` text COLLATE utf8_unicode_ci,
4212
  PRIMARY KEY (`id`),
4213
  INDEX `parent_index` (`parent`),
4214
  INDEX `lang_index` (`lang`),
4215
  INDEX `branchcode_index` (`branchcode`),
4216
  CONSTRAINT `pages_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE
4217
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
4218
4196
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
4219
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
4197
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
4220
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
4198
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
4221
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
(-)a/installer/data/mysql/userpermissions.sql (+1 lines)
Lines 61-66 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
61
   (13, 'access_files', 'Access to the files stored on the server'),
61
   (13, 'access_files', 'Access to the files stored on the server'),
62
   (13, 'upload_general_files', 'Upload any file'),
62
   (13, 'upload_general_files', 'Upload any file'),
63
   (13, 'upload_manage', 'Manage uploaded files'),
63
   (13, 'upload_manage', 'Manage uploaded files'),
64
   (13, 'edit_pages', 'Create, edit and delete CMS pages for OPAC and staff interfaces'),
64
   (15, 'check_expiration', 'Check the expiration of a serial'),
65
   (15, 'check_expiration', 'Check the expiration of a serial'),
65
   (15, 'claim_serials', 'Claim missing serials'),
66
   (15, 'claim_serials', 'Claim missing serials'),
66
   (15, 'create_subscription', 'Create a new subscription'),
67
   (15, 'create_subscription', 'Create a new subscription'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+1 lines)
Lines 60-65 Link Here
60
    [%- CASE 'delete_anonymize_patrons' -%]<span>Delete old borrowers and anonymize circulation history (deletes borrower reading history)</span>
60
    [%- CASE 'delete_anonymize_patrons' -%]<span>Delete old borrowers and anonymize circulation history (deletes borrower reading history)</span>
61
    [%- CASE 'edit_calendar' -%]<span>Define days when the library is closed</span>
61
    [%- CASE 'edit_calendar' -%]<span>Define days when the library is closed</span>
62
    [%- CASE 'edit_news' -%]<span>Write news for the OPAC and staff interfaces</span>
62
    [%- CASE 'edit_news' -%]<span>Write news for the OPAC and staff interfaces</span>
63
    [%- CASE 'edit_pages' -%]<span>Create, edit and delete CMS pages for OPAC and staff interfaces</span>
63
    [%- CASE 'edit_notice_status_triggers' -%]<span>Set notice/status triggers for overdue items</span>
64
    [%- CASE 'edit_notice_status_triggers' -%]<span>Set notice/status triggers for overdue items</span>
64
    [%- CASE 'edit_notices' -%]<span>Define notices</span>
65
    [%- CASE 'edit_notices' -%]<span>Define notices</span>
65
    [%- CASE 'edit_patrons' -%]<span>Perform batch modification of patrons</span>
66
    [%- CASE 'edit_patrons' -%]<span>Perform batch modification of patrons</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cmspages.tt (+238 lines)
Line 0 Link Here
1
[% USE KohaDates %]
2
[% USE Koha %]
3
[% SET link_opac_base = Koha.Preference( 'OPACBaseURL' ) %]
4
[% SET link_opac = link_opac_base _ '/cgi-bin/koha/opac-cmspages.pl' %]
5
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Tools &rsaquo; Pages</title>
7
[% INCLUDE 'doc-head-close.inc' %]
8
[% IF ( opac_page_count ) %]
9
    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
10
    [% INCLUDE 'datatables.inc' %]
11
    <script type="text/javascript">//<![CDATA[
12
    $(document).ready(function() {
13
        $("#newst").dataTable($.extend(true, {}, dataTablesDefaults, {
14
            "aoColumnDefs": [
15
                { "aTargets": [ 0,-1,-2 ], "bSortable": false },
16
                { "aTargets": [ 0, -1 ], "bSearchable": false },
17
                { 'sType': "title-string", 'aTargets' : [ 'title-string'] }
18
            ],
19
            "sPaginationType": "full_numbers"
20
        }));
21
    });
22
    //]]>
23
    </script>
24
[% END %]
25
<script type="text/javascript" src="[% interface %]/lib/tiny_mce/tiny_mce.js"></script>
26
<script type="text/javascript">//<![CDATA[
27
var MSG_CONFIRM_DELETE_PAGE  = _("Are you sure you want to delete the selected page?");
28
29
tinyMCE.init({
30
    mode : "textareas",
31
    theme : "advanced",
32
    convert_urls : false,
33
    relative_urls : false,
34
    content_css : "[% themelang %]/css/tinymce.css",
35
    plugins : "table,save,advhr,advlink,searchreplace,print,contextmenu",
36
    theme_advanced_buttons1 : "save,|,bold,italic,|,cut,copy,paste,|,search,replace,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,|,link,unlink,anchor,cleanup,help,code,advhr,|,print",
37
    theme_advanced_buttons2 : "tablecontrols,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,removeformat,|,visualaid,|,sub,sup,|,charmap",
38
    theme_advanced_buttons3 : "",
39
    theme_advanced_toolbar_location : "top",
40
    theme_advanced_toolbar_align : "left",
41
    theme_advanced_path_location : "bottom",
42
    theme_advanced_resizing : true,
43
    plugin_insertdate_dateFormat : "%Y-%m-%d",
44
    plugin_insertdate_timeFormat : "%H:%M:%S",
45
    apply_source_formatting : true,
46
    height : "300",
47
    width : "700"
48
//]]>
49
});
50
//]]>
51
</script>
52
</head>
53
<body id="tools_koha-content" class="tools">
54
[% INCLUDE 'header.inc' %]
55
[% INCLUDE 'cat-search.inc' %]
56
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( form ) %]<a href="[% link_self %]">Pages</a> &rsaquo; [% IF ( id ) %]
57
Edit page[% ELSE %]Add page[% END %][% ELSE %]Pages[% END %]</div>
58
59
[% IF ( form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
60
   <div id="bd">
61
    <div id="yui-main">
62
    <div class="yui-b">
63
64
[% UNLESS ( link_opac_base && link_self) %]
65
    <div class="dialog alert">
66
    [% UNLESS ( link_opac_base ) %]
67
    Warning: Preference <em>OPACBaseURL</em> not set, some links might not work!</div>
68
    [% END %]
69
    [% UNLESS ( link_self ) %]
70
    Warning: Variable <em>link_self</em> not set, some links might not work!</div>
71
    [% END %]
72
[% END %]
73
[% UNLESS ( form ) %]
74
    [% IF error_message == 'title_missing' %]
75
        <div class="dialog alert">Error: Required page title missing!</div>
76
    [% END %]
77
<div id="toolbar" class="btn-toolbar">
78
    <a class="btn btn-small" id="newentry" href="[% link_self %]?op=form"><i class="icon-plus"></i> New page</a>
79
</div>
80
[% END %]
81
<pre>DEBUG: [% debug %]</pre>
82
<pre>DEBUG2: data.location: [% data.location %] data.branchcode: [% data.branchcode %]</pre>
83
[% IF ( form ) %]
84
        <form name="form" method="post" enctype="multipart/form-data" action="[% link_self %]" >
85
            <input type="hidden" name="op" value="[% op %]" />
86
            <input type="hidden" name="id" value="[% id %]" />
87
            <fieldset class="rows">
88
            <legend>Page</legend>
89
            <ol>
90
            <li>
91
                <label for="disp">Display location</label>
92
                <select id="disp" name="disp">
93
                    <option value=""  [% IF ( data.disp == ""  ) %]selected="selected"[% END %]>All</option>
94
                    <option value="1" [% IF ( data.disp == "1" ) %]selected="selected"[% END %]>Intranet</option>
95
                    <option value="2" [% IF ( data.disp == "2" ) %]selected="selected"[% END %]>OPAC</option>
96
                </select>
97
            </li>
98
            <li>
99
                <label for="branch">Library: </label>
100
                <select id="branch" name="branch">
101
                    <option value=""[% IF ( data.branchcode == '' ) %] selected="selected"[% END %]>All libraries</option>
102
                [% FOREACH branch_lis IN branch_list %]
103
                    <option value="[% branch_lis.branchcode %]"[% IF ( branch_lis.branchcode == data.branchcode ) %] selected="selected"[% END %]>[% branch_lis.branchname %]</option>
104
                [% END %]
105
                </select>
106
            </li>
107
            <li>
108
                <label for="lang">Language</label>
109
<pre>LANG: [% lang %]</pre>
110
                <select id="lang" name="lang">
111
                    <option value="" [% IF ( data.lang == "" ) %]selected="selected"[% END %]>All</option>
112
                    [% FOREACH lang_lis IN lang_list %]
113
                        <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>
114
                    [% END %]
115
                </select>
116
            </li>
117
            <li>
118
                <label for="parent">Parent page: </label>
119
                <select id="parent" name="parent">
120
                    <option value="" [% IF ( data.id == "" ) %]selected="selected"[% END %]>No parent</option>
121
                [% FOREACH parent_lis IN parent_list %]
122
                        <option value="[% parent_lis.id %]" [% IF ( data.parent.id == parent_lis.id ) %]selected="selected"[% END %]>[% parent_lis.title_link %]</option>
123
                [% END %]
124
                </select>
125
            </li>
126
            <li>
127
                <label for="title_link" class="required">Link title: </label>
128
                <input id="title_link" size="30" type="text" name="title_link" value="[% data.title_link %]" required="required" class="required" /> <span class="required">Required</span>
129
            </li>
130
            <li>
131
                <label for="title">Page title: </label>
132
                <input id="title" size="30" type="text" name="title" value="[% data.title %]" />
133
            </li>
134
            <li>
135
                <label for="number">Appear in position: </label>
136
                <input id="sortorder" size="3" name="sortorder" type="text" value="[% IF ( data.sortorder ) %][% data.sortorder %][% ELSE %]0[% END %]" />
137
            </li>
138
            <li>
139
                <label for="publish">Publish: </label>
140
                <input type="checkbox" id="publish" name="publish"[% IF ( data.publish ) %] checked="checked"[% END %]/>
141
            </li>
142
            <li><label for="new">Content: </label>
143
            <textarea name="content" id="content" cols="75" rows="10">[% data.content %]</textarea>
144
            </li>
145
            </ol>
146
            </fieldset>
147
            <fieldset class="action"><input class="button" type="submit" value="Save" /> <a class="cancel" href="[% link_self %]">Cancel</a></fieldset>
148
        </form>
149
    [% ELSE %]
150
        <div style="margin-bottom:5px;">
151
        <form name="form" method="post" action="[% link_self %]" >
152
            <label for="disp">Display location:</label>
153
            <select name="disp" id="disp">
154
                <option value=""  [% IF ( disp == ""  ) %]selected="selected"[% END %]>All</option>
155
                <option value="0" [% IF ( disp == "0" ) %]selected="selected"[% END %]>OPAC</option>
156
                <option value="1" [% IF ( disp == "1" ) %]selected="selected"[% END %]>Librarian interface</option>
157
            </select>
158
159
            <label for="branch">Library: </label>
160
            <select id="branch" name="branch">
161
                <option value=""[% IF ( branch == "" ) %] selected="selected"[% END %]>All libraries</option>
162
                [% FOREACH branch_lis IN branch_list %]
163
                <option value="[% branch_lis.branchcode %]"[% IF ( branch_lis.branchcode == branch ) %] selected="selected"[% END %]>[% branch_lis.branchname %]</option>
164
                [% END %]
165
            </select>
166
167
            <label for="lang">Language:</label>
168
            <select name="lang" id="lang">
169
                <option value="" [% IF ( lang == "" ) %]selected="selected"[% END %]>All</option>
170
                [% FOREACH lang_lis IN lang_list %]
171
                <option value="[% lang_lis.rfc4646_subtag %]" [% IF ( lang_lis.rfc4646_subtag == lang ) %]selected="selected"[% END %]>[% lang_lis.native_description %] ([% lang_lis.rfc4646_subtag %])</option>
172
                [% END %]
173
            </select>
174
            <input type="submit" class="button" value="Filter" />
175
        </form>
176
        </div>
177
        [% IF ( page_list_count ) %]
178
        <form name="del_form" method="post" action="[% link_self %]" onsubmit='return confirm(MSG_CONFIRM_DELETE_PAGE)'>
179
                <table id="newst">
180
                   <thead><tr>
181
                        <th>&nbsp;</th>
182
                        <th>Pub.</th>
183
                        <th>Parent</th>
184
                        <th>Loc.</th>
185
                        <th>Lib.</th>
186
                        <th>Lang.</th>
187
                        <th>Num.</th>
188
                        <th>Link title</th>
189
                        <th>Page title</th>
190
                        <th>&nbsp;</th>
191
                        <th>&nbsp;</th>
192
                    </tr></thead>
193
                    <tbody>[% FOREACH page_lis IN page_list %]
194
                        <tr>
195
                            <td>
196
                                <input type="checkbox" name="ids" id="ids" value="[% page_lis.id %]" />
197
                            </td>
198
                            <td>[% IF ( page_lis.publish ) %]Yes[% ELSE %]No[% END %]</td>
199
                            <td>[% page_lis.parent.title_link %]</td>
200
                            <td>[% SWITCH page_lis.display %]
201
                                [% CASE "0" %]
202
                                    OPAC
203
                                [% CASE "1" %]
204
                                    Staff interface
205
                                [% CASE "" %]
206
                                    All
207
                                [% END %]
208
                            </td>
209
                            <td>[% IF ( page_lis.branch == "" ) %]
210
                                All
211
                                [% ELSE %][% page_lis.branchname %]
212
                                [% END %]</td>
213
                            <td>[% IF ( page_lis.langcode == "" ) %]All[% ELSE %]
214
                                [% page_lis.langcode %][% END %]</td>
215
                            <td>[% page_lis.sortorder %]</td>
216
                            <td><a href="[% link_self %]?op=form&amp;id=[% page_lis.id %]">[% page_lis.title_link %]</a></td>
217
                            <td>[% page_lis.title %]</td>
218
                            <td><a href="[% link_self %]?op=form&amp;id=[% page_lis.id %]">Edit</a></td>
219
                            <td><a href="[% link_opac %]?id=[% page_lis.id %]">View</a></td>
220
                        </tr>
221
                    [% END %]</tbody>
222
                </table>
223
                <input type="hidden" name="op" value="del" />
224
                <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset>
225
            </form>
226
        [% ELSE %]
227
            <p>No pages exists</p>
228
        [% END %]
229
    [% END %]
230
</div>
231
</div>
232
[% UNLESS ( form ) %]
233
    <div class="yui-b noprint">
234
        [% INCLUDE 'tools-menu.inc' %]
235
    </div>
236
[% END %]
237
</div>
238
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+5 lines)
Lines 94-99 Link Here
94
    <dd>Write news for the OPAC and staff interfaces</dd>
94
    <dd>Write news for the OPAC and staff interfaces</dd>
95
    [% END %]
95
    [% END %]
96
96
97
    [% IF ( CAN_user_tools_edit_pages ) %]
98
    <dt><a href="/cgi-bin/koha/tools/cmspages.pl">Pages</a></dt>
99
    <dd>Create and edit additional content pages</dd>
100
    [% END %]
101
97
    [% IF ( CAN_user_tools_schedule_tasks ) %]
102
    [% IF ( CAN_user_tools_schedule_tasks ) %]
98
    <dt><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></dt>
103
    <dt><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></dt>
99
    <dd>Schedule tasks to run</dd>
104
    <dd>Schedule tasks to run</dd>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc (+14 lines)
Lines 286-291 Link Here
286
                                    [% END %]
286
                                    [% END %]
287
                                </ul>
287
                                </ul>
288
                            </div> <!-- /#moresearches -->
288
                            </div> <!-- /#moresearches -->
289
                            <div id="cms_nav_top">
290
								[% IF ( cms_nav_top ) %]
291
								<ul>
292
									[% WHILE ( cms_item = cms_nav_top.next ) %]
293
										[% IF ( cms_item.id == cms_page.id ) %]
294
											<li class="cms_nav_top_active">
295
										[% ELSE %]
296
                                            <li>
297
										[% END %]
298
                                        <a href="/cgi-bin/koha/opac-cmspages.pl?id=[% cms_item.id %]">[% cms_item.title_link %]</a></li>
299
									[% END %]
300
								</ul>
301
								[% END %]
302
                            </div>
289
                    </div> <!-- /.row-fluid -->
303
                    </div> <!-- /.row-fluid -->
290
304
291
                [% END # / OpacPublic %]
305
                [% END # / OpacPublic %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/navigation.inc (-1 / +9 lines)
Lines 1-4 Link Here
1
<div id="opacnav">[% OpacNav %]</div>
1
<div id="opacnav">
2
[% IF ( cms_nav_left ) %]
3
<ul id="cms_nav_left">
4
[% WHILE ( item = cms_nav_left.next ) %]
5
    <li><a href="/cgi-bin/koha/opac-cmspages.pl?id=[% item.id %]">[% item.title_link %]</a></li>
6
[% END %]
7
</ul>
8
[% END %]
9
[% OpacNav %]</div>
2
[% IF IsPatronPage %]
10
[% IF IsPatronPage %]
3
    <div id="usermenu">[% INCLUDE usermenu.inc %]</div>
11
    <div id="usermenu">[% INCLUDE usermenu.inc %]</div>
4
[% END %]
12
[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-cmspages.tt (+89 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE Branches %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %][% IF (cms_page.title) %] - [% cms_page.title %][% ELSE %] catalog[% END%]</title>
5
[% INCLUDE 'doc-head-close.inc' %]
6
[% BLOCK cssinclude %][% END %]
7
</head>
8
[% INCLUDE 'bodytag.inc' bodyid='opac-cmspages' %]
9
[% INCLUDE 'masthead.inc' %]
10
11
<div class="main">
12
    <ul class="breadcrumb">
13
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a></li>
14
        <li><span class="divider">&rsaquo;</span></li>
15
        <li><a href="#">[% cms_page.title_link %]</a></li>
16
    </ul>
17
18
    [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
19
        [% IF ( loggedinusername ) %]
20
            <div id="loggedin" class="container-fluid">
21
        [% ELSE %]
22
            <div id="notloggedin" class="container-fluid">
23
        [% END %]
24
    [% ELSE %]
25
        <div id="notloggedin" class="container-fluid">
26
    [% END %]
27
28
    <div class="row-fluid">
29
    [% IF ( OpacNav ||  OpacNavBottom ) %]
30
        <div class="span2">
31
            <div id="navigation">
32
                [% INCLUDE 'navigation.inc' %]
33
            </div>
34
        </div>
35
    [% END %]
36
37
    [% IF ( OpacNav || OpacNavBottom ) %]
38
        <div class="span7">
39
    [% ELSE %]
40
        <div class="span9">
41
    [% END %]
42
        [% cms_page.content %]
43
        [% IF ( OpacMainUserBlock ) %]<div id="opacmainuserblock">[% OpacMainUserBlock %]</div>[% END %]
44
        </div> <!-- / .span 7/9 -->
45
46
        [% IF ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) || OpacNavRight ) %]
47
            <div class="span3">
48
                [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
49
                    [% UNLESS ( loggedinusername ) %]
50
                        [% UNLESS ( casAuthentication || shibbolethAuthentication ) %]
51
                            <div id="login">
52
                                <form action="/cgi-bin/koha/opac-user.pl" method="post" name="auth" id="auth">
53
                                    <input type="hidden" name="koha_login_context" value="opac" />
54
                                    <fieldset class="brief">
55
                                        <legend>Log in to your account:</legend>
56
                                        <label for="userid">Login:</label><input type="text" id="userid" name="userid" />
57
                                        <label for="password">Password:</label><input type="password" id="password" name="password" />
58
                                    <fieldset class="action">
59
                                        <input type="submit" value="Log in" class="btn" />
60
                                    </fieldset>
61
                                    [% 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 %]
62
                                    </fieldset>
63
                                [% IF Koha.Preference( 'NoLoginInstructions' ) %]
64
                                    <div id="nologininstructions-main">
65
                                        [% Koha.Preference( 'NoLoginInstructions' ) %]
66
                                    </div>
67
                                [% END %]
68
                                </form>
69
                            </div> <!-- /#login -->
70
                        [% END # /casAuthentication %]
71
                        [% IF persona %]
72
                            <a href="#" class="persona-button" id="browserid" ><span>Sign in with your email</span></a>
73
                        [% END # /persona %]
74
                    [% END # / loggedinusername %]
75
                [% END # /opacuserlogin %]
76
                [% IF ( OpacNavRight ) %]
77
                    <div id="opacnavright">
78
                        [% OpacNavRight %]
79
                    </div>
80
                [% END # /OpacNavRight %]
81
            </div> <!-- / .span3 -->
82
        [% END # /opacuserlogin || OpacNavRight %]
83
84
        </div> <!-- /.container-fluid -->
85
    </div> <!-- /.row-fluid -->
86
</div> <!-- /.main -->
87
88
[% INCLUDE 'opac-bottom.inc' %]
89
[% BLOCK jsinclude %][% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less (-2 / +38 lines)
Lines 203-209 td { Link Here
203
}
203
}
204
204
205
#moresearches {
205
#moresearches {
206
    margin: .5em 0;
206
    margin: .5em 0 .5em 0;
207
    padding: 0 .8em;
207
    padding: 0 .8em;
208
    li {
208
    li {
209
        display: inline;
209
        display: inline;
Lines 215-227 td { Link Here
215
    }
215
    }
216
    ul {
216
    ul {
217
        margin : 0;
217
        margin : 0;
218
        display: inline;
218
    }
219
    }
220
    display: inline;
219
}
221
}
220
222
221
#moresearches li:last-child:after {
223
#moresearches li:last-child:after {
222
    content : "";
224
    content : "";
223
}
225
}
224
226
227
#cms_nav_top {
228
	li {
229
		margin-bottom: -1em;
230
		display: inline;
231
		white-space: nowrap;
232
		border-top-left-radius: 5px;
233
		border-top-right-radius: 5px;
234
		background-color: #eee;
235
		border: 1px solid #D2D2CF;
236
		border-bottom: none;
237
		padding: 0.1em 0.8em 0em 0.8em;
238
		font-weight: bold;
239
		font-size: 1.2em;
240
		border-bottom: 1px solid #D2D2CF;
241
		a {
242
			text-decoration: none;
243
		}
244
		&.cms_nav_top_active {
245
			background-color: #fff;
246
			border-bottom: 1px solid #FFF;
247
		}
248
	}
249
	ul {
250
		margin: 0;
251
		display: inline;
252
	}
253
	display: inline;
254
}
255
256
ul#cms_nav_left {
257
	list-style-type: none;
258
	padding: 0;
259
}
260
225
#news {
261
#news {
226
    margin : .5em 0;
262
    margin : .5em 0;
227
}
263
}
Lines 382-388 td { Link Here
382
    border: 1px solid #D2D2CF;
418
    border: 1px solid #D2D2CF;
383
    .border-radius-all(7px);
419
    .border-radius-all(7px);
384
    .shadowed;
420
    .shadowed;
385
    margin-top : 0.5em;
421
    margin-top : 1px;
386
    margin-bottom: 0.5em;
422
    margin-bottom: 0.5em;
387
}
423
}
388
424
(-)a/opac/opac-cmspages.pl (+52 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright Halland County Library 2015
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI;
22
use C4::Auth;
23
use C4::Output;
24
use C4::Languages qw( getTranslatedLanguages accept_language );
25
use Koha::CmsPages;
26
27
my $input  = new CGI;
28
my $id     = scalar $input->param( 'id' )     // '';
29
my $lang   = scalar $input->param( 'lang' )   // '';
30
my $branch = scalar $input->param( 'branch' ) // '';
31
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
33
    {
34
        template_name   => "opac-cmspages.tt",
35
        type            => "opac",
36
        query           => $input,
37
        authnotrequired => ( C4::Context->preference( "OpacPublic" ) ? 1 : 0 ),
38
        flagsrequired   => { borrow => 1 },
39
    }
40
);
41
42
my ( $theme, $news_lang, $availablethemes ) = C4::Templates::themelanguage(
43
    C4::Context->config( 'opachtdocs'), 'opac-cmspages.tt', 'opac', $input );
44
45
my ($cms_nav_top, $cms_nav_left, $cms_data) = Koha::CmsPages->page( $id );
46
$template->param(
47
	cms_page     => $cms_data,
48
    cms_nav_top  => $cms_nav_top,
49
    cms_nav_left => $cms_nav_left,
50
);
51
52
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/opac/opac-main.pl (-1 / +5 lines)
Lines 29-34 use C4::Members; Link Here
29
use C4::Overdues;
29
use C4::Overdues;
30
use Koha::Checkouts;
30
use Koha::Checkouts;
31
use Koha::Holds;
31
use Koha::Holds;
32
use Koha::CmsPages qw( list );
32
33
33
my $input = new CGI;
34
my $input = new CGI;
34
my $dbh   = C4::Context->dbh;
35
my $dbh   = C4::Context->dbh;
Lines 97-103 $template->param( Link Here
97
    daily_quote         => $quote,
98
    daily_quote         => $quote,
98
);
99
);
99
100
100
# If GoogleIndicTransliteration system preference is On Set parameter to load Google's javascript in OPAC search screens
101
$template->param(
102
    cms_nav_top => Koha::CmsPages->child_links( undef ),
103
);
104
101
if (C4::Context->preference('GoogleIndicTransliteration')) {
105
if (C4::Context->preference('GoogleIndicTransliteration')) {
102
        $template->param('GoogleIndicTransliteration' => 1);
106
        $template->param('GoogleIndicTransliteration' => 1);
103
}
107
}
(-)a/t/Pages.t (+31 lines)
Line 0 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/t/db_dependent/Pages.t (+93 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
# Copyright Halland County Library 2015.
5
#
6
# Koha is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# Koha is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
19
use Modern::Perl;
20
21
use Test::More tests => 2;
22
use Test::Warn;
23
use Data::Dumper::Concise;
24
25
use C4::Context;
26
use Koha::Database;
27
use t::lib::TestBuilder;
28
29
BEGIN {
30
    use_ok('Koha::Objects');
31
    use_ok('Koha::CmsPages');
32
}
33
34
my $builder = t::lib::TestBuilder->new();
35
36
# Start transaction
37
my $dbh = C4::Context->dbh;
38
$dbh->{ AutoCommit } = 0;
39
$dbh->{ RaiseError } = 1;
40
$dbh->do( 'DELETE FROM items' );
41
$dbh->do( 'DELETE FROM borrowers' );
42
$dbh->do( 'DELETE FROM branches' );
43
$dbh->do( 'DELETE FROM cms_pages' );
44
45
my $branchcode = $builder->build({ source => 'Branch' });
46
47
my $page10 = $builder->build({
48
	source => 'CmsPage',
49
	value  => {
50
		parent     => undef,
51
		title_link => 'page 10',
52
		title      => 'full page 10',
53
		published  => 1,
54
		sortorder  => 1,
55
	}
56
});
57
my $page11 = $builder->build({
58
	source => 'CmsPage',
59
	value  => {
60
		parent     => $page10->{'id'},
61
		title_link => 'subpage 11',
62
		title      => 'full subpage 11',
63
		published  => 1,
64
		sortorder  => 0,
65
	}
66
});
67
my $page12 = $builder->build({
68
	source => 'CmsPage',
69
	value  => {
70
		parent     => $page10->{'id'},
71
		title_link => 'subpage 12',
72
		title      => 'full subpage 12',
73
		published  => 1,
74
		sortorder  => 1,
75
	}
76
});
77
my $page20 = $builder->build({
78
	source => 'CmsPage',
79
	value  => {
80
		parent     => undef,
81
		title_link => 'page 20',
82
		title      => 'full page 20',
83
		published  => 0,
84
		sortorder  => 2,
85
	}
86
});
87
88
my $result = Koha::CmsPages->child_links( undef );
89
is_deeply( $result, [ $page10, $page20 ]);
90
91
$dbh->rollback();
92
93
1;
(-)a/tools/cmspages.pl (-1 / +90 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Script to manage CMS pages.
6
# Copyright (C) 2015 Halland County Library
7
#
8
# Koha is free software; you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# Koha is distributed in the hope that it will be useful, but
14
# WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with Koha; if not, see <http://www.gnu.org/licenses>.
20
21
use Modern::Perl;
22
use CGI qw( -utf8 );
23
use C4::Auth;
24
use C4::Output;
25
use C4::Languages qw( getTranslatedLanguages );
26
use Koha::Database;
27
use Koha::CmsPages;
28
29
my $link_self = '/cgi-bin/koha/tools/cmspages.pl';
30
31
my $cgi    = new CGI;
32
my $op     = scalar $cgi->param( 'op' )     // '';
33
my $id     = scalar $cgi->param( 'id' )     // '';
34
my $lang   = scalar $cgi->param( 'lang' )   // '';
35
my $branch = scalar $cgi->param( 'branch' ) // '';
36
my $disp   = scalar $cgi->param( 'disp' )   // '';
37
38
my ( $template, $borrowernumber, $cookie ) = get_template_and_user({
39
    template_name   => 'tools/cmspages.tt',
40
    query           => $cgi,
41
    type            => 'intranet',
42
    authnotrequired => 0,
43
    flagsrequired   => { tools => 'edit_pages' },
44
});
45
46
# Filter selection
47
$template->param(
48
    lang   => $lang,
49
    branch => $branch,
50
    disp   => $disp
51
);
52
53
my $schema = Koha::Database->new->schema;
54
my @branches = $schema->resultset( 'Branch' )->all;
55
$template->param( branch_list => @branches );
56
57
my $lang_list = getTranslatedLanguages;
58
59
# List all pages, if id is set generate parent page list and data.
60
my ( $page_list, $parent_list, $page_data ) = Koha::CmsPages->list( $id );
61
62
$template->param(
63
    page_list_count => scalar $page_list,
64
    page_list       => $page_list,
65
    parent_list     => $parent_list,
66
    data            => $page_data,
67
    lang_list       => $lang_list
68
);
69
70
# Used for adding or editing a page.
71
if ( $op eq 'form' ) {
72
    $template->param(
73
        form => 1,
74
        id   => $id,
75
        op   => 'add'
76
    );
77
}
78
79
if ( $op eq 'add' ) {
80
    Koha::CmsPages->add( $cgi );
81
    print $cgi->redirect( $link_self );
82
83
} elsif ( $op eq 'del' ) {
84
    # param => multi_param; no list-ctx warnings
85
    Koha::CmsPages->remove( $cgi->multi_param( 'ids' ) );
86
    print $cgi->redirect( $link_self );
87
}
88
89
$template->param( link_self => $link_self );
90
output_html_with_http_headers $cgi, $cookie, $template->output;

Return to bug 15326