- Refactored using @badshark's comments

- Integrated changes to JSON data
This commit is contained in:
MrCasual
2015-09-23 11:24:08 -04:00
parent 01b5416882
commit b3e376cd01
14 changed files with 1066 additions and 1197 deletions

View File

@@ -1,7 +1,6 @@
<?php namespace MailPoet\Newsletter\Renderer;
class StylesHelper {
public $cssAtributesTable = array(
'backgroundColor' => 'background-color',
'fontColor' => 'color',
@@ -16,22 +15,20 @@ class StylesHelper {
'lineHeight' => 'line-height'
);
function getBlockStyles($element, $ignore = false) {
function getBlockStyles($element) {
if(!isset($element['styles']['block'])) {
return;
}
return $this->getStyles($element['styles'], 'block', $ignore);
return $this->getStyles($element['styles'], 'block');
}
function getStyles($data, $type, $ignore = false) {
array_map(function ($attribute, $style) use (&$styles, $ignore) {
if(!$ignore || !in_array($attribute, $ignore)) {
$styles .= $this->translateCSSAttribute($attribute) . ': ' . $style . ' !important;';
}
function getStyles($data, $type) {
$styles = array_map(function ($attribute, $style) {
return $this->translateCSSAttribute($attribute) . ': ' . $style . ' !important;';
}, array_keys($data[$type]), $data[$type]);
return $styles;
return implode('', $styles);
}
function translateCSSAttribute($attribute) {