/** * @param $access_name * @param $text * @param $url * @param array $attrs * * @return $this */ function addItem($as, $key, $attrs = []) { if (!Route::isEnable($as)) { return $this; } if (is_array($as)) { $text = Arr::get($as, 'title'); $icon = Arr::get($as, 'icon'); $url = Arr::get($as, 'url', '#'); $as = Arr::get($as, 'as'); } else { $text = Route::get_title($as); $icon = Route::get_icon($as); $url = Route::get_url($as); } if ($icon) { $text = \HtmlI::setTitle($text)->addClass($icon) . ' ' . \HtmlSpan::setContent($text); } $this->map->add($key, $as, $text, $url, $attrs); return $this; }
/** * @param $access_name * @param $text * @param $url * @param array $attrs * * @return $this */ function addItem($as, $key, $route_parameters = []) { if (is_string($as)) { if (!Route::isEnable($as)) { return $this; } if (Route::checkRouteFilters($as)) { return $this; } if (!count(Route::get($as))) { return $this; } } if (is_array($as)) { $text = Arr::get($as, 'title'); $icon = Arr::get($as, 'icon'); $url = Arr::get($as, 'url', '#'); $as = Arr::get($as, 'as'); } else { $keys = array_keys($route_parameters); $keys = array_map(function ($item) { return '{' . $item . '}'; }, $keys); $text = str_replace($keys, array_values($route_parameters), Route::get_title($as)); $icon = Route::get_icon($as); $url = \URL::route($as, $route_parameters); } if ($icon) { $text = \HtmlI::setTitle($text)->addClass($icon) . ' ' . \HtmlSpan::setContent($text); } if (!isset($this->maps[$this->section])) { $this->maps[$this->section] = Map::instance(get_called_class() . $this->name . $this->section); } if ($route_parameters) { $key .= '.' . str_replace(['&', '='], ['.', '-'], http_build_query($route_parameters)); } $this->maps[$this->section]->add($key, $as, $text, $url); return $this; }
return HtmlAbbr::setContent($abbr)->setTitle($fulltext); }); Larakit\Twig::register_function('html_blockquote', function ($content, $author = null) { return HtmlBlockquote::setContent($content)->setAuthor($author); }); Larakit\Twig::register_function('html_button', function ($content) { return HtmlButton::setContent($content); }); Larakit\Twig::register_function('html_div', function ($content = null) { return HtmlDiv::setContent($content); }); Larakit\Twig::register_function('html_i', function ($content = null) { return HtmlI::setContent($content); }); Larakit\Twig::register_function('html_span', function ($content = null) { return HtmlSpan::setContent($content); }); Larakit\Twig::register_function('html_strike', function ($content = null) { return HtmlStrike::setContent($content); }); Larakit\Twig::register_function('html_strong', function ($content = null) { return HtmlStrong::setContent($content); }); Larakit\Twig::register_function('html_sup', function ($content = null) { return HtmlSup::setContent($content); }); Larakit\Twig::register_function('html_sub', function ($content = null) { return HtmlSub::setContent($content); }); Larakit\Twig::register_function('html_ul', function ($items = []) { $list = HtmlUl::setContent(null);