[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

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

Provides validation class to check the plugin ZIP contents Uses fragments of the local_plugins_archive_validator class copyrighted by Marina Glancy that is part of the local_plugins plugin.

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

Defines 1 class

tool_installaddon_validator:: (20 methods):
  instance()
  assert_plugin_type()
  assert_moodle_version()
  execute()
  get_result()
  get_messages()
  get_versionphp_info()
  get_language_file_name()
  get_rootdir()
  set_continue_url()
  get_continue_url()
  __construct()
  validate_files_layout()
  validate_version_php()
  validate_language_pack()
  validate_target_location()
  parse_version_php()
  add_message()
  get_stripped_file_contents()
  get_plugintype_location()


Class: tool_installaddon_validator  - X-Ref

Validates the contents of extracted plugin ZIP file

instance($zipcontentpath, array $zipcontentfiles)   X-Ref
Factory method returning instance of the validator

param: string $zipcontentpath full path to the extracted ZIP contents
param: array $zipcontentfiles (string)filerelpath => (bool|string)true or error
return: tool_installaddon_validator

assert_plugin_type($required)   X-Ref
Set the expected plugin type, fail the validation otherwise

param: string $required plugin type

assert_moodle_version($required)   X-Ref
Set the expectation that the plugin can be installed into the given Moodle version

param: string $required Moodle version we are about to install to

execute()   X-Ref
Execute the validation process against all explicit and implicit requirements

Returns true if the validation passes (all explicit and implicit requirements
pass) and the plugin can be installed. Returns false if the validation fails
(some explicit or implicit requirement fails) and the plugin must not be
installed.

return: bool

get_result()   X-Ref
Returns overall result of the validation.

Null is returned if the validation has not been executed yet. Otherwise
this method returns true (the installation can continue) or false (it is not
safe to continue with the installation).

return: bool|null

get_messages()   X-Ref
Return the list of validation log messages

Each validation message is a plain object with properties level, msgcode
and addinfo.

return: array of (int)index => (stdClass) validation message

get_versionphp_info()   X-Ref
Return the information provided by the the plugin's version.php

If version.php was not found in the plugin (which is tolerated for
themes only at the moment), null is returned. Otherwise the array
is returned. It may be empty if no information was parsed (which
should not happen).

return: null|array

get_language_file_name()   X-Ref
Returns the name of the English language file without the .php extension

This can be used as a suggestion for fixing the plugin root directory in the
ZIP file during the upload. If no file was found, or multiple PHP files are
located in lang/en/ folder, then null is returned.

return: null|string

get_rootdir()   X-Ref
Returns the rootdir of the extracted package (after eventual renaming)

return: string|null

set_continue_url(moodle_url $url)   X-Ref
Sets the URL to continue to after successful validation

param: moodle_url $url

get_continue_url()   X-Ref
Get the URL to continue to after successful validation

Null is returned if the URL has not been explicitly set by the caller.

return: moodle_url|null

__construct($zipcontentpath, array $zipcontentfiles)   X-Ref

param: string $zipcontentpath full path to the extracted ZIP contents
param: array $zipcontentfiles (string)filerelpath => (bool|string)true or error

validate_files_layout()   X-Ref

return: bool false if files in the ZIP do not have required layout

validate_version_php()   X-Ref

return: bool false if the version.php file does not declare required information

validate_language_pack()   X-Ref

return: bool false if the English language pack is not provided correctly

validate_target_location()   X-Ref

return: bool false of the given add-on can't be installed into its location

parse_version_php($fullpath)   X-Ref
Get as much information from existing version.php as possible

param: string full path to the version.php file
return: array of found meta-info declarations

add_message($level, $msgcode, $a = null)   X-Ref
Append the given message to the messages log

param: string $level e.g. self::ERROR
param: string $msgcode may form a string
param: string|array|object $a optional additional info suitable for {@link get_string()}

get_stripped_file_contents($fullpath)   X-Ref
Returns bare PHP code from the given file

Returns contents without PHP opening and closing tags, text outside php code,
comments and extra whitespaces.

param: string $fullpath full path to the file
return: string

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

param: string $plugintype
return: string|null



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