/** * Get the evaluated contents of the object. * * @return string */ public function render() { $output = ''; foreach ($this->entries as $entry) { $entryAttributes = []; if ($entry instanceof DropdownDivider) { $entryAttributes['role'] = 'seperator'; $entryAttributes['class'] = 'divider'; } else { if ($entry instanceof DropdownHeader) { $entryAttributes['class'] = 'dropdown-header'; } else { if (MenuHelper::isCurrentRoute($entry->getName())) { $entryAttributes['class'] = 'active'; } else { foreach ($entry->getAdditionalRouteNames() as $additionalRouteName) { if (MenuHelper::isCurrentRoute($additionalRouteName)) { $entryAttributes['class'] = ' active'; } } } } } $output .= '<li ' . Html::attributes($entryAttributes) . '>' . $entry->render() . '</li>'; } if (empty($this->name)) { $link = Html::link('#', $this->title . '<span class="caret"></span>', ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']); } else { $link = Html::linkRoute($this->name, $this->title . '<span class="caret"></span>', $this->parameters, ['class' => 'dropdown-toggle', 'data-toggle' => 'dropdown']); } return $link . '<ul class="dropdown-menu">' . $output . '</ul>'; }
/** * Get the evaluated contents of the object. * * @return string */ public function render() { if (empty($this->name)) { $content = Html::link('#', $this->title, $this->attributes); } else { $content = Html::linkRoute($this->name, $this->title, $this->parameters, $this->attributes); } return $content; }
/** * @param string $url * @param string $name * @param string $position * @param array $attributes * * @return $this */ public function link($url, $name, $position = "BL", $attributes = array()) { $base = str_replace(Request::path(), '', strtok(Request::fullUrl(), '?')); $match_url = str_replace($base, '/', strtok($url, '?')); if (Request::path() != $match_url) { $url = Persistence::get($match_url, parse_url($url, PHP_URL_QUERY)); } $attributes = array_merge(array("class" => "btn btn-default"), $attributes); $this->button_container[$position][] = HTML::link($url, $name, $attributes); $this->links[] = $url; return $this; }