예제 #1
0
function smarty_block_a($params, $content, Smarty_Internal_Template $template, &$repeat)
{
    $ret = '';
    $smarty = $template->smarty;
    $par = new Params($params);
    $par->setParams([], ['href' => '', 'textDecoration' => $smarty->getConfigVars('aTextDecoration'), 'target' => $smarty->getConfigVars('aTarget'), 'buttonHeight' => false, 'style' => false, 'id' => false, 'class' => false, 'attrs' => false]);
    // only output on the closing tag
    if (!$repeat) {
        if (isset($content)) {
            $ret .= "<a";
            $ret .= SmartyUtils::addAttr('href', $par['href']);
            if ($par['textDecoration'] || $par['style'] || $par['buttonHeight']) {
                $ret .= ' style="';
                if ($par['textDecoration']) {
                    $ret .= "text-decoration:{$par['textDecoration']};text-decoration:{$par['textDecoration']} !important;";
                }
                if ($par['buttonHeight']) {
                    $ret .= "display:inline-block;mso-line-height-rule:exactly;height:{$par['buttonHeight']}px;max-height:{$par['buttonHeight']}px;line-height:{$par['buttonHeight']}px;line-height:{$par['buttonHeight']}px !important;vertical-align:middle;width:100%;white-space:nowrap;overflow:hidden;text-align:center;";
                }
                if ($par['style']) {
                    $ret .= $par['style'];
                }
                $ret .= '"';
            }
            $ret .= SmartyUtils::addAttr('target', $par['target']);
            $ret .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs']);
            $ret .= ">{$content}</a>";
            return $ret;
        }
    }
}
예제 #2
0
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;
        }
    }
}
예제 #3
0
function smarty_block_tr($params, $content, Smarty_Internal_Template $template, &$repeat)
{
    $ret = '';
    $smarty = $template->smarty;
    $par = new Params($params);
    $par->setParams([], ['style' => false, 'id' => false, 'class' => false, 'attrs' => false]);
    // only output on the closing tag
    if (!$repeat) {
        if (isset($content)) {
            $ret .= "<tr";
            $ret .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs'], $par['style']);
            $ret .= ">{$content}</tr>";
            return $ret;
        }
    }
}
예제 #4
0
function smarty_function_margin($params, Smarty_Internal_Template $template)
{
    $ret = '';
    $smarty = $template->smarty;
    $par = new Params($params);
    $par->setParams([], ['width' => false, 'height' => 30, 'colspan' => 1, 'bgcolor' => false, 'style' => false, 'id' => false, 'class' => false, 'attrs' => false]);
    $tpl = "{tr}{td";
    $tpl .= SmartyUtils::addAttr('height', $par['height'], true);
    $tpl .= SmartyUtils::addAttr('width', $par['width'], true);
    $tpl .= " colspan={$par['colspan']} align=false valign=false noFont=true";
    $tpl .= SmartyUtils::addAttr('overflow', 'hidden');
    $tpl .= SmartyUtils::addAttr('bgcolor', $par['bgcolor']);
    $tpl .= SmartyUtils::addAttr('fontSize', 0);
    $tpl .= SmartyUtils::addAttr('style', $par['style']);
    $tpl .= SmartyUtils::getAttrs($par['id'], $par['class'], $par['attrs']);
    $tpl .= "}";
    if ($par['height'] >= 18) {
        $tpl .= "&nbsp;";
    }
    $tpl .= "{/td}{/tr}";
    $ret .= $smarty->fetch('string:' . $tpl);
    return $ret;
}
예제 #5
0
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;
}
예제 #6
0
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;
        }
    }
}
예제 #7
0
function smarty_block_button($params, $content, Smarty_Internal_Template $template, &$repeat)
{
    $ret = '';
    $smarty = $template->smarty;
    $par = new Params($params);
    $par->setParams([], ['href' => '', 'width' => false, 'height' => false, 'bgcolor' => false, 'bordercolor' => false, 'borderRadius' => false, 'centered' => true]);
    // only output on the closing tag
    if (!$repeat) {
        if (isset($content)) {
            $isCentered = $par['centered'];
            $hasBorder = $par['bordercolor'] !== false;
            $arcSize = false;
            if ($par['height'] && $par['borderRadius']) {
                $arcSize = round($par['borderRadius'] / $par['height'] * 100) . '%';
            }
            $tagName = $par['borderRadius'] ? 'roundrect' : 'rect';
            $ret .= '
      <!--[if mso]>
        <v:' . $tagName . ' xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="' . $par['href'] . '" style="height:' . $par['height'] . 'px;v-text-anchor:middle;width:' . $par['width'] . 'px;"';
            $ret .= SmartyUtils::addAttr('arcsize', $arcSize);
            $ret .= SmartyUtils::addAttr('strokecolor', $par['bordercolor']);
            if (!$par['bordercolor']) {
                $ret .= ' stroke="f"';
            }
            $ret .= ' fillcolor="' . $par['bgcolor'] . '">';
            $ret .= '<w:anchorlock/>';
            if (!$hasBorder) {
                $ret .= '<![endif]-->';
            }
            if ($isCentered) {
                $ret .= '<center>';
            }
            $inner = "{a href='{$par['href']}' textDecoration='none' buttonHeight='{$par['height']}' style='width:{$par['width']}px;-webkit-text-size-adjust:none;background-color:{$par['bgcolor']};";
            $innerWithBorder = false;
            if ($par['borderRadius'] !== false) {
                $par['borderRadius'] .= 'px';
            }
            $inner .= SmartyUtils::addCss('border-radius', $par['borderRadius']);
            if (!$par['centered']) {
                $inner .= SmartyUtils::addCss('text-align', 'left');
            }
            if ($hasBorder) {
                $par['bordercolor'] = '1px solid ' . $par['bordercolor'];
                $innerWithBorder = $inner;
                $innerWithBorder .= SmartyUtils::addCss('border', $par['bordercolor']);
            }
            $innerFinish = "'}" . $content . '{/a}';
            if ($hasBorder) {
                $innerWithBorder .= SmartyUtils::addCss('mso-hide', 'all');
                $innerWithBorder .= $innerFinish;
            }
            $inner .= $innerFinish;
            $ret .= $inner;
            if ($par['centered']) {
                $ret .= '</center>';
            }
            if (!$hasBorder) {
                $ret .= '<!--[if mso]>';
            }
            $ret .= '</v:' . $tagName . '>
        <![endif]-->';
            //add a button with border hidden for MSO
            if ($hasBorder) {
                $ret .= $innerWithBorder;
            }
            return $smarty->fetch('string:' . $ret);
        }
    }
}
예제 #8
0
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;
        }
    }
}