getOneColumnTemplate($styles, $column_image, $class) :
$this->getMultipleColumnsTemplate($styles, $column_image, $width, $alignment, $class);
$result = array_map(function($content) use ($template) {
return $template['content_start'] . $content . $template['content_end'];
}, $columns_data);
$result = implode('', $result);
if($columns_count !== 1) {
$result = $template['container_start'] . $result . $template['container_end'];
}
return $result;
}
function getOneColumnTemplate($styles, $image, $class) {
$background_css = $this->getBackgroundCss($styles, $image);
$template['content_start'] = '
';
$template['content_end'] = '
|
|
';
return $template;
}
function getMultipleColumnsTemplate($styles, $image, $width, $alignment, $class) {
$background_css = $this->getBackgroundCss($styles, $image);
$template['container_start'] = '
';
$template['content_end'] = '
|
|
';
return $template;
}
private function getBackgroundCss($styles, $image) {
if($image !== null && $image['src'] !== null) {
$background_color = isset($styles['backgroundColor']) && $styles['backgroundColor'] !== 'transparent' ? $styles['backgroundColor'] : '#ffffff';
$repeat = $image['display'] === 'tile' ? 'repeat' : 'no-repeat';
$size = $image['display'] === 'scale' ? 'cover' : 'contain';
return sprintf(
'background: %s url(%s) %s center/%s;background-color: %s;background-image: url(%s);background-repeat: %s;background-position: center;background-size: %s;',
$background_color, $image['src'], $repeat, $size, $background_color, $image['src'], $repeat, $size
);
} else {
if(!isset($styles['backgroundColor'])) return false;
$background_color = $styles['backgroundColor'];
return ($background_color !== 'transparent') ?
sprintf('background-color:%s!important;" bgcolor="%s', $background_color, $background_color) :
false;
}
}
}