function smarty_function_link(array $params, Smarty_Internal_Template $template) { $label = ''; if (isset($params['label'])) { $label = $params['label']; } unset($params['label']); $class = 'link'; if (isset($params['class'])) { $class .= ' ' . $params['class']; } unset($params['class']); $title = null; if (isset($params['title'])) { $title = $params['title']; } unset($params['title']); $icon = null; if (isset($params['icon'])) { $icon = $params['icon']; } unset($params['icon']); $iconPosition = 'left'; if (isset($params['iconPosition']) && $params['iconPosition'] === 'right') { $iconPosition = 'right'; } unset($params['iconPosition']); $data = array(); if (isset($params['data'])) { $data = (array) $params['data']; } unset($params['data']); $onclick = null; if (isset($params['onclick'])) { $onclick = $params['onclick']; } unset($params['onclick']); $href = 'javascript:;'; if (isset($params['href'])) { $href = (string) $params['href']; } unset($params['href']); $target = null; if (isset($params['target'])) { $target = (string) $params['target']; } unset($params['target']); if (isset($params['page'])) { $href = smarty_function_linkUrl($params, $template); } if (empty($label) && empty($icon) && empty($title) && 0 !== strpos($href, 'javascript:')) { $label = $href; } $iconMarkup = null; if (null !== $icon) { $iconMarkup = '<span class="icon icon-' . $icon . '"></span>'; } $html = ''; if (null !== $iconMarkup && 'left' === $iconPosition) { $html .= $iconMarkup; $class .= ' hasIcon'; } if (!empty($label)) { $html .= '<span class="label">' . CM_Util::htmlspecialchars($label) . '</span>'; $class .= ' hasLabel'; } if (null !== $iconMarkup && 'right' === $iconPosition) { $html .= $iconMarkup; $class .= ' hasIconRight'; } $attributeList = ['el' => 'a', 'content' => $html, 'href' => $href, 'class' => $class, 'title' => $title, 'onclick' => $onclick, 'target' => $target]; foreach ($data as $name => $value) { $attributeList['data-' . $name] = $value; } return smarty_function_tag($attributeList, $template); }
function smarty_function_button_link(array $params, Smarty_Internal_Template $template) { $isHtmlLabel = isset($params['isHtmlLabel']) ? (bool) $params['isHtmlLabel'] : false; $label = ''; if (isset($params['label'])) { $label = $isHtmlLabel ? $params['label'] : CM_Util::htmlspecialchars($params['label']); unset($params['label']); } $attrs = ''; $icon = null; $iconConfirm = null; if (isset($params['icon'])) { $icon = $params['icon']; if (isset($params['iconConfirm'])) { $iconConfirm = $params['iconConfirm']; } } unset($params['icon']); unset($params['iconConfirm']); $iconPosition = 'left'; if (!empty($params['iconPosition']) && $params['iconPosition'] == 'right') { $iconPosition = 'right'; } unset($params['iconPosition']); $title = null; if (isset($params['title'])) { $title = (string) $params['title']; $attrs .= ' title="' . CM_Util::htmlspecialchars($title) . '"'; } unset($params['title']); if (isset($params['id'])) { $attrs .= ' id="' . $params['id'] . '"'; } unset($params['id']); $theme = isset($params['theme']) ? (string) $params['theme'] : 'default'; $class = 'button ' . 'button-' . $theme . ' clickFeedback' . ' '; if (isset($params['class'])) { $class .= $params['class']; } unset($params['theme']); unset($params['class']); if ($label) { $class .= ' hasLabel'; } $iconMarkup = ''; if ($icon) { if ($iconConfirm) { $iconMarkup = '<span class="icon icon-' . $icon . ' confirmClick-state-inactive"></span>' . '<span class="icon icon-' . $iconConfirm . ' confirmClick-state-active"></span>'; } else { $iconMarkup = '<span class="icon icon-' . $icon . '"></span>'; } if ($iconPosition == 'right') { $class .= ' hasIconRight'; } else { $class .= ' hasIcon'; } } $onclick = false; if (isset($params['onclick'])) { $onclick = $params['onclick']; unset($params['onclick']); } if (isset($params['page'])) { $onclick .= ' cm.router.route(\'' . smarty_function_linkUrl($params, $template) . '\');'; } if ($onclick) { $attrs .= ' onclick="' . CM_Util::htmlspecialchars($onclick) . '"'; } if (isset($params['data'])) { foreach ($params['data'] as $name => $value) { $attrs .= ' data-' . $name . '="' . CM_Util::htmlspecialchars($value) . '"'; } } $html = ''; $html .= '<button class="' . $class . '" type="button" value="' . $label . '" ' . $attrs . '>'; if ($icon && $iconPosition == 'left') { $html .= $iconMarkup; } if ($label) { $html .= '<span class="label">' . $label . '</span>'; } if ($icon && $iconPosition == 'right') { $html .= $iconMarkup; } $html .= '</button>'; return $html; }