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
1fc9e895
Commit
1fc9e895
authored
May 01, 2012
by
Eloy Lafuente
Browse files
MDL-32709 book: replace some deprecated stuff. Some pending yet, blame $PAGE
parent
98cef39d
Changes
16
Hide whitespace changes
Inline
Side-by-side
mod/book/db/upgrade.php
View file @
1fc9e895
...
...
@@ -141,7 +141,7 @@ function xmldb_book_upgrade($oldversion) {
upgrade_set_timeout
(
360
);
// set up timeout, may also abort execution
$pbar
->
update
(
$i
,
$count
,
"Migrating book files -
$i
/
$count
."
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$book
->
cmid
);
$context
=
context_
module
::
instance
(
$book
->
cmid
);
mod_book_migrate_moddata_dir_to_legacy
(
$book
,
$context
,
'/'
);
...
...
mod/book/db/upgradelib.php
View file @
1fc9e895
...
...
@@ -46,7 +46,6 @@ function mod_book_migrate_moddata_dir_to_legacy($book, $context, $path) {
}
$fs
=
get_file_storage
();
$textlib
=
textlib_get_instance
();
$items
=
new
DirectoryIterator
(
$fulldir
);
foreach
(
$items
as
$item
)
{
...
...
@@ -77,7 +76,7 @@ function mod_book_migrate_moddata_dir_to_legacy($book, $context, $path) {
continue
;
}
if
(
$
textlib
->
strlen
(
$filepath
)
>
255
)
{
if
(
textlib
::
strlen
(
$filepath
)
>
255
)
{
echo
$OUTPUT
->
notification
(
" File path longer than 255 chars, skipping: "
.
$fulldir
.
$item
->
getFilename
());
unset
(
$item
);
// release file handle
continue
;
...
...
@@ -115,7 +114,7 @@ function mod_book_migrate_all_areas() {
foreach
(
$rsbooks
as
$book
)
{
upgrade_set_timeout
(
360
);
// set up timeout, may also abort execution
$cm
=
get_coursemodule_from_instance
(
'book'
,
$book
->
id
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
mod_book_migrate_area
(
$book
,
'intro'
,
'book'
,
$book
->
course
,
$context
,
'mod_book'
,
'intro'
,
0
);
$rschapters
=
$DB
->
get_recordset
(
'book_chapters'
,
array
(
'bookid'
=>
$book
->
id
));
...
...
@@ -147,7 +146,7 @@ function mod_book_migrate_area($record, $field, $table, $courseid, $context, $co
foreach
(
array
(
get_site
()
->
id
,
$courseid
)
as
$cid
)
{
$matches
=
null
;
$ooldcontext
=
get_
context_instance
(
CONTEXT_COURSE
,
$cid
);
$ooldcontext
=
context_
course
::
instance
(
$cid
);
if
(
preg_match_all
(
"|
$CFG->wwwroot
/file.php(\?file=)?/
$cid
(/[^\s'
\"
&\?#]+)|"
,
$record
->
$field
,
$matches
))
{
$file_record
=
array
(
'contextid'
=>
$context
->
id
,
'component'
=>
$component
,
'filearea'
=>
$filearea
,
'itemid'
=>
$itemid
);
foreach
(
$matches
[
2
]
as
$i
=>
$filepath
)
{
...
...
mod/book/delete.php
View file @
1fc9e895
...
...
@@ -36,7 +36,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login
(
$course
,
false
,
$cm
);
require_sesskey
();
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:edit'
,
$context
);
$PAGE
->
set_url
(
'/mod/book/delete.php'
,
array
(
'id'
=>
$id
,
'chapterid'
=>
$chapterid
));
...
...
mod/book/edit.php
View file @
1fc9e895
...
...
@@ -37,7 +37,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login
(
$course
,
false
,
$cm
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:edit'
,
$context
);
$PAGE
->
set_url
(
'/mod/book/edit.php'
,
array
(
'cmid'
=>
$cmid
,
'id'
=>
$chapterid
,
'pagenum'
=>
$pagenum
,
'subchapter'
=>
$subchapter
));
...
...
mod/book/index.php
View file @
1fc9e895
...
...
@@ -75,7 +75,7 @@ if ($usesections) {
$modinfo
=
get_fast_modinfo
(
$course
);
$currentsection
=
''
;
foreach
(
$books
as
$book
)
{
$cm
=
$modinfo
->
cms
[
$book
->
coursemodule
]
;
$cm
=
$modinfo
->
get_cm
(
$book
->
coursemodule
)
;
if
(
$usesections
)
{
$printsection
=
''
;
if
(
$book
->
section
!==
$currentsection
)
{
...
...
mod/book/locallib.php
View file @
1fc9e895
...
...
@@ -221,7 +221,7 @@ function book_get_toc($chapters, $chapter, $book, $cm, $edit) {
$ns
=
0
;
// Subchapter number
$first
=
1
;
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
switch
(
$book
->
numbering
)
{
case
BOOK_NUM_NONE
:
...
...
mod/book/move.php
View file @
1fc9e895
...
...
@@ -37,7 +37,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login
(
$course
,
false
,
$cm
);
require_sesskey
();
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:edit'
,
$context
);
$chapter
=
$DB
->
get_record
(
'book_chapters'
,
array
(
'id'
=>
$chapterid
,
'bookid'
=>
$book
->
id
),
'*'
,
MUST_EXIST
);
...
...
mod/book/show.php
View file @
1fc9e895
...
...
@@ -35,7 +35,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login
(
$course
,
false
,
$cm
);
require_sesskey
();
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:edit'
,
$context
);
$PAGE
->
set_url
(
'/mod/book/show.php'
,
array
(
'id'
=>
$id
,
'chapterid'
=>
$chapterid
));
...
...
mod/book/tool/exportimscp/index.php
View file @
1fc9e895
...
...
@@ -40,7 +40,7 @@ $PAGE->set_url('/mod/book/tool/exportimscp/index.php', array('id'=>$id));
require_login
(
$course
,
false
,
$cm
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:read'
,
$context
);
require_capability
(
'booktool/exportimscp:export'
,
$context
);
...
...
mod/book/tool/exportimscp/locallib.php
View file @
1fc9e895
...
...
@@ -159,7 +159,7 @@ function booktool_exportimscp_prepare_files($book, $context) {
// Update prevlevel
$prevlevel
=
$currlevel
;
// Calculate the number of spaces (for visual xml-text formating)
// Calculate the number of spaces (for visual xml-text format
t
ing)
$currspaces
=
substr
(
' '
,
0
,
$currlevel
*
2
);
$chaptertitle
=
format_string
(
$chapter
->
title
,
true
,
array
(
'context'
=>
$context
));
...
...
mod/book/tool/importhtml/import_form.php
View file @
1fc9e895
...
...
@@ -64,7 +64,7 @@ class booktool_importhtml_form extends moodleform {
return
$errors
;
}
$usercontext
=
get_
context_instance
(
CONTEXT_USER
,
$USER
->
id
);
$usercontext
=
context_
user
::
instance
(
$USER
->
id
);
$fs
=
get_file_storage
();
if
(
!
$files
=
$fs
->
get_area_files
(
$usercontext
->
id
,
'user'
,
'draft'
,
$data
[
'importfile'
],
'id'
,
false
))
{
...
...
mod/book/tool/importhtml/index.php
View file @
1fc9e895
...
...
@@ -35,7 +35,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_login
(
$course
,
false
,
$cm
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'booktool/importhtml:import'
,
$context
);
$PAGE
->
set_url
(
'/mod/book/tool/importhtml/index.php'
,
array
(
'id'
=>
$id
,
'chapterid'
=>
$chapterid
));
...
...
@@ -73,7 +73,7 @@ if ($mform->is_cancelled()) {
// this is a bloody hack - children do not try this at home!
$fs
=
get_file_storage
();
$draftid
=
file_get_submitted_draft_itemid
(
'importfile'
);
if
(
!
$files
=
$fs
->
get_area_files
(
get_
context_instance
(
CONTEXT_USER
,
$USER
->
id
)
->
id
,
'user'
,
'draft'
,
$draftid
,
'id DESC'
,
false
))
{
if
(
!
$files
=
$fs
->
get_area_files
(
context_
user
::
instance
(
$USER
->
id
)
->
id
,
'user'
,
'draft'
,
$draftid
,
'id DESC'
,
false
))
{
redirect
(
$PAGE
->
url
);
}
$file
=
reset
(
$files
);
...
...
mod/book/tool/importhtml/locallib.php
View file @
1fc9e895
...
...
@@ -215,7 +215,7 @@ function toolbook_importhtml_fix_encoding($html) {
$head
=
$matches
[
1
];
if
(
preg_match
(
'/charset=([^"]+)/is'
,
$head
,
$matches
))
{
$enc
=
$matches
[
1
];
return
textlib
_get_instance
()
->
convert
(
$html
,
$enc
,
'utf-8'
);
return
textlib
::
convert
(
$html
,
$enc
,
'utf-8'
);
}
}
return
iconv
(
'UTF-8'
,
'UTF-8//IGNORE'
,
$html
);
...
...
@@ -299,9 +299,9 @@ function toolbook_importhtml_get_chapter_files($package, $type) {
}
}
// TODO: natural dir sorting would be nice here...
textlib
_get_instance
()
->
asort
(
$tophtmlfiles
);
textlib
_get_instance
()
->
asort
(
$subhtmlfiles
);
textlib
_get_instance
()
->
asort
(
$topdirs
);
textlib
::
asort
(
$tophtmlfiles
);
textlib
::
asort
(
$subhtmlfiles
);
textlib
::
asort
(
$topdirs
);
$chapterfiles
=
array
();
...
...
@@ -313,7 +313,7 @@ function toolbook_importhtml_get_chapter_files($package, $type) {
if
(
empty
(
$htmlfiles
))
{
continue
;
}
textlib
_get_instance
()
->
asort
(
$htmlfiles
);
textlib
::
asort
(
$htmlfiles
);
if
(
isset
(
$htmlfiles
[
$dir
.
'/index.html'
]))
{
$htmlfile
=
$htmlfiles
[
$dir
.
'/index.html'
];
}
else
if
(
isset
(
$htmlfiles
[
$dir
.
'/index.htm'
]))
{
...
...
mod/book/tool/print/index.php
View file @
1fc9e895
...
...
@@ -38,7 +38,7 @@ $book = $DB->get_record('book', array('id'=>$cm->instance), '*', MUST_EXIST);
require_course_login
(
$course
,
true
,
$cm
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:read'
,
$context
);
require_capability
(
'booktool/print:print'
,
$context
);
...
...
mod/book/tool/print/locallib.php
View file @
1fc9e895
...
...
@@ -39,7 +39,7 @@ function booktool_print_get_toc($chapters, $book, $cm) {
$first
=
true
;
$titles
=
array
();
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
$toc
=
''
;
// Representation of toc (HTML).
...
...
mod/book/view.php
View file @
1fc9e895
...
...
@@ -47,7 +47,7 @@ if ($id) {
require_course_login
(
$course
,
true
,
$cm
);
$context
=
get_
context_instance
(
CONTEXT_MODULE
,
$cm
->
id
);
$context
=
context_
module
::
instance
(
$cm
->
id
);
require_capability
(
'mod/book:read'
,
$context
);
$allowedit
=
has_capability
(
'mod/book:edit'
,
$context
);
...
...
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