Skip to content
Closed
Changes from 2 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
14 changes: 12 additions & 2 deletions administrator/components/com_templates/src/Model/TemplateModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1810,11 +1810,21 @@ public function getMediaFiles()
$path = Path::clean(JPATH_ROOT . '/media/templates/' . ($template->client_id === 0 ? 'site' : 'administrator') . '/' . $template->element . '/');
$this->mediaElement = $path;

if (!is_dir($path)) {
// Just in case a template does not include any media
mkdir($path, 0777, true);
Comment thread
BrainforgeUK marked this conversation as resolved.
Outdated
}

$result = $this->getDirectoryTree($path);

if (!is_writable($path)) {
$app->enqueueMessage(Text::_('COM_TEMPLATES_DIRECTORY_NOT_WRITABLE'), 'error');
}
} elseif (empty($result)) {
// Add some default folders
foreach(['css', 'images', 'js', 'sccs'] as $folder) {
Comment thread
BrainforgeUK marked this conversation as resolved.
Outdated
mkdir($path . '/' . $folder, 0777, true);
}

if (is_dir($path)) {
$result = $this->getDirectoryTree($path);
}

Expand Down