function smarty_block_table($params, $content, Smarty_Internal_Template $template, &$repeat) { $ret = ''; $smarty = $template->smarty; $repeatCss = $smarty->getConfigVars('repeatAttrInCss'); $par = new Params($params); $par->setParams([], ['width' => $smarty->getConfigVars('tableWidth'), 'cellpadding' => '0', 'cellspacing' => '0', 'bgcolor' => false, 'border' => '0', 'bordercolor' => false, 'align' => $smarty->getConfigVars('tableAlign'), 'style' => false, 'id' => false, 'class' => false, 'attrs' => false]); // only output on the closing tag if (!$repeat) { if (isset($content)) { if ($par['width'] === "") { $par['width'] = $smarty->getConfigVars('lWidth'); } $widthCss = SmartyUtils::unitPx($par['width']); $ret .= "<table cellpadding=\"{$par['cellpadding']}\" cellspacing=\"{$par['cellspacing']}\" border=\"{$par['border']}\""; $ret .= SmartyUtils::addAttr('align', $par['align']); $ret .= SmartyUtils::addAttr('width', $par['width']); $ret .= SmartyUtils::addAttr('bgcolor', $par['bgcolor']); $ret .= SmartyUtils::addAttr('bordercolor', $par['bordercolor']); $style = ''; if ($repeatCss) { $style .= "margin:0"; if ($par['align'] == 'center') { $style .= " auto"; } $style .= ';'; $style .= SmartyUtils::addCss('width', $widthCss); } $style .= SmartyUtils::addCss('background-color', $par['bgcolor']); if ($par['border']) { $style .= "border:{$par['border']}px solid "; if ($par['bordercolor']) { $style .= $par['bordercolor']; } else { $style .= '#000'; } $style .= ';'; } $style .= 'border-collapse:collapse;'; if ($smarty->getConfigVars('outlookCss')) { $style .= "mso-table-lspace:0pt;mso-table-rspace:0pt;"; } if ($par['align'] == 'center') { $style .= 'margin-left:auto;margin-right:auto;'; } if ($par['style']) { $style .= $par['style']; } if (strlen($style)) { $ret .= ' style="' . $style . '"'; } $ret .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs']); $ret .= ">"; $ret .= $content . '</table>'; return $ret; } } }
function smarty_function_img($params, Smarty_Internal_Template $template) { $ret = ''; $smarty = $template->smarty; $repeatCss = $smarty->getConfigVars('repeatAttrInCss'); $par = new Params($params); $par->setParams([], ['src' => '', 'srcPrepend' => $smarty->getConfigVars('imgSrcPrepend'), 'width' => false, 'height' => false, 'autoSize' => $smarty->getConfigVars('imgAutoSize'), 'alt' => $smarty->getConfigVars('imgAlt'), 'padding' => false, 'margin' => '0', 'marginV' => '0', 'marginH' => '0', 'align' => false, 'display' => $smarty->getConfigVars('imgDisplay'), 'border' => '0', 'bordercolor' => false, 'style' => false, 'id' => false, 'class' => '', 'attrs' => false]); $ret .= "<img"; $src = $par['src']; if ($par['srcPrepend'] !== false) { $src = $par['srcPrepend'] . $src; } $ret .= SmartyUtils::addAttr('src', $src); //auto size if ($par['autoSize'] && $par['src'] && !$par['width'] && !$par['height']) { $file = SmartyUtils::$config['outputsDir'] . $par['src']; if (file_exists($file)) { $s = getimagesize($file); if ($s) { $par['width'] = $s[0]; $par['height'] = $s[1]; } } } $ret .= SmartyUtils::addAttr('width', $par['width']); $widthCss = SmartyUtils::unitPx($par['width']); $ret .= SmartyUtils::addAttr('height', $par['height']); $ret .= SmartyUtils::addAttr('alt', $par['alt']); $ret .= SmartyUtils::addAttr('vspace', $par['marginV']); $ret .= SmartyUtils::addAttr('hspace', $par['marginH']); if ($par->isDefault('margin') && ($par['marginV'] || $par['marginH'])) { $par['margin'] = ($par['marginV'] ? $par['marginV'] : '0') + 'px ' + ($par['marginH'] ? $par['marginH'] : '0') + 'px'; } $ret .= SmartyUtils::addAttr('align', $par['align']); $ret .= SmartyUtils::addAttr('border', $par['border']); $ret .= SmartyUtils::addAttr('bordercolor', $par['bordercolor']); $ret .= " style=\""; $ret .= SmartyUtils::addCss('display', $par['display']); if ($repeatCss) { $ret .= SmartyUtils::addCss('width', $par['width']); $ret .= SmartyUtils::addCss('height', $par['height']); } $ret .= SmartyUtils::addCss('padding', $par['padding']); $ret .= SmartyUtils::addCss('margin', $par['margin']); if ($par['border'] && $par['border'] != '0') { if ($par['bordercolor']) { $ret .= "border:{$par['border']}px solid {$par['bordercolor']};"; } else { $ret .= "border-width:{$par['border']}px;"; } } else { //if ($repeatCss) { $ret .= 'border:none;'; //} } $ret .= 'outline:none;text-decoration:none;'; if ($smarty->getConfigVars('outlookCss')) { $ret .= '-ms-interpolation-mode:bicubic;'; } if ($par['style']) { $ret .= $par['style']; } $ret .= '"'; $ret .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs']); $ret .= ' />'; return $ret; }
function smarty_block_td($params, $content, Smarty_Internal_Template $template, &$repeat) { $ret = ''; $smarty = $template->smarty; $repeatCss = $smarty->getConfigVars('repeatAttrInCss'); $noFont = isset($params['noFont']) ? $params['noFont'] : !$smarty->getConfigVars('fontStyleTdTag'); $par = new Params($params); $par->setParams([], ['width' => $smarty->getConfigVars('tdWidth'), 'height' => false, 'colspan' => 1, 'align' => $smarty->getConfigVars('tdAlign'), 'valign' => $smarty->getConfigVars('tdValign'), 'padding' => 0, 'overflow' => $smarty->getConfigVars('tdOverflow'), 'bgcolor' => false, 'lineHeight' => $smarty->getConfigVars('tdLineHeight'), 'borderRadius' => false, 'noFont' => $noFont, 'fontFamily' => $noFont ? false : $smarty->getConfigVars('fontFamily'), 'fontSize' => $noFont ? false : $smarty->getConfigVars('fontSize'), 'fontColor' => $noFont ? false : $smarty->getConfigVars('fontColor'), 'style' => false, 'id' => false, 'class' => false, 'attrs' => false]); // only output on the closing tag if (!$repeat) { if (isset($content)) { if ($par['width'] === "") { $par['width'] = $smarty->getConfigVars('lWidth'); } //shorthand if ($par['overflow'] === true) { $par['overflow'] = 'hidden'; } $ret .= "<td"; $ret .= SmartyUtils::addAttr('width', $par['width']); $widthCss = SmartyUtils::unitPx($par['width']); $ret .= SmartyUtils::addAttr('height', $par['height']); if ($par['colspan'] > 1) { $ret .= SmartyUtils::addAttr('colspan', $par['colspan']); } $ret .= SmartyUtils::addAttr('valign', $par['valign']); $ret .= SmartyUtils::addAttr('align', $par['align']); $ret .= SmartyUtils::addAttr('bgcolor', $par['bgcolor']); $style = ''; if ($repeatCss) { $style .= SmartyUtils::addCss('width', $widthCss); if ($par['height'] !== false) { $style .= SmartyUtils::addCss('height', $par['height'] . 'px'); } $style .= SmartyUtils::addCss('vertical-align', $par['valign']); $style .= SmartyUtils::addCss('text-align', $par['align']); } if ($smarty->getConfigVars('outlookCss') && $par['lineHeight'] !== false) { $style .= "mso-line-height-rule:exactly;"; } if ($repeatCss || !$par->isDefault('padding')) { $style .= SmartyUtils::addCss('padding', $par['padding']); } $style .= SmartyUtils::addCss('overflow', $par['overflow']); $style .= SmartyUtils::addCss('background', $par['bgcolor']); $style .= SmartyUtils::addCss('line-height', $par['lineHeight']); $style .= SmartyUtils::addCss('border-radius', $par['borderRadius']); $style .= SmartyUtils::addCss('font-family', $par['fontFamily']); if ($par['fontSize'] !== false) { $par['fontSize'] = $par['fontSize'] . 'px'; } $style .= SmartyUtils::addCss('font-size', $par['fontSize']); $style .= SmartyUtils::addCss('color', $par['fontColor']); if ($par['style']) { $style .= $par['style']; } if (strlen($style)) { $ret .= ' style="' . $style . '"'; } $ret .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs']); $ret .= ">{$content}</td>"; return $ret; } } }