Skip to content

Commit

Permalink
Fixed issue #14258: Path to preview image broken when creating a cust…
Browse files Browse the repository at this point in the history
…om admin theme
  • Loading branch information
dominikvitt committed Nov 22, 2018
1 parent 48f2542 commit af24103
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion application/models/AdminTheme.php
Expand Up @@ -307,6 +307,7 @@ static private function getThemeList($sDir)
{
$bOldEntityLoaderState = libxml_disable_entity_loader(true); // @see: http://phpsecurity.readthedocs.io/en/latest/Injection-Attacks.html#xml-external-entity-injection
$aListOfFiles = array();
$oAdminTheme = new AdminTheme;
if ($sDir && $pHandle = opendir($sDir)) {
while (false !== ($file = readdir($pHandle))) {
if (is_dir($sDir.DIRECTORY_SEPARATOR.$file) && is_file($sDir.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR.'config.xml')) {
Expand All @@ -315,7 +316,11 @@ static private function getThemeList($sDir)
// Simple Xml is buggy on PHP < 5.4. The [ array -> json_encode -> json_decode ] workaround seems to be the most used one.
// @see: http://php.net/manual/de/book.simplexml.php#105330 (top comment on PHP doc for simplexml)
$oTemplateConfig = json_decode(json_encode((array) simplexml_load_string($sXMLConfigFile), 1));
$previewUrl = Yii::app()->getConfig('styleurl').$file; // NOTE: will not work with uploaded themes for now
if ($oAdminTheme->isStandardAdminTheme($file)) {
$previewUrl = Yii::app()->getConfig('styleurl').$file;
} else {
$previewUrl = Yii::app()->getConfig('uploadurl').DIRECTORY_SEPARATOR.'admintheme'.DIRECTORY_SEPARATOR.$file;
}
$oTemplateConfig->path = $file;
$oTemplateConfig->preview = '<img src="'.$previewUrl.'/preview.png" alt="admin theme preview" height="200" class="img-thumbnail" />';
$aListOfFiles[$file] = $oTemplateConfig;
Expand Down

0 comments on commit af24103

Please sign in to comment.