|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| component_installer ($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') | |
| check_requisites () | |
| install () | |
| need_upgrade () | |
| change_zip_file ($newzipfilename) | |
| get_local_md5 () | |
| get_component_md5 () | |
| get_all_components_md5 () | |
| get_error () | |
| get_extra_md5_field () | |
Data Fields | |
| $sourcebase | |
| $zippath | |
| Full http URL, base for downloadable items. | |
| $zipfilename | |
| $md5filename | |
| Name of the .zip file to be downloaded. | |
| $componentname | |
| Name of the .md5 file to be read. | |
| $destpath | |
| $errorstring | |
| $extramd5info | |
| Latest error produced. It will contain one lang string key. | |
| $requisitesok | |
| Contents of the optional third field in the .md5 file. | |
| $cachedmd5components | |
Definition at line 155 of file componentlib.class.php.
| change_zip_file | ( | $ | newzipfilename | ) |
This function will change the zip file to install on the fly to allow the class to process different components of the same md5 file without intantiating more objects.
| string | $newzipfilename | New zip filename to process |
Definition at line 388 of file componentlib.class.php.

| check_requisites | ( | ) |
This function will check if everything is properly set to begin one installation. Also, it will check for required settings and will fill everything as needed.
object
Check that everything we need is present
Check for correct sourcebase (this will be out in the future)
Check the zip file is a correct one (by extension)
Check that exists under dataroot
Calculate the componentname
Calculate md5filename if it's empty
Set the requisites passed flag
Definition at line 217 of file componentlib.class.php.

| component_installer | ( | $ | sourcebase, |
| $ | zippath, | ||
| $ | zipfilename, | ||
| $ | md5filename = '', |
||
| $ | destpath = '' |
||
| ) |
Array of cached components to avoid to download the same md5 file more than once per request. Standard constructor of the class. It will initialize all attributes. without performing any check at all.
| string | $sourcebase | Full http URL, base for downloadeable items |
| string | $zippath | Relative path (from sourcebase) where the downloadeable item resides |
| string | $zipfilename | Name of the .zip file to be downloaded |
| string | $md5filename | Name of the .md5 file to be read (default '' = same than zipfilename) |
| string | $destpath | Relative path (from moodledata) where the .zip file will be expanded (default='' = moodledataitself) |
Definition at line 193 of file componentlib.class.php.

This function allows you to retrieve the complete array of components found in the md5filename
Check requisites are passed
Initialize components array
Define and retrieve the full md5 file
Check if we have downloaded the md5 file before (per request cache)
Not downloaded, let's do it now
Split text into lines
Each line will be one component
If no components have been found, return error
Build an associative array of components for easily search applying trim to avoid linefeeds and other...
Avoid sometimes empty lines
Cache components
Return error
If there is no commponents or erros found, error
Definition at line 466 of file componentlib.class.php.


This function will download the specified md5 file, looking for the current componentname, returning its md5 field and storing extramd5info if present. Also it caches results to cachedmd5components for better performance in the same request.
Check requisites are passed
Get all components of md5 file
Search for the componentname component
Check we have a valid md5
Set the extramd5info field
Definition at line 430 of file componentlib.class.php.


| get_error | ( | ) |
This function returns the errorstring
Definition at line 539 of file componentlib.class.php.
This function returns the extramd5 field (optional in md5 file)
Definition at line 547 of file componentlib.class.php.
| get_local_md5 | ( | ) |
This function will get the local md5 value of the installed component.
object
Check requisites are passed
Fake value to force new installation
Calculate source to read
Read md5 value stored (if exists)
Definition at line 401 of file componentlib.class.php.

| install | ( | ) |
This function will perform the full installation if needed, i.e. compare md5 values, download, unzip, install and regenerate local md5 file
object COMPONENT_ERROR COMPONENT_UPTODATE COMPONENT_ERROR COMPONENT_INSTALLED
Check requisites are passed
Confirm we need upgrade
Create temp directory if necesary
Download zip file and save it to temp
Calculate its md5
Compare it with the remote md5 to check if we have the correct zip file
Move current revision to a safe place
Unzip new version
Error so, go back to the older
Delete old component version
Create local md5
Delete temp zip file
Definition at line 268 of file componentlib.class.php.

| need_upgrade | ( | ) |
This function will detect if remote component needs to be installed because it's different from the local one
COMPONENT_ERROR COMPONENT_UPTODATE COMPONENT_NEEDUPDATE
Check requisites are passed
Get local md5
Get remote md5
Return result
Definition at line 360 of file componentlib.class.php.


| $cachedmd5components |
Definition at line 176 of file componentlib.class.php.
| $componentname |
Name of the .md5 file to be read.
Definition at line 164 of file componentlib.class.php.
| $destpath |
Name of the component. Must be the zip name without the extension. And it defines a lot of things: the md5 line to search for, the default m5 file name and the name of the root dir stored inside the zip file
Definition at line 168 of file componentlib.class.php.
| $errorstring |
Relative path (from moodledata) where the .zip file will be expanded.
Definition at line 170 of file componentlib.class.php.
| $extramd5info |
Latest error produced. It will contain one lang string key.
Definition at line 171 of file componentlib.class.php.
| $md5filename |
Name of the .zip file to be downloaded.
Definition at line 163 of file componentlib.class.php.
| $requisitesok |
Contents of the optional third field in the .md5 file.
Definition at line 172 of file componentlib.class.php.
| $sourcebase |
Definition at line 159 of file componentlib.class.php.
| $zipfilename |
Relative path (from sourcebase) where the downloadeable item resides.
Definition at line 162 of file componentlib.class.php.
| $zippath |
Full http URL, base for downloadable items.
Definition at line 160 of file componentlib.class.php.