Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
This library includes all the necessary stuff to use the one-click download and install feature of Moodle, used to keep updated some items like languages, pear, enviroment... i.e, components. It has been developed harcoding some important limits that are explained below: - It only can check, download and install items under moodledata. - Every downloadeable item must be one zip file. - The zip file root content must be 1 directory, i.e, everything is stored under 1 directory. - Zip file name and root directory must have the same name (but the .zip extension, of course). - Every .zip file must be defined in one .md5 file that will be stored in the same remote directory than the .zip file. - The name of such .md5 file is free, although it's recommended to use the same name than the .zip (that's the default assumption if no specified). - Every remote .md5 file will be a comma separated (CVS) file where each line will follow this format: - Field 1: name of the zip file (without extension). Mandatory. - Field 2: md5 of the zip file. Mandatory. - Field 3: whatever you want (or need). Optional. -Every local .md5 file will: - Have the zip file name (without the extension) plus -md5 - Will reside inside the expanded zip file dir - Will contain the md5 od the latest installed component With all these details present, the process will perform this tasks: - Perform security checks. Only admins are allowed to use this for now. - Read the .md5 file from source (1). - Extract the correct line for the .zip being requested. - Compare it with the local .md5 file (2). - If different: - Download the newer .zip file from source. - Calculate its md5 (3). - Compare (1) and (3). - If equal: - Delete old directory. - Uunzip the newer .zip file. - Create the new local .md5 file. - Delete the .zip file. - If different: - ERROR. Old package won't be modified. We shouldn't reach here ever. - If component download is not possible, a message text about how to do the process manually (remotedownloaderror) must be displayed to explain it.
Copyright: | (C) 2001-3001 Eloy Lafuente (stronk7) {@link http://contiento.com} |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 837 lines (30 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
component_installer:: (2 methods):
__construct()
component_installer()
name:: (9 methods):
check_requisites()
install()
need_upgrade()
change_zip_file()
get_local_md5()
get_component_md5()
get_all_components_md5()
get_error()
get_extra_md5_field()
lang_installer:: (11 methods):
__construct()
set_queue()
run()
lang_pack_url()
get_remote_list_of_languages()
add_to_queue()
is_queued()
was_processed()
mark_processed()
get_parent_language()
install_language_pack()
lang_installer_exception:: (1 method):
__construct()
Class: component_installer - X-Ref
This class is used to check, download and install items from__construct($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') X-Ref |
Standard constructor of the class. It will initialize all attributes. without performing any check at all. param: string $sourcebase Full http URL, base for downloadeable items param: string $zippath Relative path (from sourcebase) where the param: string $zipfilename Name of the .zip file to be downloaded param: string $md5filename Name of the .md5 file to be read (default '' = same param: string $destpath Relative path (from moodledata) where the .zip file will return: object |
component_installer($sourcebase, $zippath, $zipfilename, $md5filename='', $destpath='') X-Ref |
Old syntax of class constructor. Deprecated in PHP7. |
check_requisites() X-Ref |
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. return: boolean true/false (plus detailed error in errorstring) |
install() X-Ref |
This function will perform the full installation if needed, i.e. compare md5 values, download, unzip, install and regenerate local md5 file return: int COMPONENT_(ERROR | UPTODATE | INSTALLED) |
need_upgrade() X-Ref |
This function will detect if remote component needs to be installed because it's different from the local one return: int COMPONENT_(ERROR | UPTODATE | NEEDUPDATE) |
change_zip_file($newzipfilename) X-Ref |
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. param: string $newzipfilename New zip filename to process return: boolean true/false |
get_local_md5() X-Ref |
This function will get the local md5 value of the installed component. return: bool|string md5 of the local component (false on error) |
get_component_md5() X-Ref |
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. return: mixed md5 present in server (or false if error) |
get_all_components_md5() X-Ref |
This function allows you to retrieve the complete array of components found in the md5filename return: bool|array array of components in md5 file or false if error |
get_error() X-Ref |
This function returns the errorstring return: string the error string |
get_extra_md5_field() X-Ref |
No description |
Class: lang_installer - X-Ref
Language packs installer__construct($langcode = '') X-Ref |
Prepare the installer param: string|array $langcode a code of the language to install |
set_queue($langcodes) X-Ref |
Sets the queue of language packs to be installed param: string|array $langcodes language code like 'cs' or a list of them |
run() X-Ref |
Runs the installer This method calls {@link self::install_language_pack} for every language in the queue. If a dependency is detected, the parent language is added to the queue. return: array results, array of self::RESULT_xxx constants indexed by language code |
lang_pack_url($langcode = '') X-Ref |
Returns the URL where a given language pack can be downloaded Alternatively, if the parameter is empty, returns URL of the page with the list of all available language packs. param: string $langcode language code like 'cs' or empty for unknown return: string URL |
get_remote_list_of_languages() X-Ref |
Returns the list of available language packs from download.moodle.org return: array|bool false if can not download |
add_to_queue($langcodes) X-Ref |
Adds a language pack (or a list of them) to the queue param: string|array $langcodes code of the language to install or a list of them |
is_queued($langcode = '') X-Ref |
Checks if the given language is queued or if the queue is empty param: string $langcode language code or empty string for "any" return: boolean |
was_processed($langcode) X-Ref |
Checks if the given language has already been processed by this instance param: string $langcode return: boolean |
mark_processed($langcode) X-Ref |
Mark the given language pack as processed param: string $langcode |
get_parent_language($langcode) X-Ref |
Returns a parent language of the given installed language param: string $langcode return: string parent language's code |
install_language_pack($langcode) X-Ref |
Perform the actual language pack installation param: string $langcode return: int return status |
Class: lang_installer_exception - X-Ref
Exception thrown by {@link lang_installer}__construct($errorcode, $debuginfo = null) X-Ref |
No description |