Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
758f7dde
Commit
758f7dde
authored
Jan 15, 2011
by
Petr Skoda
Browse files
move print and other functions to the settings block
parent
9221a711
Changes
3
Hide whitespace changes
Inline
Side-by-side
README
View file @
758f7dde
...
...
@@ -109,4 +109,10 @@ CHANGELOG:
== 2.0dev ============================================================
* Moodle 2.0 conversion - no new features
TODO:
* upgrade imscp export code (disabled for now)
* upgrade import code (disabled for now)
* open print links in new windows (needs fix in navlib)
Petr
lib.php
View file @
758f7dde
...
...
@@ -236,9 +236,6 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
$PAGE
->
cm
->
context
=
get_context_instance
(
CONTEXT_MODULE
,
$PAGE
->
cm
->
instance
);
}
if
(
!
has_capability
(
'mod/book:edit'
,
$PAGE
->
cm
->
context
))
{
return
;
}
$params
=
$PAGE
->
url
->
params
();
...
...
@@ -246,16 +243,43 @@ function book_extend_settings_navigation(settings_navigation $settingsnav, navig
return
;
}
if
(
!
empty
(
$USER
->
editing
))
{
$string
=
get_string
(
"turneditingoff"
);
$edit
=
'0'
;
}
else
{
$string
=
get_string
(
"turneditingon"
);
$edit
=
'1'
;
if
(
has_capability
(
'mod/book:print'
,
$PAGE
->
cm
->
context
))
{
$book
=
$DB
->
get_record
(
'book'
,
array
(
'id'
=>
$PAGE
->
cm
->
instance
));
if
(
!
$book
->
disableprinting
)
{
$url
=
new
moodle_url
(
'/mod/book/print.php'
,
array
(
'id'
=>
$params
[
'id'
]));
$booknode
->
add
(
get_string
(
'printbook'
,
'book'
),
$url
,
navigation_node
::
TYPE_SETTING
,
null
,
null
,
new
pix_icon
(
'print_book'
,
''
,
'mod_book'
,
array
(
'class'
=>
'icon'
)));
// buggy navlib - actions not supported!!
//$action = new action_link($url, get_string('printbook', 'book'), new popup_action('onclick', $url));
//$booknode->add('', $action, navigation_node::TYPE_SETTING);
$url
=
new
moodle_url
(
'/mod/book/print.php'
,
array
(
'id'
=>
$params
[
'id'
],
'chapterid'
=>
$params
[
'chapterid'
]));
$booknode
->
add
(
get_string
(
'printchapter'
,
'book'
),
$url
,
navigation_node
::
TYPE_SETTING
,
null
,
null
,
new
pix_icon
(
'print_chapter'
,
''
,
'mod_book'
,
array
(
'class'
=>
'icon'
)));
}
}
$url
=
new
moodle_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$params
[
'id'
],
'chapterid'
=>
$params
[
'chapterid'
],
'edit'
=>
$edit
,
'sesskey'
=>
sesskey
()));
$booknode
->
add
(
$string
,
$url
,
navigation_node
::
TYPE_SETTING
);
if
(
has_capability
(
'mod/book:import'
,
$PAGE
->
cm
->
context
))
{
//TODO
//$doimport = ($allowimport and $edit) ? '<div>(<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</div>' : '';
}
if
(
has_capability
(
'mod/book:exportimscp'
,
$PAGE
->
cm
->
context
))
{
//TODO
/// Enable the IMS CP button
//$generateimscp = ($allowexport) ? '<a title="'.get_string('generateimscp', 'book').'" href="generateimscp.php?id='.$cm->id.'"><img class="bigicon" src="'.$OUTPUT->pix_url('generateimscp', 'mod_book').'" alt="'.get_string('generateimscp', 'book').'"></img></a>' : '';
}
if
(
has_capability
(
'mod/book:edit'
,
$PAGE
->
cm
->
context
))
{
if
(
!
empty
(
$USER
->
editing
))
{
$string
=
get_string
(
"turneditingoff"
);
$edit
=
'0'
;
}
else
{
$string
=
get_string
(
"turneditingon"
);
$edit
=
'1'
;
}
$url
=
new
moodle_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$params
[
'id'
],
'chapterid'
=>
$params
[
'chapterid'
],
'edit'
=>
$edit
,
'sesskey'
=>
sesskey
()));
$booknode
->
add
(
$string
,
$url
,
navigation_node
::
TYPE_SETTING
);
}
}
/**
...
...
view.php
View file @
758f7dde
...
...
@@ -51,9 +51,6 @@ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability
(
'mod/book:read'
,
$context
);
$allowedit
=
has_capability
(
'mod/book:edit'
,
$context
);
$allowimport
=
has_capability
(
'mod/book:import'
,
$context
);
$allowprint
=
(
has_capability
(
'mod/book:print'
,
$context
)
and
!
$book
->
disableprinting
);
$allowexport
=
has_capability
(
'mod/book:exportimscp'
,
$context
);
$viewhidden
=
has_capability
(
'mod/book:viewhiddenchapters'
,
$context
);
if
(
$allowedit
)
{
...
...
@@ -96,11 +93,10 @@ if ($chapterid == '0') { // go to first chapter if no given
}
}
$chapter
=
$DB
->
get_record
(
'book_chapters'
,
array
(
'id'
=>
$chapterid
,
'bookid'
=>
$book
->
id
),
'*'
,
MUST_EXIST
);
$PAGE
->
set_url
(
'/mod/book/view.php'
,
array
(
'id'
=>
$id
,
'chapterid'
=>
$chapterid
));
if
(
!
$chapter
=
$DB
->
get_record
(
'book_chapters'
,
array
(
'id'
=>
$chapterid
,
'bookid'
=>
$book
->
id
)))
{
error
(
'Error reading book chapters.'
);
}
//check all variables
unset
(
$id
);
...
...
@@ -165,15 +161,6 @@ if ($nextid) {
$chnavigation
.
=
'<a title="'
.
get_string
(
'navexit'
,
'book'
)
.
'" href="../../course/view.php?id='
.
$course
->
id
.
'#section-'
.
$sec
.
'"><img src="'
.
$OUTPUT
->
pix_url
(
'nav_exit'
,
'mod_book'
)
.
'" class="bigicon" alt="'
.
get_string
(
'navexit'
,
'book'
)
.
'" /></a>'
;
}
/// prepare print icons
if
(
!
$allowprint
)
{
$printbook
=
''
;
$printchapter
=
''
;
}
else
{
$printbook
=
'<a title="'
.
get_string
(
'printbook'
,
'book'
)
.
'" href="print.php?id='
.
$cm
->
id
.
'" onclick="this.target=\'_blank\'"><img src="'
.
$OUTPUT
->
pix_url
(
'print_book'
,
'mod_book'
)
.
'" class="bigicon" alt="'
.
get_string
(
'printbook'
,
'book'
)
.
'"/></a>'
;
$printchapter
=
'<a title="'
.
get_string
(
'printchapter'
,
'book'
)
.
'" href="print.php?id='
.
$cm
->
id
.
'&chapterid='
.
$chapter
->
id
.
'" onclick="this.target=\'_blank\'"><img src="'
.
$OUTPUT
->
pix_url
(
'print_chapter'
,
'mod_book'
)
.
'" class="bigicon" alt="'
.
get_string
(
'printchapter'
,
'book'
)
.
'"/></a>'
;
}
// prepare $toc and $currtitle, $currsubtitle
list
(
$toc
,
$currtitle
,
$currsubtitle
,
$titles
)
=
book_get_toc
(
$chapters
,
$chapter
,
$book
,
$cm
,
$edit
,
0
);
...
...
@@ -183,14 +170,6 @@ if ($edit) {
$tocwidth
=
$CFG
->
book_tocwidth
;
}
//$doimport = ($allowimport and $edit) ? '<div>(<a href="import.php?id='.$cm->id.'">'.get_string('doimport', 'book').'</a>)</div>' : '';
$doimport
=
''
;
//TODO: after new file handling
/// Enable the IMS CP button
//$generateimscp = ($allowexport) ? '<a title="'.get_string('generateimscp', 'book').'" href="generateimscp.php?id='.$cm->id.'"><img class="bigicon" src="'.$OUTPUT->pix_url('generateimscp', 'mod_book').'" alt="'.get_string('generateimscp', 'book').'"></img></a>' : '';
$generateimscp
=
''
;
//TODO after new file handling
// =====================================================
// Book display HTML code
// =====================================================
...
...
@@ -203,11 +182,9 @@ $generateimscp = ''; //TODO after new file handling
<td
style=
"width:
<?php
echo
$tocwidth
?>
px"
valign=
"bottom"
>
<?php
print_string
(
'toc'
,
'book'
);
echo
$doimport
;
?>
</td>
<td>
<div
class=
"bookexport"
>
<?php
echo
$printbook
.
$printchapter
.
$generateimscp
?>
</div>
<div
class=
"booknav"
>
<?php
echo
$chnavigation
?>
</div>
</td>
</tr>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment