/** * Renders HTML * @access public * @return string */ public function getAsString() { $id = $this->getId(); if (!$this->isVisible()) { return "<div id='{$id}' class='hidden'></div>"; } $has_items = $this->hasItems() ? "class='p4a_menu_has_items'" : ''; $properties = $this->composeStringProperties(); if (P4A::singleton()->isHandheld()) { $icon = ''; } else { $icon = $this->getIcon(); if (strlen($icon)) { if (strpos($this->_icon, '.') === false) { $icon_disabled = ''; if (!$this->isEnabled()) { $icon_disabled = '_disabled'; } $icon = P4A_ICONS_PATH . "/16/{$icon}{$icon_disabled}." . P4A_ICONS_EXTENSION; } $icon = "<img src='{$icon}' alt='' />"; } } if (empty($this->_map_actions["onclick"]["method"]) or !$this->isEnabled()) { $sReturn = "<li {$has_items}>" . P4A_Generate_Widget_Layout_Table($icon, "<div {$properties}>" . __($this->getLabel()) . "</div>"); } else { $actions = $this->composeStringActions(); $sReturn = "<li {$has_items}>" . P4A_Generate_Widget_Layout_Table($icon, "<a href='#' {$actions} {$properties}>" . P4A_Highlight_AccessKey(__($this->getLabel()), $this->getAccessKey()) . "</a>"); } if ($has_items) { $sReturn .= "<ul>"; while ($item = $this->items->nextItem()) { $sReturn .= $item->getAsString(); } $sReturn .= "</ul>"; } $sReturn .= "</li>"; return $sReturn; }
/** * Retuns the HTML rendered button * @return string */ public function getAsString() { $id = $this->getId(); if (!$this->isVisible()) { return "<span id='{$id}' class='hidden'></span>"; } $label = htmlspecialchars(__($this->getLabel()), ENT_QUOTES); $title = $label; $properties = $this->composeStringProperties(); $actions = $this->composeStringActions(); $accesskey = $this->getAccessKey(); if (strlen($accesskey) > 0) { $title = "[{$accesskey}] {$title}"; } if ($this->_label_visible or !$this->_icon) { $label = P4A_Highlight_AccessKey($label, $accesskey); } else { $label = null; } $icon = ""; if ($this->_icon != null) { $size = $this->getSize(); if (strpos($size, 'x') !== false) { list($width, $size) = explode('x', $size); } if (strpos($this->_icon, '.') !== false) { $icon = $this->_icon; } else { $icon = P4A_ICONS_PATH . "/{$size}/{$this->_icon}"; $icon .= '.' . P4A_ICONS_EXTENSION; } $icon = "<img src='{$icon}' width='{$size}' height='{$size}' alt='' />"; } if ($icon) { $class = array('p4a_button_image'); if (!$this->isEnabled()) { $class[] = 'p4a_button_image_disabled'; } $class = $this->composeStringClass($class); } else { $class = array(); if (!$this->isEnabled()) { $class[] = 'p4a_button_disabled'; } $class = $this->composeStringClass($class); } $tooltip_text = __($this->getTooltip()); if ($tooltip_text) { $tooltip_text = "<div id='{$id}tooltip' class='p4a_tooltip'><div class='p4a_tooltip_inner'>{$tooltip_text}</div></div>"; $actions .= " onmouseover='p4a_tooltip_show(this)' "; } return "<button id='{$id}' title='{$title}' {$class} {$properties} {$actions}>" . $tooltip_text . P4A_Generate_Widget_Layout_Table($icon, $label) . '</button>'; }