Moodle  2.2.1
http://www.collinsharper.com
moodle1_converter Class Reference
Inheritance diagram for moodle1_converter:
Collaboration diagram for moodle1_converter:

Public Member Functions

 log ($message, $level, $a=null, $depth=null, $display=false)
 process_chunk ($data)
 path_start_reached ($path)
 path_end_reached ($path)
 create_stash_storage ()
 drop_stash_storage ()
 set_stash ($stashname, $info, $itemid=0)
 get_stash ($stashname, $itemid=0)
 get_stash_or_default ($stashname, $itemid=0, $default=null)
 get_stash_names ()
 get_stash_itemids ($stashname)
 get_contextid ($level, $instance=0)
 get_nextid ()
 get_file_manager ($contextid=null, $component=null, $filearea=null, $itemid=0, $userid=null)
 get_inforef_manager ($name, $id=0)

Static Public Member Functions

static detect_format ($tempdir)
static migrate_referenced_files ($text, moodle1_file_manager $fileman)
static find_referenced_files ($text)
static rewrite_filephp_usage ($text, array $files)
static description ()

Data Fields

const SKIP_ALL_CHILDREN = -991399

Protected Member Functions

 init ()
 execute ()
 register_handler (moodle1_handler $handler, array $elements)
 grouped_parent_exists ($pelement, $elements)

Protected Attributes

 $xmlparser
 $xmlprocessor
 $pathelements = array()
 $currentmod = null
 $currentblock = null
 $pathlock

Detailed Description

Converter of Moodle 1.9 backup into Moodle 2.x format

Definition at line 41 of file lib.php.


Member Function Documentation

Creates the temporary storage for stashed data

This implementation uses backup_ids_temp table.

Definition at line 422 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static description ( ) [static]
See also:
parent::description()

Reimplemented from base_converter.

Definition at line 671 of file lib.php.

static detect_format ( tempdir) [static]

Detects the Moodle 1.9 format of the backup directory

Parameters:
string$tempdirthe name of the backup directory
Returns:
null|string backup::FORMAT_MOODLE1 if the Moodle 1.9 is detected, null otherwise

Reimplemented from base_converter.

Definition at line 89 of file lib.php.

Here is the caller graph for this function:

Drops the temporary storage of stashed data

This implementation uses backup_ids_temp table.

Definition at line 431 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

execute ( ) [protected]

Converts the contents of the tempdir into the target format in the workdir

Reimplemented from base_converter.

Definition at line 145 of file lib.php.

Here is the call graph for this function:

static find_referenced_files ( text) [static]

Detects all links to file.php encoded via $$ and returns the files to migrate

See also:
self::migrate_referenced_files()
Parameters:
string$text
Returns:
array

Definition at line 625 of file lib.php.

Here is the caller graph for this function:

get_contextid ( level,
instance = 0 
)

Generates an artificial context id

Moodle 1.9 backups do not contain any context information. But we need them in Moodle 2.x format so here we generate fictive context id for every given context level + instance combo.

CONTEXT_SYSTEM and CONTEXT_COURSE ignore the $instance as they represent a single system or the course being restored.

See also:
get_context_instance()
Parameters:
int$levelthe context level, like CONTEXT_COURSE or CONTEXT_MODULE
int$instancethe instance id, for example $course->id for courses or $cm->id for activity modules
Returns:
int the context id

Definition at line 536 of file lib.php.

Here is the call graph for this function:

get_file_manager ( contextid = null,
component = null,
filearea = null,
itemid = 0,
userid = null 
)

Creates and returns new instance of the file manager

Parameters:
int$contextidthe default context id of the files being migrated
string$componentthe default component name of the files being migrated
string$fileareathe default file area of the files being migrated
int$itemidthe default item id of the files being migrated
int$useridinitial user id of the files being migrated
Returns:
moodle1_file_manager

Definition at line 575 of file lib.php.

get_inforef_manager ( name,
id = 0 
)

Creates and returns new instance of the inforef manager

Parameters:
string$namethe name of the annotator (like course, section, activity, block)
int$idthe id of the annotator if required
Returns:
moodle1_inforef_manager

Definition at line 586 of file lib.php.

Simple autoincrement generator

Returns:
int the next number in a row of numbers

Definition at line 561 of file lib.php.

Here is the caller graph for this function:

get_stash ( stashname,
itemid = 0 
)

Restores a given stash stored previously by self::set_stash()

Parameters:
string$stashnamename of the stash
int$itemidoptional id for multiple infos within the same stashname
Exceptions:
moodle1_convert_empty_storage_exceptionif the info has not been stashed previously
Returns:
mixed stashed data

