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

End of component_installer class. More...

Public Member Functions

 __construct ($langcode='')
 Prepare the installer. More...
 
 get_remote_list_of_languages ()
 Returns the list of available language packs from download.moodle.org. More...
 
 lang_pack_url ($langcode='')
 Returns the URL where a given language pack can be downloaded. More...
 
 run ()
 Runs the installer. More...
 
 set_queue ($langcodes)
 Sets the queue of language packs to be installed. More...
 

Public Attributes

const RESULT_DOWNLOADERROR = 'downloaderror'
 there was a problem with downloading the lang pack
 
const RESULT_INSTALLED = 'installed'
 lang pack was successfully downloaded and deployed
 
const RESULT_UPTODATE = 'uptodate'
 lang pack was up-to-date so no download was needed
 

Protected Member Functions

 add_to_queue ($langcodes)
 Adds a language pack (or a list of them) to the queue. More...
 
 get_parent_language ($langcode)
 Returns a parent language of the given installed language. More...
 
 install_language_pack ($langcode)
 Perform the actual language pack installation. More...
 
 is_queued ($langcode='')
 
 mark_processed ($langcode)
 Mark the given language pack as processed. More...
 
 was_processed ($langcode)
 Checks if the given language has already been processed by this instance. More...
 

Protected Attributes

string $current
 the code of language being currently installed
 
array $done = array()
 of languages already installed by this instance
 
array $queue = array()
 of languages to install
 
string $version
 this Moodle major version
 

Detailed Description

End of component_installer class.

Language packs installer

This class wraps the functionality provided by component_installer and adds support for installing a set of language packs.

Given an array of required language packs, this class fetches them all and installs them. It detects eventual dependencies and installs all parent languages, too.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

lang_installer::__construct (   $langcode = '')

Prepare the installer.

Parameters
string | array$langcodea code of the language to install

Member Function Documentation

◆ add_to_queue()

lang_installer::add_to_queue (   $langcodes)
protected

Adds a language pack (or a list of them) to the queue.

Parameters
string | array$langcodescode of the language to install or a list of them

◆ get_parent_language()

lang_installer::get_parent_language (   $langcode)
protected

Returns a parent language of the given installed language.

Parameters
string$langcode
Return values
stringparent language's code

◆ get_remote_list_of_languages()

lang_installer::get_remote_list_of_languages ( )

Returns the list of available language packs from download.moodle.org.

Return values
array|boolfalse if can not download

◆ install_language_pack()

lang_installer::install_language_pack (   $langcode)
protected

Perform the actual language pack installation.

@uses component_installer

Parameters
string$langcode
Return values
intreturn status

◆ lang_pack_url()

lang_installer::lang_pack_url (   $langcode = '')

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.

Parameters
string$langcodelanguage code like 'cs' or empty for unknown
Return values
stringURL

◆ mark_processed()

lang_installer::mark_processed (   $langcode)
protected

Mark the given language pack as processed.

See also
self::was_processed()
Parameters
string$langcode

◆ run()

lang_installer::run ( )

Runs the installer.

This method calls self::install_language_pack for every language in the queue. If a dependency is detected, the parent language is added to the queue.

Return values
arrayresults, array of self::RESULT_xxx constants indexed by language code

◆ set_queue()

lang_installer::set_queue (   $langcodes)

Sets the queue of language packs to be installed.

Parameters
string | array$langcodeslanguage code like 'cs' or a list of them

◆ was_processed()

lang_installer::was_processed (   $langcode)
protected

Checks if the given language has already been processed by this instance.

See also
self::mark_processed()
Parameters
string$langcode
Return values
boolean

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