Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Custom lang importer.

Copyright: 2020 Ferran Recio <ferran@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 268 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

importer:: (9 methods):
  __construct()
  get_log()
  import()
  deploy_files()
  unzip_file()
  process_files()
  component_from_filepath()
  import_strings()
  can_save_string()


Class: importer  - X-Ref

Class containing tha custom lang importer

__construct(string $lng, int $importmode = self::IMPORTALL)   X-Ref
Constructor for the importer class.

param: string $lng the current language to import.
param: int $importmode the import method (IMPORTALL, IMPORTNEW, IMPORTUPDATE).

get_log()   X-Ref
Returns the last parse log.

return: logstatus[] mlang logstatus with the messages

import(array $files)   X-Ref
Import customlang files.

param: stored_file[] $files array of files to import

deploy_files(array $files)   X-Ref
Deploy all files into a request folder.

param: stored_file[] $files array of files to deploy
return: string[] of file paths

unzip_file(stored_file $file)   X-Ref
Unzip a file into the request folder.

param: stored_file $file the zip file to unzip
return: string[] of zip content paths

process_files(array $langfiles)   X-Ref
Import strings from a list of langfiles.

param: string[] $langfiles an array with file paths

component_from_filepath(string $filepath)   X-Ref
Try to get the component from a filepath.

param: string $filepath the filepath
return: stdCalss|null the DB record of that component

import_strings(array $strings, stdClass $component)   X-Ref
Import an array of strings into the customlang tables.

param: langstring[] $strings the langstring to set
param: stdClass $component the target component

can_save_string(?stdClass $customlang, langstring $newstring, stdClass $component)   X-Ref
Determine if a specific string can be saved based on the current importmode.

param: stdClass $customlang customlang original record
param: langstring $newstring the new strign to store
param: stdClass $component the component target
return: bool if the string can be stored