[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/admin/tool/installaddon/classes/ -> installer.php (summary)

Provides tool_installaddon_installer related classes

Copyright: 2013 David Mudrak <[email protected]>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 647 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

tool_installaddon_installer:: (20 methods):
  instance()
  index_url()
  get_addons_repository_url()
  get_installfromzip_form()
  save_installfromzip_file()
  extract_installfromzip_file()
  get_plugin_types_menu()
  get_plugintype_root()
  is_plugintype_writable()
  handle_remote_request()
  download_file()
  move_directory()
  __construct()
  get_site_fullname()
  get_site_url()
  get_site_major_version()
  encode_site_information()
  should_send_site_info()
  rename_extracted_rootdir()
  decode_remote_request()

tool_installaddon_installer_exception:: (1 method):
  __construct()


Class: tool_installaddon_installer  - X-Ref

Implements main plugin features.

instance()   X-Ref
Factory method returning an instance of this class.

return: tool_installaddon_installer

index_url(array $params = null)   X-Ref
Returns the URL to the main page of this admin tool

param: array optional parameters
return: moodle_url

get_addons_repository_url()   X-Ref
Returns URL to the repository that addons can be searched in and installed from

return: moodle_url

get_installfromzip_form()   X-Ref

return: tool_installaddon_installfromzip_form

save_installfromzip_file(tool_installaddon_installfromzip_form $form, $targetdir)   X-Ref
Saves the ZIP file from the {@link tool_installaddon_installfromzip_form} form

The file is saved into the given temporary location for inspection and eventual
deployment. The form is expected to be submitted and validated.

param: tool_installaddon_installfromzip_form $form
param: string $targetdir full path to the directory where the ZIP should be stored to
return: string filename of the saved file relative to the given target

extract_installfromzip_file($zipfilepath, $targetdir, $rootdir = '')   X-Ref
Extracts the saved file previously saved by {self::save_installfromzip_file()}

The list of files found in the ZIP is returned via $zipcontentfiles parameter
by reference. The format of that list is array of (string)filerelpath => (bool|string)
where the array value is either true or a string describing the problematic file.

param: string $zipfilepath full path to the saved ZIP file
param: string $targetdir full path to the directory to extract the ZIP file to
param: string $rootdir explicitly rename the root directory of the ZIP into this non-empty value
param: array list of extracted files as returned by {@link zip_packer::extract_to_pathname()}

get_plugin_types_menu()   X-Ref
Returns localised list of available plugin types

return: array (string)plugintype => (string)plugin name

get_plugintype_root($plugintype)   X-Ref
Returns the full path of the root of the given plugin type

Null is returned if the plugin type is not known. False is returned if the plugin type
root is expected but not found. Otherwise, string is returned.

param: string $plugintype
return: string|bool|null

is_plugintype_writable($plugintype)   X-Ref
Is it possible to create a new plugin directory for the given plugin type?

param: string $plugintype
return: boolean

handle_remote_request(tool_installaddon_renderer $output, $request, $confirmed = false)   X-Ref
Hook method to handle the remote request to install an add-on

This is used as a callback when the admin picks a plugin version in the
Moodle Plugins directory and is redirected back to their site to install
it.

This hook is called early from admin/tool/installaddon/index.php page so that
it has opportunity to take over the UI.

param: tool_installaddon_renderer $output
param: string|null $request
param: bool $confirmed

download_file($source, $target)   X-Ref
Download the given file into the given destination.

This is basically a simplified version of {@link download_file_content()} from
Moodle itself, tuned for fetching files from moodle.org servers. Same code is used
in mdeploy.php for fetching available updates.

param: string $source file url starting with http(s)://
param: string $target store the downloaded content to this file (full path)

move_directory($source, $target, $dirpermissions, $filepermissions)   X-Ref
Moves the given source into a new location recursively

This is cross-device safe implementation to be used instead of the native rename() function.
See https://bugs.php.net/bug.php?id=54097 for more details.

param: string $source full path to the existing directory
param: string $target full path to the new location of the directory
param: int $dirpermissions
param: int $filepermissions

__construct()   X-Ref


get_site_fullname()   X-Ref

return: string this site full name

get_site_url()   X-Ref

return: string this site URL

get_site_major_version()   X-Ref

return: string major version like 2.5, 2.6 etc.

encode_site_information(array $info)   X-Ref
Encodes the given array in a way that can be safely appended as HTTP GET param

Be ware! The recipient may rely on the exact way how the site information is encoded.
Do not change anything here unless you know what you are doing and understand all
consequences! (Don't you love warnings like that, too? :-p)

param: array $info
return: string

should_send_site_info()   X-Ref
Decide if the encoded site information should be sent to the add-ons repository site

For now, we just return true. In the future, we may want to implement some
privacy aware logic (based on site/user preferences for example).

return: bool

rename_extracted_rootdir($dirname, $rootdir, array $files)   X-Ref
Renames the root directory of the extracted ZIP package.

This method does not validate the presence of the single root directory
(the validator does it later). It just searches for the first directory
under the given location and renames it.

The method will not rename the root if the requested location already
exists.

param: string $dirname the location of the extracted ZIP package
param: string $rootdir the requested name of the root directory
param: array $files list of extracted files
return: array eventually amended list of extracted files

decode_remote_request($request)   X-Ref
Decode the request from the Moodle Plugins directory

param: string $request submitted via 'installaddonrequest' HTTP parameter
return: stdClass|bool false on error, object otherwise

Class: tool_installaddon_installer_exception  - X-Ref

General exception thrown by {@link tool_installaddon_installer} class

__construct($errorcode, $a=null, $debuginfo=null)   X-Ref

param: string $errorcode exception description identifier
param: mixed $debuginfo debugging data to display



Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1