function smarty_block_font($params, $content, Smarty_Internal_Template $template, &$repeat) { $ret = ''; $smarty = $template->smarty; $repeatCss = $smarty->getConfigVars('repeatAttrInCss'); $par = new Params($params); $par->setParams([], ['color' => $smarty->getConfigVars('fontColor'), 'size' => $smarty->getConfigVars('fontSize'), 'sizeForce' => false, 'family' => $smarty->getConfigVars('fontFamily'), 'bold' => false, 'b' => false, 'italic' => false, 'i' => false, 'underlined' => false, 'u' => false, 'centered' => false, 'c' => false, 'style' => false, 'lineHeight' => false, 'forceCss' => false]); // only output on the closing tag if (!$repeat) { if (isset($content)) { $setCss = false; //check if any argument was set - if true, the css are applied foreach ($par as $key => $value) { if (!$par->isDefault($key)) { $setCss = true; break; } } $setCss = $setCss || !$smarty->getConfigVars('fontStyleTdTag'); $isBold = $par['bold'] !== false || $par['b'] !== false; $isItalic = $par['italic'] !== false || $par['i'] !== false; $isUnderlined = $par['underlined'] !== false || $par['u'] !== false; $isCentered = $par['centered'] !== false || $par['c'] !== false; $css = ""; $css .= SmartyUtils::addCss('font-size', $par['size'] . 'px'); if ($par['sizeForce']) { $css .= SmartyUtils::addCss('font-size', $par['size'] . 'px !important'); } $cssFont = $css; $css .= SmartyUtils::addCss('color', $par['color']); $css .= SmartyUtils::addCss('font-family', $par['family']); if ($isBold) { $css .= SmartyUtils::addCss('font-weight', 'bold'); } if ($isItalic) { $css .= SmartyUtils::addCss('font-style', 'italic'); } if ($isUnderlined) { $css .= SmartyUtils::addCss('text-decoration', 'underline'); } if ($repeatCss || $par['forceCss']) { $cssFont = $css; } $prop = SmartyUtils::addCss('line-height', $par['lineHeight']); $css .= $prop; $cssFont .= $prop; if ($par['style']) { $prop = $par['style']; $css .= $prop; $cssFont .= $prop; } if ($isCentered) { $ret .= '<center>'; } if ($isBold) { $ret .= '<b>'; } if ($isItalic) { $ret .= '<i>'; } if ($isUnderlined) { $ret .= '<u>'; } $useSpan = $smarty->getConfigVars('fontStyleSpanTag') && ($setCss || $par['forceCss']); if ($useSpan) { $ret .= "<span style=\"{$css}\">"; } $useFont = $smarty->getConfigVars('fontStyleFontTag'); if ($useFont) { $sizeFont = SmartyUtils::convertFontSize($par['size']); $ret .= "<font color=\"{$par['color']}\" size=\"{$sizeFont}\" face=\"{$par['family']}\" style=\"{$cssFont}\">"; } $ret .= $content; if ($useFont) { $ret .= '</font>'; } if ($useSpan) { $ret .= '</span>'; } if ($isUnderlined) { $ret .= '</u>'; } if ($isItalic) { $ret .= '</i>'; } if ($isBold) { $ret .= '</b>'; } if ($isCentered) { $ret .= '</center>'; } 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; } } }