/** * Renders as ECHO HTML code * * @param SimpleXMLElement $modelView * @param RegistryInterface[] $modelRows * @param DrawController $controllerView * @param array $options * @param boolean $htmlFormatting * @return string */ protected function renderMenu(&$modelView, &$modelRows, &$controllerView, $options, $htmlFormatting) { $renderer = new RegistryEditView($this->input, $this->_db, $this->_pluginParams, $this->_types, $this->_actions, $this->_views, $this->_pluginObject, $this->_tabid); $renderer->setParentView($modelView); $renderer->setModelOfDataRows($modelRows); $name = $modelView->attributes('name'); $label = $modelView->attributes('label'); $description = $modelView->attributes('description'); $action = $modelView->attributes('action'); $width = $modelView->attributes('width'); $height = $modelView->attributes('height'); $icon = $modelView->attributes('icon'); $iconwidth = $modelView->attributes('iconwidth'); $iconheight = $modelView->attributes('iconheight'); $iconhover = $modelView->attributes('iconhover'); if (!$icon && !$modelView->attributes('buttonclass')) { $modelView->addAttribute('buttonclass', 'default'); } if (!$modelView->attributes('textclass')) { $modelView->addAttribute('textclass', 'primary'); } $cssclass = RegistryEditView::buildClasses($modelView); if ($label) { $header = '<div class="cbButtonMenuItemLabel"><span>' . CBTxt::Th($label) . '</span></div>'; } else { $header = null; } if (count($modelView->children()) > 0) { $modelHtml = $renderer->renderEditRowView($modelView, $modelRows, $controllerView, $options, 'view', 'span'); } else { $modelHtml = null; } $footer = $modelHtml ? '<div class="cbButtonMenuItemData">' . $modelHtml . '</div>' : null; $attributes = ' class="cbButtonMenuItem' . ($cssclass ? ' ' . htmlspecialchars($cssclass) : '') . '"'; if ($width || $height) { $attributes .= ' style="' . ($width ? 'width:' . htmlspecialchars($width) . ';' : '') . ($height ? 'height:' . htmlspecialchars($height) . ';' : '') . '"'; } if ($description) { $tooltipTitle = addslashes(CBTxt::Th($label)); $tooltip = addslashes(CBTxt::Th($description)); $attributes = cbTooltip(null, $tooltip, $tooltipTitle, null, null, null, null, $attributes); } $return = '<div' . $attributes . '>'; if ($action) { $data = null; // see later if we need to put data here... $link = $controllerView->drawUrl($action, $modelView, $data, 0, true); if ($link) { $return .= '<a href="' . $link . '" class="cbButtonMenuItemLink">'; } } else { $link = null; } if ($icon) { $renderer->substituteName($icon, false); $icon = RegistryEditView::pathFromXML($icon, $modelView, $this->_pluginObject, 'live'); } if ($iconhover) { $renderer->substituteName($iconhover, false); $iconhover = RegistryEditView::pathFromXML($iconhover, $modelView, $this->_pluginObject, 'live'); } if ($iconwidth || $iconheight) { $iconattributes = ' style="' . ($iconwidth ? 'width:' . htmlspecialchars($iconwidth) : '') . ($iconheight ? 'height:' . htmlspecialchars($iconheight) : '') . '"'; } else { $iconattributes = null; } $return .= '<div class="cbButtonMenuItemInner' . ($name ? ' cbDIIM' . htmlspecialchars($name) : '') . '">' . $header . ($icon ? '<img src="' . htmlspecialchars($icon) . '" alt="" class="cbButtonMenuItemImg"' . ($iconattributes ? ' ' . $iconattributes : '') . ' />' : null) . ($iconhover ? '<img src="' . htmlspecialchars($iconhover) . '" alt="" class="cbButtonMenuItemImgHover"' . ($iconattributes ? ' ' . $iconattributes : '') . ' />' : null) . $footer . '</div>'; if ($action && $link) { $return .= '</a>'; } $return .= '</div>'; return $return; }