fix: remove theme preview tab and test page #4
@@ -91,12 +91,73 @@ class Tpl_MokoonyxInstallerScript implements InstallerScriptInterface
|
|||||||
// On install or update: migrate from MokoCassiopeia if it exists
|
// On install or update: migrate from MokoCassiopeia if it exists
|
||||||
if ($type === 'install' || $type === 'update') {
|
if ($type === 'install' || $type === 'update') {
|
||||||
$this->migrateFromCassiopeia();
|
$this->migrateFromCassiopeia();
|
||||||
|
$this->replaceCassiopeiaReferences();
|
||||||
$this->clearFaviconStamp();
|
$this->clearFaviconStamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace MokoCassiopeia references in article content and module content.
|
||||||
|
*/
|
||||||
|
private function replaceCassiopeiaReferences(): void
|
||||||
|
{
|
||||||
|
$db = Factory::getDbo();
|
||||||
|
|
||||||
|
// Replace in article content (introtext + fulltext)
|
||||||
|
foreach (['introtext', 'fulltext'] as $col) {
|
||||||
|
try {
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->update('#__content')
|
||||||
|
->set(
|
||||||
|
$db->quoteName($col) . ' = REPLACE(REPLACE('
|
||||||
|
. $db->quoteName($col) . ', '
|
||||||
|
. $db->quote(self::OLD_DISPLAY) . ', '
|
||||||
|
. $db->quote(self::NEW_DISPLAY) . '), '
|
||||||
|
. $db->quote(self::OLD_NAME) . ', '
|
||||||
|
. $db->quote(self::NEW_NAME) . ')'
|
||||||
|
)
|
||||||
|
->where(
|
||||||
|
'(' . $db->quoteName($col) . ' LIKE ' . $db->quote('%' . self::OLD_DISPLAY . '%')
|
||||||
|
. ' OR ' . $db->quoteName($col) . ' LIKE ' . $db->quote('%' . self::OLD_NAME . '%') . ')'
|
||||||
|
);
|
||||||
|
$db->setQuery($query)->execute();
|
||||||
|
$n = $db->getAffectedRows();
|
||||||
|
if ($n > 0) {
|
||||||
|
$this->logMessage("Replaced MokoCassiopeia in {$n} content row(s) ({$col}).");
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->logMessage('Content replacement failed (' . $col . '): ' . $e->getMessage(), 'warning');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace in module content (custom HTML modules etc.)
|
||||||
|
try {
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->update('#__modules')
|
||||||
|
->set(
|
||||||
|
$db->quoteName('content') . ' = REPLACE(REPLACE('
|
||||||
|
. $db->quoteName('content') . ', '
|
||||||
|
. $db->quote(self::OLD_DISPLAY) . ', '
|
||||||
|
. $db->quote(self::NEW_DISPLAY) . '), '
|
||||||
|
. $db->quote(self::OLD_NAME) . ', '
|
||||||
|
. $db->quote(self::NEW_NAME) . ')'
|
||||||
|
)
|
||||||
|
->where(
|
||||||
|
'(' . $db->quoteName('content') . ' LIKE ' . $db->quote('%' . self::OLD_DISPLAY . '%')
|
||||||
|
. ' OR ' . $db->quoteName('content') . ' LIKE ' . $db->quote('%' . self::OLD_NAME . '%') . ')'
|
||||||
|
);
|
||||||
|
$db->setQuery($query)->execute();
|
||||||
|
$n = $db->getAffectedRows();
|
||||||
|
if ($n > 0) {
|
||||||
|
$this->logMessage("Replaced MokoCassiopeia in {$n} module(s).");
|
||||||
|
}
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->logMessage('Module replacement failed: ' . $e->getMessage(), 'warning');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the favicon stamp file so favicons and site.webmanifest
|
* Delete the favicon stamp file so favicons and site.webmanifest
|
||||||
* are regenerated on the next page load after install/update.
|
* are regenerated on the next page load after install/update.
|
||||||
|
|||||||
Reference in New Issue
Block a user