1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* Print lib
|
|
|
19 |
*
|
|
|
20 |
* @package booktool_print
|
|
|
21 |
* @copyright 2004-2011 Petr Skoda {@link http://skodak.org}
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Adds module specific settings to the settings block
|
|
|
27 |
*
|
|
|
28 |
* @param settings_navigation $settings The settings navigation object
|
|
|
29 |
* @param navigation_node $node The node to add module settings to
|
|
|
30 |
*/
|
|
|
31 |
function booktool_print_extend_settings_navigation(settings_navigation $settings, navigation_node $node) {
|
1441 |
ariadna |
32 |
global $OUTPUT;
|
|
|
33 |
|
1 |
efrain |
34 |
$params = $settings->get_page()->url->params();
|
1441 |
ariadna |
35 |
if (empty($params['id']) || empty($params['chapterid'])) {
|
1 |
efrain |
36 |
return;
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
if (has_capability('booktool/print:print', $settings->get_page()->cm->context)) {
|
1441 |
ariadna |
40 |
$url1 = new moodle_url('/mod/book/tool/print/index.php', ['id' => $params['id']]);
|
|
|
41 |
$url2 = new moodle_url('/mod/book/tool/print/index.php', ['id' => $params['id'], 'chapterid' => $params['chapterid']]);
|
1 |
efrain |
42 |
$action = new action_link($url1, get_string('printbook', 'booktool_print'), new popup_action('click', $url1));
|
1441 |
ariadna |
43 |
$newwindowtext = html_writer::span(' (' . get_string('opensinnewwindow') . ')', 'visually-hidden');
|
|
|
44 |
$externalicon = $OUTPUT->pix_icon('i/externallink', '', attributes: [
|
|
|
45 |
'title' => get_string('opensinnewwindow'),
|
|
|
46 |
'class' => 'ms-1',
|
|
|
47 |
]);
|
|
|
48 |
|
|
|
49 |
$booknode = $node->add(
|
|
|
50 |
// Add both an icon and visualy hidden text to indicate link opens in a new window
|
|
|
51 |
// because Clean theme strips out the icon html.
|
|
|
52 |
get_string('printbook', 'booktool_print') . $externalicon . $newwindowtext,
|
|
|
53 |
$action,
|
|
|
54 |
navigation_node::TYPE_SETTING,
|
|
|
55 |
null,
|
|
|
56 |
'printbook',
|
|
|
57 |
new pix_icon('book', '', 'booktool_print', ['class' => 'icon'])
|
|
|
58 |
);
|
1 |
efrain |
59 |
$booknode->set_force_into_more_menu(true);
|
|
|
60 |
$action = new action_link($url2, get_string('printchapter', 'booktool_print'), new popup_action('click', $url2));
|
1441 |
ariadna |
61 |
$chapternode = $node->add(
|
|
|
62 |
// Add both an icon and visualy hidden text to indicate link opens in a new window
|
|
|
63 |
// because Clean theme strips out the icon html.
|
|
|
64 |
get_string('printchapter', 'booktool_print') . $externalicon . $newwindowtext,
|
|
|
65 |
$action,
|
|
|
66 |
navigation_node::TYPE_SETTING,
|
|
|
67 |
null,
|
|
|
68 |
'printchapter',
|
|
|
69 |
new pix_icon('chapter', '', 'booktool_print', ['class' => 'icon'])
|
|
|
70 |
);
|
1 |
efrain |
71 |
$chapternode->set_force_into_more_menu(true);
|
|
|
72 |
}
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Return read actions.
|
|
|
77 |
*
|
|
|
78 |
* Note: This is not used by new logging system. Event with
|
|
|
79 |
* crud = 'r' and edulevel = LEVEL_PARTICIPATING will
|
|
|
80 |
* be considered as view action.
|
|
|
81 |
*
|
|
|
82 |
* @return array
|
|
|
83 |
*/
|
|
|
84 |
function booktool_print_get_view_actions() {
|
1441 |
ariadna |
85 |
return ['print'];
|
1 |
efrain |
86 |
}
|