Indented HTML code as per Marco's comment

This commit is contained in:
MrCasual
2015-09-10 20:32:12 -04:00
parent 42c5885cbd
commit 7e4bd0d044
9 changed files with 123 additions and 105 deletions

View File

@ -5,35 +5,41 @@ use MailPoet\Newsletter\Blocks\Renderer as BlocksRenderer;
class Button { class Button {
static function render($element) { static function render($element) {
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_button mailpoet_padded" valign = "top" > <tr>
<div> <td class="mailpoet_col mailpoet_button mailpoet_padded" valign = "top" >
<table width="100%" cellpadding="0" cellspacing="0" border="0"> <div>
<tr> <table width="100%" cellpadding="0" cellspacing="0" border="0">
<td align="' . $element['styles']['block']['textAlign'] . '"> <tr>
<!--[if mso]> <td align="' . $element['styles']['block']['textAlign'] . '">
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" <!--[if mso]>
xmlns:w="urn:schemas-microsoft-com:office:word" <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
href="' . $element['url'] . '" xmlns:w="urn:schemas-microsoft-com:office:word"
style="height:' . $element['styles']['block']['lineHeight'] . ';width:' . $element['styles']['block']['width'] . ';v-text-anchor:middle;" href="' . $element['url'] . '"
arcsize="' . round($element['styles']['block']['borderRadius'] / $element['styles']['block']['lineHeight'] * 100) . '%" strokecolor="' . $element['styles']['block']['borderColor'] . '" style="height:' . $element['styles']['block']['lineHeight'] . ';
fillcolor="' . $element['styles']['block']['backgroundColor'] . '"> width:' . $element['styles']['block']['width'] . ';
<w:anchorlock/> v-text-anchor:middle;"
<center style="color:' . $element['styles']['block']['fontColor'] . ';font-family:' . $element['styles']['block']['fontFamily'] . ';font-size:' . $element['styles']['block']['fontSize'] . ';font-weight:bold;"> arcsize="' . round($element['styles']['block']['borderRadius'] / $element['styles']['block']['lineHeight'] * 100) . '%"
' . $element['text'] . ' strokecolor="' . $element['styles']['block']['borderColor'] . '"
</center> fillcolor="' . $element['styles']['block']['backgroundColor'] . '">
</v:roundrect> <w:anchorlock/>
<![endif]--> <center style="color:' . $element['styles']['block']['fontColor'] . ';
<a class="mailpoet_button" href="' . $element['url'] . '" font-family:' . $element['styles']['block']['fontFamily'] . ';
style="display:inline-block;text-align:center;text-decoration:none;-webkit-text-size-adjust:none;mso-hide:all;' . BlocksRenderer::getBlockStyles($element, array('textAlign')) . '"> font-size:' . $element['styles']['block']['fontSize'] . ';
' . $element['text'] . ' font-weight:bold;">' . $element['text'] . '
</a> </center>
</td> </v:roundrect>
</tr> <![endif]-->
</table> <a class="mailpoet_button"
</div> href="' . $element['url'] . '"
</td> 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'] . '
</tr>'; </a>
</td>
</tr>
</table>
</div>
</td>
</tr>';
return $template; return $template;
} }

View File

@ -3,18 +3,19 @@
class Divider { class Divider {
static function render($element) { static function render($element) {
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_divider mailpoet_padded" style="background-color: ' . $element['styles']['block']['backgroundColor'] . '; padding: ' . $element['styles']['block']['padding'] . ' 0;" valign="top"> <tr>
<table width="100%"> <td class="mailpoet_col mailpoet_divider mailpoet_padded" style="background-color: ' . $element['styles']['block']['backgroundColor'] . '; padding: ' . $element['styles']['block']['padding'] . ' 0;" valign="top">
<tr> <table width="100%">
<td style="border-top-width: ' . $element['styles']['block']['borderWidth'] . '; <tr>
border-top-style: ' . $element['styles']['block']['borderStyle'] . '; <td style="border-top-width: ' . $element['styles']['block']['borderWidth'] . ';
border-top-color: ' . $element['styles']['block']['borderColor'] . ';"> border-top-style: ' . $element['styles']['block']['borderStyle'] . ';
</td> border-top-color: ' . $element['styles']['block']['borderColor'] . ';">
</tr> </td>
</table> </tr>
</td> </table>
</tr>'; </td>
</tr>';
return $template; return $template;
} }

View File

@ -15,11 +15,12 @@ class Footer {
$element['text'] = str_replace('<p', '<p style="' . BlocksRenderer::getStyles($element['styles'], 'text') . '"', $element['text']); $element['text'] = str_replace('<p', '<p style="' . BlocksRenderer::getStyles($element['styles'], 'text') . '"', $element['text']);
} }
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_footer" style="' . BlocksRenderer::getStyles($element['styles'], 'block') . '" valign="top"> <tr>
<div>' . $element['text'] . '</div> <td class="mailpoet_col mailpoet_footer" style="' . BlocksRenderer::getStyles($element['styles'], 'block') . '" valign="top">
</td> <div>' . $element['text'] . '</div>
</tr>'; </td>
</tr>';
return $template; return $template;
} }

View File

@ -15,11 +15,12 @@ class Header {
$element['text'] = str_replace('<p', '<p style="' . BlocksRenderer::getStyles($element['styles'], 'text') . '"', $element['text']); $element['text'] = str_replace('<p', '<p style="' . BlocksRenderer::getStyles($element['styles'], 'text') . '"', $element['text']);
} }
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_header" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top"> <tr>
<div>' . $element['text'] . '</div> <td class="mailpoet_col mailpoet_header" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top">
</td> <div>' . $element['text'] . '</div>
</tr>'; </td>
</tr>';
return $template; return $template;
} }

