$vdir = new VirtualDirectory($this->dest);
$vdir->copyDirectory($this->compilePath . '/dist/css', 'css');
$vdir->copyDirectory($this->compilePath . '/dist/js', 'js');
- $vdir->copyDirectory($this->compilePath . '/dist/assets', 'assets');
+ $vdir->copyDirectory($this->compilePath . '/dist/assets', 'assets',false);
$l10n = $this->data->l10n;
$blade = new Blade($this->_resourcesPath() . '/views', $this->_resourcesPath() . '/cache/' . md5(rand(100000, 10000000)) . '/');
$data = ['mainColor' => (string)$quiz->mainColor,
'okColor' => (string)$quiz->okColor,
'nokColor' => (string)$quiz->nokColor,
- 'logo' => hash_file('sha256', $logo),
- 'banner' => hash_file('sha256', $banner),
+ 'logo' => $logo ? hash_file('sha256', $logo) : '',
+ 'banner' => $banner ? hash_file('sha256', $banner) : '',
'overlay' => (string)$quiz->overlay,
];
$hash = hash('sha256', print_r($data, true));
$theme->owner = $quiz->owner;
- $logo = new \SplFileInfo($logo);
- $tmp = Files::tempnam() . '.' . $logo->getExtension();
- copy($logo, $tmp);
- $theme->addMediaToField('logo', $tmp);
-
- $theme->backgroundCustom = '1';
+ if ($logo) {
+ $logo = new \SplFileInfo($logo);
+ $tmp = Files::tempnam() . '.' . $logo->getExtension();
+ copy($logo, $tmp);
+ $theme->addMediaToField('logo', $tmp);
+ $theme->backgroundCustom = '1';
+ }
$theme->font = 'SourceSans';
- $avg = Imagemagick::getAverageColor($banner);
- $distance = $avg->distance(new \Cubist\Util\Graphics\Color('#fff'));
- $darken = $distance <= 20000000;
+ if ($banner) {
+ $avg = Imagemagick::getAverageColor($banner);
+ $distance = $avg->distance(new \Cubist\Util\Graphics\Color('#fff'));
+ $darken = $distance <= 20000000;
- if ($darken) {
- $tmp = Files::tempnam() . '.jpg';
- Imagemagick::brightnessContrast($banner, $tmp, -20);
- $banner = $tmp;
- }
+ if ($darken) {
+ $tmp = Files::tempnam() . '.jpg';
+ Imagemagick::brightnessContrast($banner, $tmp, -20);
+ $banner = $tmp;
+ }
- $theme->addMediaToField('backgroundImage', self::resizeAndBlur($banner, 1200, 680));
- $theme->addMediaToField('backgroundImageMobile', self::resizeAndBlur($banner, 390, 844));
+ $theme->addMediaToField('backgroundImage', self::resizeAndBlur($banner, 1200, 680));
+ $theme->addMediaToField('backgroundImageMobile', self::resizeAndBlur($banner, 390, 844));
+ } else {
+ $theme->backgroundColor = '#aaa';
+ }
$theme->save();
return $theme->id;
$resizer->resize($width, $height, true, true);
$resizer->output('jpg', $tmp);
-
Imagemagick::blur($tmp, $blur);
- unlink($tmp);
+ Files::unlink($tmp);
return $blur;
}