feat: resolve mokocassiopeia download URL from updates.xml

Instead of hardcoding the zip URL, fetches MokoCassiopeia's updates.xml
from the repo main branch and parses the downloadurl. This way the
download location is controlled by the MokoCassiopeia repo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:28:08 -05:00
parent db4bf1c784
commit b1bc264314
+51 -3
View File
@@ -251,9 +251,22 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
return;
}
// Template not installed — try to install from GitHub
$zipUrl = 'https://github.com/mokoconsulting-tech/MokoCassiopeia'
. '/releases/latest/download/MokoCassiopeia.zip';
// Template not installed — get download URL from updates.xml
$updatesUrl = 'https://raw.githubusercontent.com'
. '/mokoconsulting-tech/MokoCassiopeia/main/updates.xml';
$zipUrl = $this->getDownloadUrlFromUpdates($updatesUrl);
if (empty($zipUrl))
{
Factory::getApplication()->enqueueMessage(
'MokoCassiopeia: could not resolve download URL.',
'warning'
);
return;
}
$tmpFile = JPATH_ROOT . '/tmp/mokocassiopeia.zip';
$tmpDir = JPATH_ROOT . '/tmp/mokocassiopeia';
@@ -366,6 +379,41 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
$db->execute();
}
/**
* Parse an updates.xml and return the download URL.
*
* @param string $updatesUrl URL to the updates.xml file
*
* @return string|null Download URL or null on failure
*
* @since 02.01.01
*/
private function getDownloadUrlFromUpdates($updatesUrl)
{
try
{
$xml = @file_get_contents($updatesUrl);
if ($xml === false)
{
return null;
}
$updates = new \SimpleXMLElement($xml);
if (isset($updates->update->downloads->downloadurl))
{
return (string) $updates->update->downloads->downloadurl;
}
}
catch (\Exception $e)
{
return null;
}
return null;
}
private const BLOCK_START = '; ===== BEGIN MokoWaaS Overrides (do not edit this block) =====';
/** Sentinel comment that marks the end of MokoWaaS overrides inside a Joomla override file. */