Definition at line 462 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

get_stash_itemids ( stashname)

Returns the list of stashed $itemids in the given stash

Parameters:
string$stashname
Returns:
array

Definition at line 510 of file lib.php.

Here is the call graph for this function:

Returns the list of existing stashes

Returns:
array

Definition at line 494 of file lib.php.

Here is the call graph for this function:

get_stash_or_default ( stashname,
itemid = 0,
default = null 
)

Restores a given stash or returns the given default if there is no such stash

Parameters:
string$stashnamename of the stash
int$itemidoptional id for multiple infos within the same stashname
mixed$defaultinformation to return if the info has not been stashed previously
Returns:
mixed stashed data or the default value

Definition at line 481 of file lib.php.

Here is the call graph for this function:

grouped_parent_exists ( pelement,
elements 
) [protected]

Helper method used by self::register_handler()

Parameters:
convert_path$pelementpath element
arrayof convert_path instances
Returns:
bool true if grouped parent was found, false otherwise

Definition at line 212 of file lib.php.

Here is the caller graph for this function:

init ( ) [protected]

Initialize the instance if needed, called by the constructor

Here we create objects we need before the execution.

Reimplemented from base_converter.

Definition at line 116 of file lib.php.

Here is the call graph for this function:

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

Reimplemented from base_converter.

Definition at line 79 of file lib.php.

Here is the caller graph for this function:

static migrate_referenced_files ( text,
moodle1_file_manager fileman 
) [static]

Migrates all course files referenced from the hypertext using the given filemanager

This is typically used to convert images embedded into the intro fields.

Parameters:
string$texthypertext containing $$ referenced
moodle1_file_manager$filemanfile manager to use for the file migration
Returns:
string the original $text with $$ references replaced with the new @PLUGINFILE@

Definition at line 600 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

path_end_reached ( path)

Executes operations required at the end of a watched path

Parameters:
string$pathin the original file

Definition at line 385 of file lib.php.

path_start_reached ( path)

Executes operations required at the start of a watched path

For MOD and BLOCK paths, this is supported only for the sub-paths, not the root module/block element. For the illustration:

You CAN'T attach on_xxx_start() listener to a path like /MOODLE_BACKUP/COURSE/MODULES/MOD/WORKSHOP because the <MOD> must be processed first in self::process_chunk() where $this->currentmod is set.

You CAN attach some on_xxx_start() listener to a path like /MOODLE_BACKUP/COURSE/MODULES/MOD/WORKSHOP/SUBMISSIONS because it is a sub-path under <MOD> and we have $this->currentmod already set when the <SUBMISSIONS> is reached.

Parameters:
string$pathin the original file

Definition at line 341 of file lib.php.

process_chunk ( data)

Process the data obtained from the XML parser processor

This methods receives one chunk of information from the XML parser processor and dispatches it, following the naming rules. We are expanding the modules and blocks paths here to include the plugin's name.

Parameters:
array$data

Definition at line 238 of file lib.php.

Here is the call graph for this function:

register_handler ( moodle1_handler handler,
array elements 
) [protected]

Register a handler for the given path elements

Definition at line 160 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

static rewrite_filephp_usage ( text,
array files 
) [static]

Given the list of migrated files, rewrites references to them from $$ form to the @PLUGINFILE@ one

See also:
self::migrate_referenced_files()
Parameters:
string$text
array$files
Returns:
string

Definition at line 657 of file lib.php.

Here is the caller graph for this function:

set_stash ( stashname,
info,
itemid = 0 
)

Stores some information for later processing

This implementation uses backup_ids_temp table to store data. Make sure that the $stashname + $itemid combo is unique.

Parameters:
string$stashnamename of the stash
mixed$infoinformation to stash
int$itemidoptional id for multiple infos within the same stashname

Definition at line 445 of file lib.php.

Here is the call graph for this function:

Here is the caller graph for this function:


Field Documentation

$currentblock = null [protected]

Definition at line 56 of file lib.php.

$currentmod = null [protected]

Definition at line 53 of file lib.php.

$pathelements = array() [protected]

Definition at line 50 of file lib.php.

$pathlock [protected]

Definition at line 59 of file lib.php.

$xmlparser [protected]

Definition at line 44 of file lib.php.

$xmlprocessor [protected]

Definition at line 47 of file lib.php.

const SKIP_ALL_CHILDREN = -991399

Instructs the dispatcher to ignore all children below path processor returning it

Definition at line 67 of file lib.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations