url = $url; $this->view = $view; } /** * Convert an HTML string to entities. * * @param string $value * * @return string */ public function entities($value) { return htmlentities($value, ENT_QUOTES, 'UTF-8', false); } /** * Convert entities to HTML characters. * * @param string $value * * @return string */ public function decode($value) { return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); } /** * Generate a link to a JavaScript file. * * @param string $url * @param array $attributes * @param bool $secure * * @return \Illuminate\Support\HtmlString */ public function script($url, $attributes = [], $secure = null) { $attributes['src'] = $this->url->asset($url, $secure); return $this->toHtmlString('' . PHP_EOL); } /** * Generate a link to a CSS file. * * @param string $url * @param array $attributes * @param bool $secure * * @return \Illuminate\Support\HtmlString */ public function style($url, $attributes = [], $secure = null) { $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet']; $attributes = $attributes + $defaults; $attributes['href'] = $this->url->asset($url, $secure); return $this->toHtmlString('attributes($attributes) . '>' . PHP_EOL); } /** * Generate an HTML image element. * * @param string $url * @param string $alt * @param array $attributes * @param bool $secure * * @return \Illuminate\Support\HtmlString */ public function image($url, $alt = null, $attributes = [], $secure = null) { $attributes['alt'] = $alt; return $this->toHtmlString('attributes($attributes) . '>'); } /** * Generate a link to a Favicon file. * * @param string $url * @param array $attributes * @param bool $secure * * @return \Illuminate\Support\HtmlString */ public function favicon($url, $attributes = [], $secure = null) { $defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon']; $attributes = $attributes + $defaults; $attributes['href'] = $this->url->asset($url, $secure); return $this->toHtmlString('attributes($attributes) . '>' . PHP_EOL); } /** * Generate a HTML link. * * @param string $url * @param string $title * @param array $attributes * @param bool $secure * @param bool $escape * * @return \Illuminate\Support\HtmlString */ public function link($url, $title = null, $attributes = [], $secure = null, $escape = true) { $url = $this->url->to($url, [], $secure); if (is_null($title) || $title === false) { $title = $url; } if ($escape) { $title = $this->entities($title); } return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); } /** * Generate a HTTPS HTML link. * * @param string $url * @param string $title * @param array $attributes * * @return \Illuminate\Support\HtmlString */ public function secureLink($url, $title = null, $attributes = []) { return $this->link($url, $title, $attributes, true); } /** * Generate a HTML link to an asset. * * @param string $url * @param string $title * @param array $attributes * @param bool $secure * * @return \Illuminate\Support\HtmlString */ public function linkAsset($url, $title = null, $attributes = [], $secure = null) { $url = $this->url->asset($url, $secure); return $this->link($url, $title ?: $url, $attributes, $secure); } /** * Generate a HTTPS HTML link to an asset. * * @param string $url * @param string $title * @param array $attributes * * @return \Illuminate\Support\HtmlString */ public function linkSecureAsset($url, $title = null, $attributes = []) { return $this->linkAsset($url, $title, $attributes, true); } /** * Generate a HTML link to a named route. * * @param string $name * @param string $title * @param array $parameters * @param array $attributes * * @return \Illuminate\Support\HtmlString */ public function linkRoute($name, $title = null, $parameters = [], $attributes = []) { return $this->link($this->url->route($name, $parameters), $title, $attributes); } /** * Generate a HTML link to a controller action. * * @param string $action * @param string $title * @param array $parameters * @param array $attributes * * @return \Illuminate\Support\HtmlString */ public function linkAction($action, $title = null, $parameters = [], $attributes = []) { return $this->link($this->url->action($action, $parameters), $title, $attributes); } /** * Generate a HTML link to an email address. * * @param string $email * @param string $title * @param array $attributes * @param bool $escape * * @return \Illuminate\Support\HtmlString */ public function mailto($email, $title = null, $attributes = [], $escape = true) { $email = $this->email($email); $title = $title ?: $email; if ($escape) { $title = $this->entities($title); } $email = $this->obfuscate('mailto:') . $email; return $this->toHtmlString('attributes($attributes) . '>' . $title . ''); } /** * Obfuscate an e-mail address to prevent spam-bots from sniffing it. * * @param string $email * * @return string */ public function email($email) { return str_replace('@', '@', $this->obfuscate($email)); } /** * Generates non-breaking space entities based on number supplied. * * @param int $num * * @return string */ public function nbsp($num = 1) { return str_repeat(' ', $num); } /** * Generate an ordered list of items. * * @param array $list * @param array $attributes * * @return \Illuminate\Support\HtmlString|string */ public function ol($list, $attributes = []) { return $this->listing('ol', $list, $attributes); } /** * Generate an un-ordered list of items. * * @param array $list * @param array $attributes * * @return \Illuminate\Support\HtmlString|string */ public function ul($list, $attributes = []) { return $this->listing('ul', $list, $attributes); } /** * Generate a description list of items. * * @param array $list * @param array $attributes * * @return \Illuminate\Support\HtmlString */ public function dl(array $list, array $attributes = []) { $attributes = $this->attributes($attributes); $html = "