Skip to content

Commit

Permalink
Fixed #8 bug with missing theme mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed May 11, 2020
1 parent 180f892 commit 9ab6ee9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['editor_info'] = 'Falls der Editor nicht korrekt angezeigt wird, laden Sie die Seite bitte neu.';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['source'][0] = 'Quelltext';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['source'][1] = 'Hier können Sie den Quelltext direkt bearbeiten';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['unknown_theme'] = 'Keinem Theme zugeordnet';
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['editor_info'] = 'If the editor doesn\'t appear correctly, reload the page.';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['source'][0] = 'Source code';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['source'][1] = 'Here you can edit the source code directly.';
$GLOBALS['TL_LANG']['rocksolid_theme_assistant']['unknown_theme'] = 'Not associated with a theme';
40 changes: 39 additions & 1 deletion src/ThemeAssistantDataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function showAll()
$files[] = array(
'id' => $file,
'type' => $extension === 'html5' ? 'html' : $extension,
'name' => substr($file, strlen($folder)+1, -5),
'name' => substr($file, strlen($GLOBALS['TL_CONFIG']['uploadPath'])+1, -5),
);
}
}
Expand Down Expand Up @@ -125,6 +125,44 @@ public function showAll()

}

$files = array();
$allCssFiles = array_merge(
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*/*/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*/*/*/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*/*/*/*/*.css.base') ?: array(),
glob(TL_ROOT . '/' . $GLOBALS['TL_CONFIG']['uploadPath'] . '/*/*/*/*/*/*/*.css.base') ?: array()
);

foreach ($allCssFiles as $baseFile) {
if(!file_exists(substr($baseFile, 0, -5))){
continue;
}
$baseFileId = substr($baseFile, strlen(TL_ROOT)+1);
foreach ($themeList as $theme) {
foreach ($theme['files'] as $file) {
if ($file['id'] === $baseFileId) {
continue 3;
}
}
}
$files[] = array(
'id' => $baseFileId,
'type' => 'css',
'name' => substr($baseFileId, strlen($GLOBALS['TL_CONFIG']['uploadPath'])+1, -5),
);
}

if (count($files)) {
$themeList[] = array(
'name' => $GLOBALS['TL_LANG']['rocksolid_theme_assistant']['unknown_theme'],
'files' => $files,
'screenshot' => null,
);
}

if (!count($themeList)) {
return '<p class="tl_empty">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
}
Expand Down

0 comments on commit 9ab6ee9

Please sign in to comment.