View File

@ -7,11 +7,14 @@ class Image {
static function render($element) { static function render($element) {
$element['width'] = (int) $element['width']; $element['width'] = (int) $element['width'];
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_image ' . (($element['padded'] === true) ? "mailpoet_padded" : "") . '" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top"> <tr>
<img style="top:0; left:0; height: auto; width:100%;" src="' . $element['src'] . '" width="' . (($element['padded'] === true) ? $element['width'] - (20 * 2) : $element['width']) . '"> <td class="mailpoet_col mailpoet_image ' . (($element['padded'] === true) ? "mailpoet_padded" : "") . '" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top">
</td> <img style="top:0; left:0; height: auto; width:100%;"
</tr>'; src="' . $element['src'] . '"
width="' . (($element['padded'] === true) ? $element['width'] - (20 * 2) : $element['width']) . '">
</td>
</tr>';
return $template; return $template;
} }

View File

@ -9,13 +9,12 @@ class Social {
$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;">'; $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> $template = '
<td class="mailpoet_col mailpoet_social" valign="top"> <tr>
<div class="mailpoet_social-icon mailpoet_padded"> <td class="mailpoet_col mailpoet_social" valign="top">
' . $iconsBlock . ' <div class="mailpoet_social-icon mailpoet_padded">' . $iconsBlock . ' </div>
</div> </td>
</td> </tr>';
</tr>';
return $template; return $template;
} }

View File

@ -11,10 +11,10 @@ class Spacer {
unset($element['styles']['block']['backgroundColor']); unset($element['styles']['block']['backgroundColor']);
} }
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_spacer" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top"> <tr>
</td> <td class="mailpoet_col mailpoet_spacer" style="' . BlocksRenderer::getBlockStyles($element) . '" valign="top"> </td>
</tr>'; </tr>';
return $template; return $template;
} }

View File

@ -31,11 +31,10 @@ class Text {
// remove the last break line // remove the last break line
$element['text'] = preg_replace('/<br>([^<br>]*)$/s', '', $element['text']); $element['text'] = preg_replace('/<br>([^<br>]*)$/s', '', $element['text']);
$template = '<tr> $template = '
<td class="mailpoet_col mailpoet_text mailpoet_padded" valign="top"> <tr>
' . $element['text'] . ' <td class="mailpoet_col mailpoet_text mailpoet_padded" valign="top">' . $element['text'] . ' </td>
</td> </tr>';
</tr>';
return $template; return $template;
} }

View File

@ -17,24 +17,32 @@ class Renderer {
$columnClass = $columnClasses[$columnsCount]; $columnClass = $columnClasses[$columnsCount];
// open column container // open column container
$columnContainerTemplate = '<tr> $columnContainerTemplate = '
<td class="mailpoet_content" align="left" style="border-collapse: collapse;"> <tr>
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0"> <td class="mailpoet_content" align="left" style="border-collapse: collapse;">
<tbody> <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0">
<tr> <tbody>
<td class="mailpoet_cols-wrapper" style="border-collapse: collapse; padding-left: 0px; padding-right: 0px;"> <tr>
<!--[if mso]> <td class="mailpoet_cols-wrapper" style="border-collapse: collapse; padding-left: 0px; padding-right: 0px;">
<table border="0" width="100%" cellpadding="0" cellspacing="0"> <!--[if mso]>
<tbody> <table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr> <tbody>
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top"> <tr>
<![endif]-->'; <td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top">
$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>'; <![endif]-->';
$columnCloseTemplate = '</tbody></table> $columnOpenTemplate = '
<!--[if mso]> <table width="' . $columnWidth . '"
</td> border="0" cellpadding="0" cellspacing="0" align="left" class="mailpoet_force-row ' . $columnClass . ' mailpoet_col"
<td width="' . $columnWidth . '" style="width: ' . $columnWidth . 'px;" valign="top"> style="width: ' . $columnWidth . 'px; border-spacing: 0; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
<![endif]-->'; 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) { foreach ($columnsData as $index => $columnData) {
$index++; $index++;
@ -42,23 +50,23 @@ class Renderer {
if($columnsCount > 1 && $index != $columnsCount) { if($columnsCount > 1 && $index != $columnsCount) {
$columnContainerTemplate .= $columnCloseTemplate; $columnContainerTemplate .= $columnCloseTemplate;
} }
} }
// close column container // close column container
$columnContainerTemplate .= ' </tbody> $columnContainerTemplate .= '
</table> </tbody>
<!--[if mso]> </table>
</td> <!--[if mso]>
</tr> </td>
</tbody> </tr>
</table> </tbody>
<![endif]--> </table>
</td> <![endif]-->
</tr> </td>
</table> </tr>
</td> </table>
</tr>'; </td>
</tr>';
return $columnContainerTemplate; return $columnContainerTemplate;
} }