Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public function preflight($action, $installer)
if (array_key_exists('version', $manifestValues)) {
$this->fromVersion = $manifestValues['version'];

// Ensure templates are moved to the correct mode
$this->fixTemplateMode();

return true;
}
}
Expand Down Expand Up @@ -1058,8 +1055,6 @@ public function deleteUnexistingFiles($dryRun = false, $suppressOutput = false)
}
}

$this->moveRemainingTemplateFiles();

foreach ($folders as $folder) {
if ($folderExists = Folder::exists(JPATH_ROOT . $folder)) {
$status['folders_exist'][] = $folder;
Expand Down Expand Up @@ -1644,84 +1639,6 @@ protected function fixFilenameCasing()
}
}

/**
* Move core template (s)css or js or image files which are left after deleting
* obsolete core files to the right place in media folder.
*
* @return void
*
* @since 4.1.0
*/
protected function moveRemainingTemplateFiles()
{
$folders = [
'/administrator/templates/atum/css' => '/media/templates/administrator/atum/css',
'/administrator/templates/atum/images' => '/media/templates/administrator/atum/images',
'/administrator/templates/atum/js' => '/media/templates/administrator/atum/js',
'/administrator/templates/atum/scss' => '/media/templates/administrator/atum/scss',
'/templates/cassiopeia/css' => '/media/templates/site/cassiopeia/css',
'/templates/cassiopeia/images' => '/media/templates/site/cassiopeia/images',
'/templates/cassiopeia/js' => '/media/templates/site/cassiopeia/js',
'/templates/cassiopeia/scss' => '/media/templates/site/cassiopeia/scss',
];

foreach ($folders as $oldFolder => $newFolder) {
if (Folder::exists(JPATH_ROOT . $oldFolder)) {
$oldPath = realpath(JPATH_ROOT . $oldFolder);
$newPath = realpath(JPATH_ROOT . $newFolder);
$directory = new \RecursiveDirectoryIterator($oldPath);
$directory->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($directory);

// Handle all files in this folder and all sub-folders
foreach ($iterator as $oldFile) {
if ($oldFile->isDir()) {
continue;
}

$newFile = $newPath . substr($oldFile, strlen($oldPath));

// Create target folder and parent folders if they don't exist yet
if (is_dir(dirname($newFile)) || @mkdir(dirname($newFile), 0755, true)) {
File::move($oldFile, $newFile);
}
}
}
}
}

/**
* Ensure the core templates are correctly moved to the new mode.
*
* @return void
*
* @since 4.1.0
*/
protected function fixTemplateMode(): void
{
$db = Factory::getContainer()->get('DatabaseDriver');

array_map(
function ($template) use ($db) {
$clientId = $template === 'atum' ? 1 : 0;
$query = $db->getQuery(true)
->update($db->quoteName('#__template_styles'))
->set($db->quoteName('inheritable') . ' = 1')
->where($db->quoteName('template') . ' = ' . $db->quote($template))
->where($db->quoteName('client_id') . ' = ' . $clientId);

try {
$db->setQuery($query)->execute();
} catch (Exception $e) {
echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '<br>';

return;
}
},
['atum', 'cassiopeia']
);
}

/**
* Add the user Auth Provider Column as it could be present from 3.10 already
*
Expand Down