Refactors Newsletters as per @badshark's comments
This commit is contained in:
@ -1,49 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
use MailPoet\Newsletter\Blocks\Renderer as BlocksRenderer;
|
|
||||||
|
|
||||||
class Button {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$blocksRenderer = new Renderer();
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_button mailpoet_padded" valign = "top" >
|
|
||||||
<div>
|
|
||||||
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
||||||
<tr>
|
|
||||||
<td align="' . $element['styles']['block']['textAlign'] . '">
|
|
||||||
<!--[if mso]>
|
|
||||||
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
|
|
||||||
xmlns:w="urn:schemas-microsoft-com:office:word"
|
|
||||||
href="' . $element['url'] . '"
|
|
||||||
style="height:' . $element['styles']['block']['lineHeight'] . ';
|
|
||||||
width:' . $element['styles']['block']['width'] . ';
|
|
||||||
v-text-anchor:middle;"
|
|
||||||
arcsize="' . round($element['styles']['block']['borderRadius'] / $element['styles']['block']['lineHeight'] * 100) . '%"
|
|
||||||
strokecolor="' . $element['styles']['block']['borderColor'] . '"
|
|
||||||
fillcolor="' . $element['styles']['block']['backgroundColor'] . '">
|
|
||||||
<w:anchorlock/>
|
|
||||||
<center style="color:' . $element['styles']['block']['fontColor'] . ';
|
|
||||||
font-family:' . $element['styles']['block']['fontFamily'] . ';
|
|
||||||
font-size:' . $element['styles']['block']['fontSize'] . ';
|
|
||||||
font-weight:bold;">' . $element['text'] . '
|
|
||||||
</center>
|
|
||||||
</v:roundrect>
|
|
||||||
<![endif]-->
|
|
||||||
<a class="mailpoet_button"
|
|
||||||
href="' . $element['url'] . '"
|
|
||||||
style="display:inline-block;text-align:center;text-decoration:none;-webkit-text-size-adjust:none;mso-hide:all;' . $blocksRenderer->getBlockStyles($element, array('textAlign')) . '"> ' . $element['text'] . '
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Divider {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_divider mailpoet_padded" style="background-color: ' . $element['styles']['block']['backgroundColor'] . '; padding: ' . $element['styles']['block']['padding'] . ' 0;" valign="top">
|
|
||||||
<table width="100%">
|
|
||||||
<tr>
|
|
||||||
<td style="border-top-width: ' . $element['styles']['block']['borderWidth'] . ';
|
|
||||||
border-top-style: ' . $element['styles']['block']['borderStyle'] . ';
|
|
||||||
border-top-color: ' . $element['styles']['block']['borderColor'] . ';">
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Footer {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$blocksRenderer = new Renderer();
|
|
||||||
|
|
||||||
// apply link styles
|
|
||||||
if(isset($element['styles']['link'])) {
|
|
||||||
$element['text'] = str_replace('<a', '<a style="' . $blocksRenderer->getStyles($element['styles'], 'link') . '"', $element['text']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply text styles
|
|
||||||
if(isset($element['styles']['link'])) {
|
|
||||||
$element['text'] = str_replace('<p', '<p style="' . $blocksRenderer->getStyles($element['styles'], 'text') . '"', $element['text']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_footer" style="' . $blocksRenderer->getStyles($element['styles'], 'block') . '" valign="top">
|
|
||||||
<div>' . $element['text'] . '</div>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Header {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$blocksRenderer = new Renderer();
|
|
||||||
|
|
||||||
// apply link styles
|
|
||||||
if(isset($element['styles']['link'])) {
|
|
||||||
$element['text'] = str_replace('<a', '<a style="' . $blocksRenderer->getStyles($element['styles'], 'link') . '"', $element['text']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// apply text styles
|
|
||||||
if(isset($element['styles']['link'])) {
|
|
||||||
$element['text'] = str_replace('<p', '<p style="' . $blocksRenderer->getStyles($element['styles'], 'text') . '"', $element['text']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_header" style="' . $blocksRenderer->getBlockStyles($element) . '" valign="top">
|
|
||||||
<div>' . $element['text'] . '</div>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
use MailPoet\Newsletter\Blocks\Renderer as BlocksRenderer;
|
|
||||||
|
|
||||||
class Image {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$blocksRenderer = new Renderer();
|
|
||||||
|
|
||||||
$element['width'] = (int) $element['width'];
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_image ' . (($element['padded'] === true) ? "mailpoet_padded" : "") . '" style="' . $blocksRenderer->getBlockStyles($element) . '" valign="top">
|
|
||||||
<img style="top:0; left:0; height: auto; width:100%;"
|
|
||||||
src="' . $element['src'] . '"
|
|
||||||
width="' . (($element['padded'] === true) ? $element['width'] - (20 * 2) : $element['width']) . '">
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Renderer {
|
|
||||||
|
|
||||||
public $typeFace = array(
|
|
||||||
'Arial' => "Arial, 'Helvetica Neue', Helvetica, sans-serif",
|
|
||||||
'Comic Sans MS' => "'Comic Sans MS', 'Marker Felt-Thin', Arial, sans-serif",
|
|
||||||
'Courier New' => "'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace",
|
|
||||||
'Georgia' => "Georgia, Times, 'Times New Roman', serif",
|
|
||||||
'Lucida' => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
|
|
||||||
'Tahoma' => "Tahoma, Verdana, Segoe, sans-serif",
|
|
||||||
'Times New Roman' => "'Times New Roman', Times, Baskerville, Georgia, serif",
|
|
||||||
'Trebuchet MS' => "'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif",
|
|
||||||
'Verdana' => "Verdana, Geneva, sans-serif"
|
|
||||||
);
|
|
||||||
|
|
||||||
public $cssAtributesTable = array(
|
|
||||||
'backgroundColor' => 'background-color',
|
|
||||||
'fontColor' => 'color',
|
|
||||||
'fontFamily' => 'font-family',
|
|
||||||
'textDecoration' => 'text-decoration',
|
|
||||||
'textAlign' => 'text-align',
|
|
||||||
'fontSize' => 'font-size',
|
|
||||||
'borderWidth' => 'border-width',
|
|
||||||
'borderStyle' => 'border-style',
|
|
||||||
'borderColor' => 'border-color',
|
|
||||||
'borderRadius' => 'border-radius',
|
|
||||||
'lineHeight' => 'line-height'
|
|
||||||
);
|
|
||||||
|
|
||||||
function render($data, $column = null) {
|
|
||||||
array_map(function($block) use(&$blockContent, &$columns) {
|
|
||||||
$blockContent .= $this->createElementFromBlockType($block);
|
|
||||||
if(isset($block['blocks'])) {
|
|
||||||
$blockContent = $this->render($block);
|
|
||||||
}
|
|
||||||
// vertical orientation denotes column container
|
|
||||||
if($block['type'] === 'container' && $block['orientation'] === 'vertical') {
|
|
||||||
$columns[] = $blockContent;
|
|
||||||
}
|
|
||||||
}, $data['blocks']);
|
|
||||||
|
|
||||||
return (isset($columns)) ? $columns : $blockContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createElementFromBlockType($block) {
|
|
||||||
$blockClass = __NAMESPACE__ . '\\' . ucfirst($block['type']);
|
|
||||||
return (class_exists($blockClass)) ? $blockClass::render($block) : '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function getBlockStyles($element, $ignore = false) {
|
|
||||||
if(!isset($element['styles']['block'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->getStyles($element['styles'], 'block', $ignore);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;';
|
|
||||||
}
|
|
||||||
}, array_keys($data[$type]), $data[$type]);
|
|
||||||
|
|
||||||
return $styles;
|
|
||||||
}
|
|
||||||
|
|
||||||
function translateCSSAttribute($attribute) {
|
|
||||||
return (isset($this->cssAtributesTable[$attribute])) ? $this->cssAtributesTable[$attribute] : $attribute;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Social {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
$iconsBlock = '';
|
|
||||||
|
|
||||||
if(is_array($element['icons'])) {
|
|
||||||
foreach ($element['icons'] as $icon) {
|
|
||||||
$iconsBlock .= '
|
|
||||||
<a href="' . $icon['link'] . '">
|
|
||||||
<img src="' . $icon['image'] . '" width = "32" height = "32" style="width: 32px; height: 32px;" alt="' . $icon['iconType'] . '">
|
|
||||||
</a>
|
|
||||||
<img src="http://mp3.mailpoet.net/spacer.gif" width = "10" height = "1" style=" width: 10px; height: 1px;">';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_social" valign="top">
|
|
||||||
<div class="mailpoet_social-icon mailpoet_padded">' . $iconsBlock . ' </div>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
|
||||||
|
|
||||||
class Text {
|
|
||||||
|
|
||||||
static function render($element) {
|
|
||||||
// convert <blockquote> elements to tables
|
|
||||||
$blockquoteTemplate = '<table cellpadding="0" cellspacing="0" border="0" class="mailpoet_blockquote">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td valign="top">
|
|
||||||
$1
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<br>';
|
|
||||||
$element['text'] = preg_replace('/<blockquote>(.*?)<\/blockquote>/s', $blockquoteTemplate, $element['text']);
|
|
||||||
|
|
||||||
// add line breaks after tags
|
|
||||||
$element['text'] = preg_replace('/(<\/(ul|ol|h\d)>)/', '$1<br>', $element['text']);
|
|
||||||
|
|
||||||
$element['text'] = self::removeEmptyHTMLTags($element['text']);
|
|
||||||
|
|
||||||
// convert empty <p> tags to line breaks
|
|
||||||
$element['text'] = preg_replace('/<p(?:.+style=\".*?\")?><\/p>/', '<br>', $element['text']);
|
|
||||||
|
|
||||||
// convert <p> to <span>
|
|
||||||
$element['text'] = preg_replace('/<p>(.*?)<\/p>/', '<table cellpadding="0" cellspacing="0" border="0"><tr><td><span class="paragraph">$1</span></td></tr></table>', $element['text']);
|
|
||||||
$element['text'] = preg_replace('/<p(.+style=\".*?\")?>(.*?)<\/p>/', '<table cellpadding="0" cellspacing="0" border="0"><tr><td $1><span class="paragraph">$2</span></td></tr></table>', $element['text']);
|
|
||||||
|
|
||||||
// remove the last break line
|
|
||||||
$element['text'] = preg_replace('/<br>([^<br>]*)$/s', '', $element['text']);
|
|
||||||
|
|
||||||
$template = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_col mailpoet_text mailpoet_padded" valign="top">' . $element['text'] . ' </td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $template;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function removeEmptyHTMLTags($html) {
|
|
||||||
$pattern = <<<'EOD'
|
|
||||||
~
|
|
||||||
<
|
|
||||||
(?:
|
|
||||||
!--[^-]*(?:-(?!->)[^-]*)*-->[^<]*(*SKIP)(*F) # skip comments
|
|
||||||
|
|
|
||||||
( # group 1
|
|
||||||
(span|em|strong) # tag name in group 2
|
|
||||||
[^"'>]* #'"# all that is not a quote or a closing angle bracket
|
|
||||||
(?: # quoted attributes
|
|
||||||
"[^\\"]*(?:\\.[^\\"]*)*+" [^"'>]* #'"# double quote
|
|
||||||
|
|
|
||||||
'[^\\']*(?:\\.[^\\']*)*+' [^"'>]* #'"# single quote
|
|
||||||
)*+
|
|
||||||
>
|
|
||||||
\s*
|
|
||||||
(?:
|
|
||||||
<!--[^-]*(?:-(?!->)[^-]*)*+--> \s* # html comments
|
|
||||||
|
|
|
||||||
<(?1) \s* # recursion with the group 1
|
|
||||||
)*+
|
|
||||||
</\2> # closing tag
|
|
||||||
) # end of the group 1
|
|
||||||
)
|
|
||||||
~sxi
|
|
||||||
EOD;
|
|
||||||
|
|
||||||
return preg_replace($pattern, '', $html);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Columns;
|
|
||||||
|
|
||||||
class Renderer {
|
|
||||||
|
|
||||||
public $columnWidths = array(
|
|
||||||
1 => 600,
|
|
||||||
2 => 300,
|
|
||||||
3 => 200
|
|
||||||
);
|
|
||||||
|
|
||||||
public $columnClasses = array(
|
|
||||||
1 => 'mailpoet_col-one',
|
|
||||||
2 => 'mailpoet_col-two',
|
|
||||||
3 => 'mailpoet_col-three'
|
|
||||||
);
|
|
||||||
|
|
||||||
function render($columnsCount, $columnsData) {
|
|
||||||
|
|
||||||
$columnWidth = $this->columnWidths[$columnsCount];
|
|
||||||
$columnClass = $this->columnClasses[$columnsCount];
|
|
||||||
|
|
||||||
// open column container
|
|
||||||
$columnContainerTemplate = '
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_content" align="left" style="border-collapse: collapse;">
|
|
||||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td class="mailpoet_cols-wrapper" style="border-collapse: collapse; padding-left: 0px; padding-right: 0px;">
|
|
||||||
<!--[if mso]>
|
|
||||||
<table border="0" width="100%" cellpadding="0" cellspacing="0">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top">
|
|
||||||
<![endif]-->';
|
|
||||||
|
|
||||||
$columnOpenTemplate = '
|
|
||||||
<table width="' . $columnWidth . '"
|
|
||||||
border="0" cellpadding="0" cellspacing="0" align="left" class="mailpoet_force-row ' . $columnClass . ' mailpoet_col"
|
|
||||||
style="width: ' . $columnWidth . 'px; border-spacing: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
|
|
||||||
table-layout: fixed; margin-left: auto; margin-right: auto;" bgcolor="#999999">
|
|
||||||
<tbody>';
|
|
||||||
|
|
||||||
$columnCloseTemplate = '
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<!--[if mso]>
|
|
||||||
</td>
|
|
||||||
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top">
|
|
||||||
<![endif]-->';
|
|
||||||
|
|
||||||
foreach ($columnsData as $index => $columnData) {
|
|
||||||
$index++;
|
|
||||||
$columnContainerTemplate .= $columnOpenTemplate . $columnData;
|
|
||||||
if($columnsCount > 1 && $index != $columnsCount) {
|
|
||||||
$columnContainerTemplate .= $columnCloseTemplate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// close column container
|
|
||||||
$columnContainerTemplate .= '
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<!--[if mso]>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<![endif]-->
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</td>
|
|
||||||
</tr>';
|
|
||||||
|
|
||||||
return $columnContainerTemplate;
|
|
||||||
}
|
|
||||||
}
|
|
49
lib/Newsletter/Renderer/Blocks/Button.php
Normal file
49
lib/Newsletter/Renderer/Blocks/Button.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||||
|
|
||||||
|
class Button {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$stylesHelper = new StylesHelper();
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_button mailpoet_padded" valign = "top" >
|
||||||
|
<div>
|
||||||
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
||||||
|
<tr>
|
||||||
|
<td align="' . $element['styles']['block']['textAlign'] . '">
|
||||||
|
<!--[if mso]>
|
||||||
|
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
|
||||||
|
xmlns:w="urn:schemas-microsoft-com:office:word"
|
||||||
|
href="' . $element['url'] . '"
|
||||||
|
style="height:' . $element['styles']['block']['lineHeight'] . ';
|
||||||
|
width:' . $element['styles']['block']['width'] . ';
|
||||||
|
v-text-anchor:middle;"
|
||||||
|
arcsize="' . round($element['styles']['block']['borderRadius'] / $element['styles']['block']['lineHeight'] * 100) . '%"
|
||||||
|
strokecolor="' . $element['styles']['block']['borderColor'] . '"
|
||||||
|
fillcolor="' . $element['styles']['block']['backgroundColor'] . '">
|
||||||
|
<w:anchorlock/>
|
||||||
|
<center style="color:' . $element['styles']['block']['fontColor'] . ';
|
||||||
|
font-family:' . $element['styles']['block']['fontFamily'] . ';
|
||||||
|
font-size:' . $element['styles']['block']['fontSize'] . ';
|
||||||
|
font-weight:bold;">' . $element['text'] . '
|
||||||
|
</center>
|
||||||
|
</v:roundrect>
|
||||||
|
<![endif]-->
|
||||||
|
<a class="mailpoet_button"
|
||||||
|
href="' . $element['url'] . '"
|
||||||
|
style="display:inline-block;text-align:center;text-decoration:none;-webkit-text-size-adjust:none;mso-hide:all;' . $stylesHelper->getBlockStyles($element, array('textAlign')) . '"> ' . $element['text'] . '
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
lib/Newsletter/Renderer/Blocks/Divider.php
Normal file
25
lib/Newsletter/Renderer/Blocks/Divider.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
class Divider {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_divider mailpoet_padded"
|
||||||
|
style="background-color: ' . $element['styles']['block']['backgroundColor'] . '; padding: ' . $element['styles']['block']['padding'] . ' 0;"
|
||||||
|
valign="top">
|
||||||
|
<table width="100%">
|
||||||
|
<tr>
|
||||||
|
<td style="border-top-width: ' . $element['styles']['block']['borderWidth'] . ';
|
||||||
|
border-top-style: ' . $element['styles']['block']['borderStyle'] . ';
|
||||||
|
border-top-color: ' . $element['styles']['block']['borderColor'] . ';">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
lib/Newsletter/Renderer/Blocks/Footer.php
Normal file
32
lib/Newsletter/Renderer/Blocks/Footer.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||||
|
|
||||||
|
class Footer {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$stylesHelper = new StylesHelper();
|
||||||
|
|
||||||
|
// apply link styles
|
||||||
|
if(isset($element['styles']['link'])) {
|
||||||
|
$element['text'] = str_replace('<a', '<a style="' . $stylesHelper->getStyles($element['styles'], 'link') . '"', $element['text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply text styles
|
||||||
|
if(isset($element['styles']['link'])) {
|
||||||
|
$element['text'] = str_replace('<p', '<p style="' . $stylesHelper->getStyles($element['styles'], 'text') . '"', $element['text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_footer"
|
||||||
|
style="' . $stylesHelper->getStyles($element['styles'], 'block') . '"
|
||||||
|
valign="top">
|
||||||
|
<div>' . $element['text'] . '</div>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
lib/Newsletter/Renderer/Blocks/Header.php
Normal file
32
lib/Newsletter/Renderer/Blocks/Header.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||||
|
|
||||||
|
class Header {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$stylesHelper = new StylesHelper();
|
||||||
|
|
||||||
|
// apply link styles
|
||||||
|
if(isset($element['styles']['link'])) {
|
||||||
|
$element['text'] = str_replace('<a', '<a style="' . $stylesHelper->getStyles($element['styles'], 'link') . '"', $element['text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply text styles
|
||||||
|
if(isset($element['styles']['link'])) {
|
||||||
|
$element['text'] = str_replace('<p', '<p style="' . $stylesHelper->getStyles($element['styles'], 'text') . '"', $element['text']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_header"
|
||||||
|
style="' . $stylesHelper->getBlockStyles($element) . '"
|
||||||
|
valign="top">
|
||||||
|
<div>' . $element['text'] . '</div>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
lib/Newsletter/Renderer/Blocks/Image.php
Normal file
26
lib/Newsletter/Renderer/Blocks/Image.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||||
|
|
||||||
|
class Image {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$stylesHelper = new StylesHelper();
|
||||||
|
|
||||||
|
$element['width'] = (int) $element['width'];
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_image ' . (($element['padded'] === true) ? "mailpoet_padded" : "") . '"
|
||||||
|
style="' . $stylesHelper->getBlockStyles($element) . '"
|
||||||
|
valign="top">
|
||||||
|
<img style="top:0; left:0; height: auto; width:100%;"
|
||||||
|
src="' . $element['src'] . '"
|
||||||
|
width="' . (($element['padded'] === true) ? $element['width'] - (20 * 2) : $element['width']) . '">
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
lib/Newsletter/Renderer/Blocks/Renderer.php
Normal file
25
lib/Newsletter/Renderer/Blocks/Renderer.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
class Renderer {
|
||||||
|
|
||||||
|
function render($data, $column = null) {
|
||||||
|
array_map(function ($block) use (&$blockContent, &$columns) {
|
||||||
|
$blockContent .= $this->createElementFromBlockType($block);
|
||||||
|
if(isset($block['blocks'])) {
|
||||||
|
$blockContent = $this->render($block);
|
||||||
|
}
|
||||||
|
// vertical orientation denotes column container
|
||||||
|
if($block['type'] === 'container' && $block['orientation'] === 'vertical') {
|
||||||
|
$columns[] = $blockContent;
|
||||||
|
}
|
||||||
|
}, $data['blocks']);
|
||||||
|
|
||||||
|
return (isset($columns)) ? $columns : $blockContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createElementFromBlockType($block) {
|
||||||
|
$blockClass = __NAMESPACE__ . '\\' . ucfirst($block['type']);
|
||||||
|
return (class_exists($blockClass)) ? $blockClass::render($block) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
lib/Newsletter/Renderer/Blocks/Social.php
Normal file
28
lib/Newsletter/Renderer/Blocks/Social.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
class Social {
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$iconsBlock = '';
|
||||||
|
|
||||||
|
if(is_array($element['icons'])) {
|
||||||
|
foreach ($element['icons'] as $icon) {
|
||||||
|
$iconsBlock .= '
|
||||||
|
<a href="' . $icon['link'] . '">
|
||||||
|
<img src="' . $icon['image'] . '" width = "32" height = "32" style="width: 32px; height: 32px;" alt="' . $icon['iconType'] . '">
|
||||||
|
</a>
|
||||||
|
<img src="http://mp3.mailpoet.net/spacer.gif" width = "10" height = "1" style=" width: 10px; height: 1px;">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_social" valign="top">
|
||||||
|
<div class="mailpoet_social-icon mailpoet_padded">' . $iconsBlock . ' </div>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
<?php namespace MailPoet\Newsletter\Blocks;
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
use MailPoet\Newsletter\Blocks\Renderer as BlocksRenderer;
|
use MailPoet\Newsletter\Renderer\StylesHelper;
|
||||||
|
|
||||||
class Spacer {
|
class Spacer {
|
||||||
|
|
||||||
static function render($element) {
|
static function render($element) {
|
||||||
|
|
||||||
$blocksRenderer = new Renderer();
|
$stylesHelper = new StylesHelper();
|
||||||
|
|
||||||
// if the parent container (column) has background set and the divider element has a transparent background,
|
// if the parent container (column) has background set and the divider element has a transparent background,
|
||||||
// it will assume the newsletter background, not that of the parent container
|
// it will assume the newsletter background, not that of the parent container
|
||||||
@ -15,9 +15,9 @@ class Spacer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$template = '
|
$template = '
|
||||||
<tr>
|
<tr>
|
||||||
<td class="mailpoet_col mailpoet_spacer" style="' . $blocksRenderer->getBlockStyles($element) . '" valign="top"> </td>
|
<td class="mailpoet_col mailpoet_spacer" style="' . $stylesHelper->getBlockStyles($element) . '" valign="top"> </td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
116
lib/Newsletter/Renderer/Blocks/Text.php
Normal file
116
lib/Newsletter/Renderer/Blocks/Text.php
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
|
||||||
|
|
||||||
|
class Text {
|
||||||
|
|
||||||
|
static $typeFace = array(
|
||||||
|
'Arial' => "Arial, 'Helvetica Neue', Helvetica, sans-serif",
|
||||||
|
'Comic Sans MS' => "'Comic Sans MS', 'Marker Felt-Thin', Arial, sans-serif",
|
||||||
|
'Courier New' => "'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace",
|
||||||
|
'Georgia' => "Georgia, Times, 'Times New Roman', serif",
|
||||||
|
'Lucida' => "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
|
||||||
|
'Tahoma' => "Tahoma, Verdana, Segoe, sans-serif",
|
||||||
|
'Times New Roman' => "'Times New Roman', Times, Baskerville, Georgia, serif",
|
||||||
|
'Trebuchet MS' => "'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif",
|
||||||
|
'Verdana' => "Verdana, Geneva, sans-serif"
|
||||||
|
);
|
||||||
|
|
||||||
|
static function render($element) {
|
||||||
|
$html = $element['text'];
|
||||||
|
|
||||||
|
$html = self::convertBlockquotesToTables($html);
|
||||||
|
$html = self::addLineBreakAfterTags($html);
|
||||||
|
$html = self::removeEmptyTags($html);
|
||||||
|
$html = self::convertEmptyParagraphsToLineBreaks($html);
|
||||||
|
$html = self::convertParagraphsToTables($html);
|
||||||
|
$html = self::removeLastBreakLine($html);
|
||||||
|
|
||||||
|
$template = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_col mailpoet_text mailpoet_padded" valign="top">' . $html . ' </td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function removeLastBreakLine($html) {
|
||||||
|
return preg_replace('/<br>([^<br>]*)$/s', '', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function convertParagraphsToTables($html) {
|
||||||
|
$html = preg_replace('/<p>(.*?)<\/p>/', '
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<span class="paragraph">
|
||||||
|
$1
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>', $html);
|
||||||
|
|
||||||
|
return preg_replace('/<p(.+style=\".*?\")?>(.*?)<\/p>/', '
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0">
|
||||||
|
<tr>
|
||||||
|
<td $1>
|
||||||
|
<span class="paragraph">
|
||||||
|
$2
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function convertEmptyParagraphsToLineBreaks($html) {
|
||||||
|
return preg_replace('/<p(?:.+style=\".*?\")?><\/p>/', '<br>', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function addLineBreakAfterTags($html) {
|
||||||
|
return preg_replace('/(<\/(ul|ol|h\d)>)/', '$1<br>', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function convertBlockquotesToTables($html) {
|
||||||
|
$template = '
|
||||||
|
<table cellpadding="0" cellspacing="0" border="0" class="mailpoet_blockquote">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td valign="top">$1</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<br>';
|
||||||
|
|
||||||
|
return preg_replace('/<blockquote>(.*?)<\/blockquote>/s', $template, $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function removeEmptyTags($html) {
|
||||||
|
$pattern = <<<'EOD'
|
||||||
|
~
|
||||||
|
<
|
||||||
|
(?:
|
||||||
|
!--[^-]*(?:-(?!->)[^-]*)*-->[^<]*(*SKIP)(*F) # skip comments
|
||||||
|
|
|
||||||
|
( # group 1
|
||||||
|
(span|em|strong) # tag name in group 2
|
||||||
|
[^"'>]* #'"# all that is not a quote or a closing angle bracket
|
||||||
|
(?: # quoted attributes
|
||||||
|
"[^\\"]*(?:\\.[^\\"]*)*+" [^"'>]* #'"# double quote
|
||||||
|
|
|
||||||
|
'[^\\']*(?:\\.[^\\']*)*+' [^"'>]* #'"# single quote
|
||||||
|
)*+
|
||||||
|
>
|
||||||
|
\s*
|
||||||
|
(?:
|
||||||
|
<!--[^-]*(?:-(?!->)[^-]*)*+--> \s* # html comments
|
||||||
|
|
|
||||||
|
<(?1) \s* # recursion with the group 1
|
||||||
|
)*+
|
||||||
|
</\2> # closing tag
|
||||||
|
) # end of the group 1
|
||||||
|
)
|
||||||
|
~sxi
|
||||||
|
EOD;
|
||||||
|
|
||||||
|
return preg_replace($pattern, '', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
78
lib/Newsletter/Renderer/Columns/Renderer.php
Normal file
78
lib/Newsletter/Renderer/Columns/Renderer.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer\Columns;
|
||||||
|
|
||||||
|
class Renderer {
|
||||||
|
|
||||||
|
public $columnWidths = array(
|
||||||
|
1 => 600,
|
||||||
|
2 => 300,
|
||||||
|
3 => 200
|
||||||
|
);
|
||||||
|
|
||||||
|
public $columnClasses = array(
|
||||||
|
1 => 'mailpoet_col-one',
|
||||||
|
2 => 'mailpoet_col-two',
|
||||||
|
3 => 'mailpoet_col-three'
|
||||||
|
);
|
||||||
|
|
||||||
|
function render($columnsCount, $columnsData) {
|
||||||
|
|
||||||
|
$columnWidth = $this->columnWidths[$columnsCount];
|
||||||
|
$columnClass = $this->columnClasses[$columnsCount];
|
||||||
|
|
||||||
|
// open column container
|
||||||
|
$columnContainerTemplate = '
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_content" align="left" style="border-collapse: collapse;">
|
||||||
|
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="mailpoet_cols-wrapper" style="border-collapse: collapse; padding-left: 0px; padding-right: 0px;">
|
||||||
|
<!--[if mso]>
|
||||||
|
<table border="0" width="100%" cellpadding="0" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top">
|
||||||
|
<![endif]-->';
|
||||||
|
|
||||||
|
$columnOpenTemplate = '
|
||||||
|
<table width="' . $columnWidth . '"
|
||||||
|
border="0" cellpadding="0" cellspacing="0" align="left" class="mailpoet_force-row ' . $columnClass . ' mailpoet_col"
|
||||||
|
style="width: ' . $columnWidth . 'px; border-spacing: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
|
||||||
|
table-layout: fixed; margin-left: auto; margin-right: auto;" bgcolor="#999999">
|
||||||
|
<tbody>';
|
||||||
|
|
||||||
|
$columnCloseTemplate = '
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<!--[if mso]>
|
||||||
|
</td>
|
||||||
|
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top">
|
||||||
|
<![endif]-->';
|
||||||
|
|
||||||
|
foreach ($columnsData as $index => $columnData) {
|
||||||
|
$index++;
|
||||||
|
$columnContainerTemplate .= $columnOpenTemplate . $columnData;
|
||||||
|
if($columnsCount > 1 && $index != $columnsCount) {
|
||||||
|
$columnContainerTemplate .= $columnCloseTemplate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// close column container
|
||||||
|
$columnContainerTemplate .= '
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<!--[if mso]>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<![endif]-->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>';
|
||||||
|
|
||||||
|
return $columnContainerTemplate;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace MailPoet\Newsletter;
|
namespace MailPoet\Newsletter\Renderer;
|
||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
@ -9,6 +9,7 @@ class Renderer {
|
|||||||
function __construct($newsletterData) {
|
function __construct($newsletterData) {
|
||||||
$this->blocksRenderer = new Blocks\Renderer();
|
$this->blocksRenderer = new Blocks\Renderer();
|
||||||
$this->columnsRenderer = new Columns\Renderer();
|
$this->columnsRenderer = new Columns\Renderer();
|
||||||
|
$this->stylesHelper = new StylesHelper();
|
||||||
$this->DOMQuery = new \pQuery();
|
$this->DOMQuery = new \pQuery();
|
||||||
$this->CSSInliner = new \MailPoet\Util\CSS();
|
$this->CSSInliner = new \MailPoet\Util\CSS();
|
||||||
$this->data = $newsletterData;
|
$this->data = $newsletterData;
|
||||||
@ -29,7 +30,7 @@ class Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderContent($content) {
|
function renderContent($content) {
|
||||||
array_map(function($contentBlock) use(&$newsletterContent) {
|
array_map(function ($contentBlock) use (&$newsletterContent) {
|
||||||
$columnCount = count($contentBlock['blocks']);
|
$columnCount = count($contentBlock['blocks']);
|
||||||
$columnData = $this->blocksRenderer->render($contentBlock);
|
$columnData = $this->blocksRenderer->render($contentBlock);
|
||||||
$newsletterContent .= $this->columnsRenderer->render($columnCount, $columnData);
|
$newsletterContent .= $this->columnsRenderer->render($columnCount, $columnData);
|
||||||
@ -56,7 +57,7 @@ class Renderer {
|
|||||||
}
|
}
|
||||||
$newsletterStyles .= $selector . '{' . PHP_EOL;
|
$newsletterStyles .= $selector . '{' . PHP_EOL;
|
||||||
foreach ($style as $attribute => $individualStyle) {
|
foreach ($style as $attribute => $individualStyle) {
|
||||||
$newsletterStyles .= $this->blocksRenderer->translateCSSAttribute($attribute) . ':' . $individualStyle . ';' . PHP_EOL;
|
$newsletterStyles .= $this->stylesHelper->translateCSSAttribute($attribute) . ':' . $individualStyle . ';' . PHP_EOL;
|
||||||
}
|
}
|
||||||
$newsletterStyles .= '}' . PHP_EOL;
|
$newsletterStyles .= '}' . PHP_EOL;
|
||||||
}
|
}
|
||||||
@ -65,7 +66,7 @@ class Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderTemplate($template, $data) {
|
function renderTemplate($template, $data) {
|
||||||
return preg_replace_callback('/{{\w+}}/', function($matches) use(&$data) {
|
return preg_replace_callback('/{{\w+}}/', function ($matches) use (&$data) {
|
||||||
return array_shift($data);
|
return array_shift($data);
|
||||||
}, $template);
|
}, $template);
|
||||||
}
|
}
|
40
lib/Newsletter/Renderer/StylesHelper.php
Normal file
40
lib/Newsletter/Renderer/StylesHelper.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php namespace MailPoet\Newsletter\Renderer;
|
||||||
|
|
||||||
|
class StylesHelper {
|
||||||
|
|
||||||
|
public $cssAtributesTable = array(
|
||||||
|
'backgroundColor' => 'background-color',
|
||||||
|
'fontColor' => 'color',
|
||||||
|
'fontFamily' => 'font-family',
|
||||||
|
'textDecoration' => 'text-decoration',
|
||||||
|
'textAlign' => 'text-align',
|
||||||
|
'fontSize' => 'font-size',
|
||||||
|
'borderWidth' => 'border-width',
|
||||||
|
'borderStyle' => 'border-style',
|
||||||
|
'borderColor' => 'border-color',
|
||||||
|
'borderRadius' => 'border-radius',
|
||||||
|
'lineHeight' => 'line-height'
|
||||||
|
);
|
||||||
|
|
||||||
|
function getBlockStyles($element, $ignore = false) {
|
||||||
|
if(!isset($element['styles']['block'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getStyles($element['styles'], 'block', $ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;';
|
||||||
|
}
|
||||||
|
}, array_keys($data[$type]), $data[$type]);
|
||||||
|
|
||||||
|
return $styles;
|
||||||
|
}
|
||||||
|
|
||||||
|
function translateCSSAttribute($attribute) {
|
||||||
|
return (array_key_exists($attribute, $this->cssAtributesTable)) ? $this->cssAtributesTable[$attribute] : $attribute;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user