Example #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;
        }
    }
}
Example #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;
        }
    }
}
Example #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;
        }
    }
}
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;
}
Example #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;
}
Example #6
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;
        }
    }
}