fix(cli): Joomla module element detection and display name fixes #203

Merged
jmiller merged 4 commits from dev into main 2026-05-28 22:19:02 +00:00
4 changed files with 28 additions and 6 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ DEFGROUP: MokoStandards.Root
INGROUP: MokoStandards
REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
PATH: /README.md
VERSION: 09.03.00
VERSION: 09.03.02
BRIEF: Project overview and documentation
-->
+4 -1
View File
@@ -112,10 +112,13 @@ switch (true) {
$extFolder = $gm[1];
}
// Element name: <element>, plugin= attribute, <packagename>, or filename
// Element name: <element>, module= attribute, plugin= attribute, <packagename>, or filename
if (preg_match('/<element>([^<]+)<\/element>/', $xml, $em)) {
$extElement = $em[1];
}
if (empty($extElement) && preg_match('/module="([^"]*)"/', $xml, $mm)) {
$extElement = $mm[1];
}
if (empty($extElement) && preg_match('/plugin="([^"]*)"/', $xml, $pm)) {
$extElement = $pm[1];
}
+4 -1
View File
@@ -213,10 +213,13 @@ if ($extManifest !== null) {
$extFolder = $gm[1];
}
// Element name: <element>, plugin= attribute, <packagename>, or filename
// Element name: <element>, module= attribute, plugin= attribute, <packagename>, or filename
if (preg_match('/<element>([^<]+)<\/element>/', $xml, $em)) {
$extElement = $em[1];
}
if ($extElement === '' && preg_match('/module="([^"]*)"/', $xml, $mm)) {
$extElement = $mm[1];
}
if ($extElement === '' && preg_match('/plugin="([^"]*)"/', $xml, $pm)) {
$extElement = $pm[1];
}
+19 -3
View File
@@ -228,6 +228,12 @@ if (empty($extType)) {
$extType = 'component';
}
// If extName is still a technical/prefixed name (mod_foo, tpl_foo), prefer
// the human-readable name from .mokogitea/manifest.xml <identity><name>
if (preg_match('/^(pkg_|com_|mod_|plg_\w+_|tpl_|lib_)/i', $extName) && !empty($detectedName)) {
$extName = $detectedName;
}
// Build display name with type prefix (e.g. "Package - MokoWaaS")
$typeDisplayMap = [
'package' => 'Package',
@@ -239,6 +245,8 @@ $typeDisplayMap = [
'file' => 'File',
];
$typeDisplay = $typeDisplayMap[$extType] ?? ucfirst($extType);
// Strip existing type prefix to avoid doubling (e.g. "Template - Template - MokoOnyx")
$extName = preg_replace('/^(' . implode('|', array_map('preg_quote', $typeDisplayMap)) . ')\s*-\s*/i', '', $extName);
$displayName = "{$typeDisplay} - {$extName}";
// -- Build type prefix --------------------------------------------------------
@@ -365,9 +373,17 @@ function buildEntry(
$lines[] = ' <update>';
$lines[] = " <name>{$displayName}</name>";
$lines[] = " <description>{$displayName} {$stabilityLabel} build.</description>";
// Element in updates.xml must match what Joomla stores in #__extensions
// For packages: pkg_elementname. For plugins: elementname (folder handles grouping).
$dbElement = ($extType === 'package') ? "pkg_{$extElement}" : $extElement;
// Element in updates.xml must match what Joomla stores in #__extensions.
// Plugins are stored as bare element (folder handles grouping).
// All other types need their prefix: mod_, com_, tpl_, pkg_, lib_.
$prefixMap = [
'package' => 'pkg_',
'module' => 'mod_',
'component' => 'com_',
'template' => 'tpl_',
'library' => 'lib_',
];
$dbElement = isset($prefixMap[$extType]) ? $prefixMap[$extType] . $extElement : $extElement;
$lines[] = " <element>{$dbElement}</element>";
$lines[] = " <type>{$extType}</type>";
$lines[] = $clientTag;