Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
moodle1_mod_book_handler Class Reference

Book conversion handler. More...

Inheritance diagram for moodle1_mod_book_handler:
moodle1_mod_handler moodle1_plugin_handler moodle1_xml_handler moodle1_handler loggable

Public Member Functions

 get_component_name ()
 Returns the normalized name of the plugin, eg mod_workshop. More...
 
 get_converter ()
 
 get_modname ()
 Returns the name of the module, eg. More...
 
 get_paths ()
 Declare the paths in moodle.xml we are able to convert. More...
 
 log ($message, $level, $a=null, $depth=null, $display=false)
 This function will be responsible for handling the params, and to call to the corresponding logger->process() once all modifications in params have been performed.
 
 on_book_chapters_end ()
 This is executed when the parser reaches the closing </CHAPTERS> element.
 
 on_book_chapters_start ()
 This is executed when the parser reaches the <CHAPTERS> opening element.
 
 on_book_end ()
 This is executed when we reach the closing </MOD> tag of our 'book' path.
 
 process_book ($data)
 This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/BOOK data available. More...
 
 process_book_chapters ($data)
 This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/BOOK/CHAPTERS/CHAPTER data available. More...
 

Protected Member Functions

 close_xml_writer ()
 Close the XML writer. More...
 
 get_cminfo ($instance, $modname=null)
 Returns course module information for the given instance id. More...
 
 has_xml_writer ()
 Checks if the XML writer has been opened by self::open_xml_writer(). More...
 
 make_sure_xml_exists ($filename, $rootelement=false, $content=array())
 Makes sure that a new XML file exists, or creates it itself. More...
 
 open_xml_writer ($filename)
 Opens the XML writer - after calling, one is free to use $xmlwriter. More...
 
 write_xml ($element, array $data, array $attribs=array(), $parent='/')
 Writes the given XML tree data into the currently opened file. More...
 

Protected Attributes

moodle1_converter $converter
 
moodle1_file_manager $fileman = null
 
int $moduleid = null
 cmid
 
string $pluginname
 
string $plugintype
 
null string $xmlfilename
 the name of file we are writing to
 
null xml_writer $xmlwriter
 

Detailed Description

Book conversion handler.

Member Function Documentation

◆ close_xml_writer()

moodle1_xml_handler::close_xml_writer ( )
protectedinherited

Close the XML writer.

At the moment, the caller must close all tags before calling

Return values
void

Reimplemented in moodle1_qtype_handler.

◆ get_cminfo()

moodle1_mod_handler::get_cminfo (   $instance,
  $modname = null 
)
protectedinherited

Returns course module information for the given instance id.

The information for this instance id has been stashed by moodle1_course_outline_handler::process_course_module()

Parameters
int$instancethe module instance id
string$modnamethe module type, defaults to $this->pluginname
Return values
int

◆ get_component_name()

moodle1_plugin_handler::get_component_name ( )
inherited

Returns the normalized name of the plugin, eg mod_workshop.

Return values
string

◆ get_converter()

moodle1_handler::get_converter ( )
inherited
Return values
moodle1_converterthe converter that required this handler

◆ get_modname()

moodle1_mod_handler::get_modname ( )
inherited

Returns the name of the module, eg.

'forum'

Return values
string

◆ get_paths()

moodle1_mod_book_handler::get_paths ( )

Declare the paths in moodle.xml we are able to convert.

The method returns list of convert_path instances. For each path returned, at least one of on_xxx_start(), process_xxx() and on_xxx_end() methods must be defined. The method process_xxx() is not executed if the associated path element is empty (i.e. it contains none elements or sub-paths only).

Note that the path /MOODLE_BACKUP/COURSE/MODULES/MOD/BOOK does not actually exist in the file. The last element with the module name was appended by the moodle1_converter class.

Return values
arrayof convert_path instances

◆ has_xml_writer()

moodle1_xml_handler::has_xml_writer ( )
protectedinherited

Checks if the XML writer has been opened by self::open_xml_writer().

Return values
bool

◆ make_sure_xml_exists()

moodle1_xml_handler::make_sure_xml_exists (   $filename,
  $rootelement = false,
  $content = array() 
)
protectedinherited

Makes sure that a new XML file exists, or creates it itself.

This is here so we can check that all XML files that the restore process relies on have been created by an executed handler. If the file is not found, this method can create it using the given $rootelement as an empty root container in the file.

Parameters
string$filenamerelative file name like 'course/course.xml'
string | bool$rootelementroot element to use, false to not create the file
array$contentcontent of the root element
Return values
booltrue is the file existed, false if it did not

◆ open_xml_writer()

moodle1_xml_handler::open_xml_writer (   $filename)
protectedinherited

Opens the XML writer - after calling, one is free to use $xmlwriter.

Parameters
string$filenameXML file name to write into
Return values
void

Reimplemented in moodle1_qtype_handler.

◆ process_book()

moodle1_mod_book_handler::process_book (   $data)

This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/BOOK data available.

Parameters
array$data

◆ process_book_chapters()

moodle1_mod_book_handler::process_book_chapters (   $data)

This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/BOOK/CHAPTERS/CHAPTER data available.

Parameters
array$data

◆ write_xml()

moodle1_xml_handler::write_xml (   $element,
array  $data,
array  $attribs = array(),
  $parent = '/' 
)
protectedinherited

Writes the given XML tree data into the currently opened file.

Parameters
string$elementthe name of the root element of the tree
array$datathe associative array of data to write
array$attribslist of additional fields written as attributes instead of nested elements
string$parentused internally during the recursion, do not set yourself

The documentation for this class was generated from the following file: