Skip to content

Commit

Permalink
Merge branch 'MDL-67515-master' of git://github.com/vmdef/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Mar 2, 2021
2 parents e86504f + bb4da69 commit 5db1ed8
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions admin/tool/customlang/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class tool_customlang_utils {
const ROUGH_NUMBER_OF_STRINGS = 16500;

/** @var array cache of {@link self::list_components()} results */
protected static $components = null;
private static $components = null;

/**
* This class can not be instantiated
Expand All @@ -54,28 +54,30 @@ private function __construct() {
*/
public static function list_components() {

$list['moodle'] = 'core';
if (self::$components === null) {
$list['moodle'] = 'core';

$coresubsystems = core_component::get_core_subsystems();
ksort($coresubsystems); // should be but just in case
foreach ($coresubsystems as $name => $location) {
$list[$name] = 'core_'.$name;
}
$coresubsystems = core_component::get_core_subsystems();
ksort($coresubsystems); // Should be but just in case.
foreach ($coresubsystems as $name => $location) {
$list[$name] = 'core_' . $name;
}

$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $location) {
$pluginlist = core_component::get_plugin_list($type);
foreach ($pluginlist as $name => $ununsed) {
if ($type == 'mod') {
// Plugin names are now automatically validated.
$list[$name] = $type.'_'.$name;
} else {
$list[$type.'_'.$name] = $type.'_'.$name;
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $location) {
$pluginlist = core_component::get_plugin_list($type);
foreach ($pluginlist as $name => $ununsed) {
if ($type == 'mod') {
// Plugin names are now automatically validated.
$list[$name] = $type . '_' . $name;
} else {
$list[$type . '_' . $name] = $type . '_' . $name;
}
}
}
self::$components = $list;
}

return $list;
return self::$components;
}

/**
Expand Down Expand Up @@ -211,14 +213,18 @@ public static function checkin($lang) {
return false;
}

// get all customized strings from updated components
list($insql, $inparams) = $DB->get_in_or_equal(self::list_components());

// Get all customized strings from updated valid components.
$sql = "SELECT s.*, c.name AS component
FROM {tool_customlang} s
JOIN {tool_customlang_components} c ON s.componentid = c.id
WHERE s.lang = ?
AND (s.local IS NOT NULL OR s.modified = 1)
AND c.name $insql
ORDER BY componentid, stringid";
$strings = $DB->get_records_sql($sql, array($lang));
array_unshift($inparams, $lang);
$strings = $DB->get_records_sql($sql, $inparams);

$files = array();
foreach ($strings as $string) {
Expand Down Expand Up @@ -336,11 +342,9 @@ protected static function dump_strings($lang, $component, $strings) {
* @return string|boolean filename eg 'moodle.php' or 'workshop.php', false if not found
*/
protected static function get_component_filename($component) {
if (is_null(self::$components)) {
self::$components = self::list_components();
}

$return = false;
foreach (self::$components as $legacy => $normalized) {
foreach (self::list_components() as $legacy => $normalized) {
if ($component === $normalized) {
$return = $legacy.'.php';
break;
Expand Down

0 comments on commit 5db1ed8

Please sign in to comment.