/** * Create a link like a jquery.ui button * @param string $value The button value * @param string $id The buton Id * @param string $properties Html attributes and properties */ function ui_link_button($configuration) { $corners = ''; $title = isset($configuration['title']) ? $configuration['title'] : ''; $defaultAlign = ''; $priority = ''; $href = isset($configuration['url']) ? sprintf(' href="%s" ', $configuration['url']) : ''; $href .= isset($configuration['target']) ? sprintf(' target="%s" ', $configuration['target']) : ''; $defaultStyle = isset($configuration['show']) && !$configuration['show'] ? 'style="cursor:pointer; display:none"' : 'style="cursor:pointer"'; $uiIcon = ''; $stateHtml = ''; $state = 'ui-state-default '; $id = isset($configuration['id']) ? $configuration['id'] : ''; if (isset($configuration['value'])) { $title = $configuration['value']; $value = $configuration['value']; } else { $value = ' '; $defaultAlign = 'fg-button-icon-solo'; } if (isset($configuration['noTitle']) && $configuration['noTitle'] == true) { $title = ''; } else { if (isset($configuration['title'])) { $title = $configuration['title']; } } if (isset($configuration['corner'])) { $corners = 'ui-corner-' . strtolower($configuration['corner']); } if (isset($configuration['priority'])) { $priority = 'ui-priority-' . strtolower($configuration['priority']); } if (isset($configuration['state'])) { $href = ''; $state .= 'ui-state-' . strtolower($configuration['state'] . ' '); if (strtolower($configuration['state']) == 'disabled') { echo add_jquery_support('#' . $id, 'ready', like_function(jquery_unbind_event('#' . $id))); $stateHtml = sprintf(' disabled="%s"', $configuration['state']); } } if (isset($configuration['icon'])) { if (isset($configuration['align']) && isset($configuration['value'])) { $defaultAlign = 'fg-button-icon-' . strtolower($configuration['align']); } else { $defaultAlign = $defaultAlign != '' ? $defaultAlign : 'fg-button-icon-left'; } $uiIcon = ui_create_icon($configuration['icon']); } $title = sprintf(' title="%s" ', $title); $defaultProperties = sprintf('%s class="fg-button ui-button %s %s %s %s" %s %s', $title, $state, $priority, $defaultAlign, $corners, $defaultStyle, $href . $stateHtml); $properties = isset($configuration['properties']) ? $configuration['properties'] . $defaultProperties : $defaultProperties; $pattern = '<a id="%s" %s >%s %s</a>'; return sprintf($pattern, $id, $properties, $uiIcon, $value); }
/** * Formatter for ui.fg-menu * @param array $items The array to Format. */ function fg_menu_list_formatter($item) { $properties = ''; if (isset($item['type']) && strtolower($item['type']) == 'separator') { return '<hr class="ui-state-default"/>'; } if (isset($item['disabled']) && $item['disabled'] == true) { $properties = ' class="ui-state-disabled fg-button fg-button-icon-left" '; unset($item['url'], $item['actions']); } $pattern = '<a id="%s" %s %s class="fg-button fg-button-icon-left"+>%s</a>'; $value = isset($item['value']) ? $item['value'] : 'undefined[value]'; if (isset($item['icon'])) { $icon = ui_create_icon($item['icon']); $value .= $icon; } $id = isset($item['id']) ? $item['id'] : ''; $href = isset($item['url']) ? sprintf('href="%s"', $item['url']) : 'href="#"'; $properties .= _get_actions($item); return sprintf($pattern, $id, $href, $properties, $value); }