Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 403]

HTML import lib

Copyright: 2011 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 346 lines (14 kb)
Included or required: 1 time
Referenced: 1 time
Includes or requires: 1 file
 mod/book/tool/importhtml/lib.php

Defines 8 functions


Functions that are not part of a class:

toolbook_importhtml_import_chapters($package, $type, $book, $context, $verbose = true)   X-Ref
Import HTML pages packaged into one zip archive

param: stored_file $package
param: string $type type of the package ('typezipdirs' or 'typezipfiles')
param: stdClass $book
param: context_module $context
param: bool $verbose

toolbook_importhtml_parse_headings($html)   X-Ref
Parse the headings of the imported package of type 'typeonefile'
(currently unsupported)

param: string $html html content to parse

toolbook_importhtml_parse_styles($html)   X-Ref
Parse the links to external css sheets of the imported html content

param: string $html html content to parse
return: string all the links to external css sheets

toolbook_importhtml_fix_path($path)   X-Ref
Normalize paths to be absolute

param: string $path original path with MS/relative separators
return: string the normalized and cleaned absolute path

toolbook_importhtml_fix_encoding($html)   X-Ref
Convert some html content to utf8, getting original encoding from html headers

param: string $html html content to convert
return: string html content converted to utf8

toolbook_importhtml_parse_body($html)   X-Ref
Extract the body from any html contents

param: string $html the html to parse
return: string the contents of the body

toolbook_importhtml_parse_title($html, $default)   X-Ref
Extract the title of any html content, getting it from the title tag

param: string $html the html to parse
param: string $default default title to apply if no title is found
return: string the resulting title

toolbook_importhtml_get_chapter_files($package, $type)   X-Ref
Returns all the html files (chapters) from a file package

param: stored_file $package file to be processed
param: string $type type of the package ('typezipdirs' or 'typezipfiles')
return: array the html files found in the package