From 1d990a604ecfd9118dd3e8efaf3ee190242e11f4 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 31 Dec 2020 09:05:59 -0500 Subject: [PATCH] Make $modules->getModule($moduleName) be non-case-sensitive for $moduleName. Plus minor updates to Fieldtypes API var and ProcessTemplate module. --- wire/core/Fieldtypes.php | 17 ++++++++--------- wire/core/Modules.php | 11 +++++++++++ .../ProcessTemplate/ProcessTemplate.module | 2 +- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/wire/core/Fieldtypes.php b/wire/core/Fieldtypes.php index 1eff57f4..e7250e53 100644 --- a/wire/core/Fieldtypes.php +++ b/wire/core/Fieldtypes.php @@ -93,11 +93,8 @@ class Fieldtypes extends WireArray { */ public function init() { $this->isAPI = true; - foreach($this->wire('modules') as $name => $module) { - if(strpos($name, 'Fieldtype') === 0) { - // if($module instanceof ModulePlaceholder) $module = $this->wire('modules')->get($module->className()); - $this->add($module); - } + foreach($this->wire()->modules->findByPrefix('Fieldtype', 3) as $name => $module) { + $this->add($module); } } @@ -113,7 +110,7 @@ class Fieldtypes extends WireArray { foreach($this->data as $moduleName => $module) { if($module instanceof ModulePlaceholder) { $fieldtype = $modules->getModule($moduleName); - $this->data[$moduleName] = $fieldtype; + if($fieldtype) $this->data[$moduleName] = $fieldtype; } } if($debug) Debug::saveTimer('Fieldtypes.preload'); @@ -188,10 +185,12 @@ class Fieldtypes extends WireArray { */ public function get($key) { - if(strpos($key, 'Fieldtype') !== 0) $key = "Fieldtype" . ucfirst($key); + if(stripos($key, 'Fieldtype') !== 0) $key = 'Fieldtype' . ucfirst($key); - if(!$fieldtype = parent::get($key)) { - $fieldtype = $this->wire()->modules->getModule($key); + $fieldtype = parent::get($key); + + if(!$fieldtype) { + $fieldtype = $this->wire()->modules->getModule($key); if($fieldtype) $this->set($key, $fieldtype); } diff --git a/wire/core/Modules.php b/wire/core/Modules.php index 9233fa4b..2a9a0c34 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -1276,11 +1276,22 @@ class Modules extends WireArray { return empty($options['returnError']) ? null : "Unable to find module ID $moduleID"; } } else { + $moduleID = 0; $key = wireClassName($key, false); } $module = parent::get($key); + if(!$module && !$moduleID) { + // make non case-sensitive for module name ($key) + $lowerKey = strtolower($key); + foreach(array_keys($this->moduleIDs) as $className) { + if(strtolower($className) !== $lowerKey) continue; + $module = parent::get($className); + break; + } + } + if(!$module) { if(empty($options['noSubstitute'])) { if($this->isInstallable($key) && empty($options['noInstall'])) { diff --git a/wire/modules/Process/ProcessTemplate/ProcessTemplate.module b/wire/modules/Process/ProcessTemplate/ProcessTemplate.module index e937a679..cfcd6887 100644 --- a/wire/modules/Process/ProcessTemplate/ProcessTemplate.module +++ b/wire/modules/Process/ProcessTemplate/ProcessTemplate.module @@ -2197,7 +2197,7 @@ class ProcessTemplate extends Process { protected function buildEditFormAccessRoles(Template $template = null) { $adminTheme = $this->wire()->adminTheme; - $checkboxClass = $adminTheme ? $this->wire()->adminTheme->getClass('input-checkbox') : ''; + $checkboxClass = $adminTheme ? $adminTheme->getClass('input-checkbox') : ''; $roles = $this->pages->get($this->config->rolesPageID)->children(); $checked = "checked='checked' "; $disabled = "";