<?php if ($menus) { foreach ($menus as $menu) { $li_class = !empty($is_ajax_loaded) ? ' class="ajax_loaded"' : ''; if (empty($menu['tag']) || $menu['tag'] == 'a' || $menu['tag'] == 'anchor') { $href = isset($menu['href']) ? $menu['href'] : '#'; $attr = isset($menu['attr']) ? $menu['attr'] : array(); $label = isset($menu['label']) ? $menu['label'] : ''; if (isset($menu['icon_term'])) { if (empty($attr['data-msg']) && ($msg = Site_Util::get_confirm_msg(str_replace('form.', '', $menu['icon_term'])))) { $attr['data-msg'] = $msg; } ?> <li<?php echo $li_class; ?> ><?php echo anchor_icon($href, $menu['icon_term'], $attr); ?> </li> <?php } else { ?> <li<?php echo $li_class; ?> ><?php echo anchor($href, $label, false, $attr); ?> </li>
function btn($term_key, $href = '#', $class_name = '', $with_text = true, $btn_size = '', $btn_type = null, $attr = array(), $absolute_icon_key = null, $tag = null, $form_name = null, $is_hidden_xs = true, $with_caret = false) { if (!$tag) { $tag = 'a'; } if (!in_array($tag, array('a', 'button'))) { throw new \InvalidArgumentException('Parameter tag is invalid.'); } $label = icon_label($term_key, $with_text ? 'both' : 'icon', $is_hidden_xs, $absolute_icon_key); if ($with_caret) { $label .= ' <span class="caret"></span>'; } switch ($term_key) { case 'form.delete': case 'form.do_delete': if (is_null($btn_type)) { $btn_type = 'danger'; } break; case 'form.create': if (is_null($btn_type)) { $btn_type = 'warning'; } break; case 'form.preview': $attr['target'] = '_blank'; break; } if (empty($attr['data-msg']) && ($msg = Site_Util::get_confirm_msg($term_key))) { $attr['data-msg'] = $msg; } if (is_null($btn_type)) { $btn_type = 'default'; } $class_items = array(); $class_items[] = 'btn'; $class_items[] = 'btn-' . $btn_type; if ($class_name) { $class_items[] = $class_name; } if ($btn_size) { $class_items[] = 'btn-' . $btn_size; } if (isset($attr['class'])) { if (is_array($attr['class'])) { $class_items += $attr['class']; } else { $class_items[] = $attr['class']; } } $attr['class'] = implode(' ', $class_items); if ($tag == 'button') { if (!$form_name) { $form_name = 'button'; } return Form::button($form_name, $label, $attr); } if (empty($href)) { $href = '#'; } return Html::anchor($href, $label, $attr); }