updated backend
This commit is contained in:
parent
1fea0f4fe7
commit
11521c2339
3459 changed files with 72735 additions and 168535 deletions
|
|
@ -1,41 +1,57 @@
|
|||
{
|
||||
"name": "laravelcollective/html",
|
||||
"description": "HTML and Form Builders for the Laravel Framework",
|
||||
"license": "MIT",
|
||||
"homepage": "http://laravelcollective.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||
"source": "https://github.com/LaravelCollective/html"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Adam Engebretson",
|
||||
"email": "adam@laravelcollective.com"
|
||||
"name": "laravelcollective/html",
|
||||
"description": "HTML and Form Builders for the Laravel Framework",
|
||||
"license": "MIT",
|
||||
"homepage": "https://laravelcollective.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/LaravelCollective/html/issues",
|
||||
"source": "https://github.com/LaravelCollective/html"
|
||||
},
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
"illuminate/http": "5.4.*",
|
||||
"illuminate/routing": "5.4.*",
|
||||
"illuminate/session": "5.4.*",
|
||||
"illuminate/support": "5.4.*",
|
||||
"illuminate/view": "5.4.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/database": "5.4.*",
|
||||
"mockery/mockery": "~0.9.4",
|
||||
"phpunit/phpunit": "~5.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Collective\\Html\\": "src/"
|
||||
"authors": [
|
||||
{
|
||||
"name": "Adam Engebretson",
|
||||
"email": "adam@laravelcollective.com"
|
||||
},
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylorotwell@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1.3",
|
||||
"illuminate/http": "5.8.*",
|
||||
"illuminate/routing": "5.8.*",
|
||||
"illuminate/session": "5.8.*",
|
||||
"illuminate/support": "5.8.*",
|
||||
"illuminate/view": "5.8.*"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
}
|
||||
"require-dev": {
|
||||
"illuminate/database": "5.8.*",
|
||||
"mockery/mockery": "~1.0",
|
||||
"phpunit/phpunit": "~7.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Collective\\Html\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/helpers.php"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.8-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Collective\\Html\\HtmlServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
"Form": "Collective\\Html\\FormFacade",
|
||||
"Html": "Collective\\Html\\HtmlFacade"
|
||||
}
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace Collective\Html;
|
||||
|
||||
use BadMethodCallException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
trait Componentable
|
||||
|
|
@ -47,7 +48,7 @@ trait Componentable
|
|||
* @param $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* @return HtmlString
|
||||
*/
|
||||
protected function renderComponent($name, array $arguments)
|
||||
{
|
||||
|
|
@ -81,7 +82,7 @@ trait Componentable
|
|||
$default = null;
|
||||
}
|
||||
|
||||
$data[$variable] = array_get($arguments, $i, $default);
|
||||
$data[$variable] = Arr::get($arguments, $i, $default);
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,11 +49,11 @@ trait FormAccessible
|
|||
unset($keys[0]);
|
||||
$key = implode('.', $keys);
|
||||
|
||||
if ($this->hasFormMutator($key)) {
|
||||
if (method_exists($relatedModel, 'hasFormMutator') && $key !== '' && $relatedModel->hasFormMutator($key)) {
|
||||
return $relatedModel->getFormValue($key);
|
||||
}
|
||||
|
||||
return data_get($relatedModel, $key);
|
||||
return data_get($relatedModel, empty($key)? null: $key);
|
||||
}
|
||||
|
||||
// No form mutator, let the model resolve this
|
||||
|
|
@ -69,11 +69,7 @@ trait FormAccessible
|
|||
*/
|
||||
public function isNestedModel($key)
|
||||
{
|
||||
if (in_array($key, array_keys($this->getRelations()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return in_array($key, array_keys($this->getRelations()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -81,13 +77,13 @@ trait FormAccessible
|
|||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasFormMutator($key)
|
||||
public function hasFormMutator($key)
|
||||
{
|
||||
$methods = $this->getReflection()->getMethods(ReflectionMethod::IS_PUBLIC);
|
||||
|
||||
$mutator = collect($methods)
|
||||
->first(function (ReflectionMethod $method) use ($key) {
|
||||
return $method->getName() == 'form' . Str::studly($key) . 'Attribute';
|
||||
return $method->getName() === 'form' . Str::studly($key) . 'Attribute';
|
||||
});
|
||||
|
||||
return (bool) $mutator;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use Illuminate\Contracts\Session\Session;
|
|||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
|
@ -49,6 +50,12 @@ class FormBuilder
|
|||
*/
|
||||
protected $csrfToken;
|
||||
|
||||
/**
|
||||
* Consider Request variables while auto fill.
|
||||
* @var bool
|
||||
*/
|
||||
protected $considerRequest = false;
|
||||
|
||||
/**
|
||||
* The session store implementation.
|
||||
*
|
||||
|
|
@ -108,6 +115,7 @@ class FormBuilder
|
|||
* @param \Illuminate\Contracts\Routing\UrlGenerator $url
|
||||
* @param \Illuminate\Contracts\View\Factory $view
|
||||
* @param string $csrfToken
|
||||
* @param Request $request
|
||||
*/
|
||||
public function __construct(HtmlBuilder $html, UrlGenerator $url, Factory $view, $csrfToken, Request $request = null)
|
||||
{
|
||||
|
|
@ -127,7 +135,7 @@ class FormBuilder
|
|||
*/
|
||||
public function open(array $options = [])
|
||||
{
|
||||
$method = array_get($options, 'method', 'post');
|
||||
$method = Arr::get($options, 'method', 'post');
|
||||
|
||||
// We need to extract the proper method from the attributes. If the method is
|
||||
// something other than GET or POST we'll use POST since we will spoof the
|
||||
|
|
@ -152,7 +160,7 @@ class FormBuilder
|
|||
// is used to spoof requests for this PUT, PATCH, etc. methods on forms.
|
||||
$attributes = array_merge(
|
||||
|
||||
$attributes, array_except($options, $this->reserved)
|
||||
$attributes, Arr::except($options, $this->reserved)
|
||||
|
||||
);
|
||||
|
||||
|
|
@ -191,6 +199,16 @@ class FormBuilder
|
|||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current model instance on the form builder.
|
||||
*
|
||||
* @return mixed $model
|
||||
*/
|
||||
public function getModel()
|
||||
{
|
||||
return $this->model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the current form.
|
||||
*
|
||||
|
|
@ -319,6 +337,20 @@ class FormBuilder
|
|||
return $this->input('password', $name, '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a range input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function range($name, $value = null, $options = [])
|
||||
{
|
||||
return $this->input('range', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hidden input field.
|
||||
*
|
||||
|
|
@ -454,6 +486,10 @@ class FormBuilder
|
|||
*/
|
||||
public function time($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('H:i');
|
||||
}
|
||||
|
||||
return $this->input('time', $name, $value, $options);
|
||||
}
|
||||
|
||||
|
|
@ -471,6 +507,24 @@ class FormBuilder
|
|||
return $this->input('url', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a week input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function week($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('Y-\WW');
|
||||
}
|
||||
|
||||
return $this->input('week', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file input field.
|
||||
*
|
||||
|
|
@ -517,7 +571,7 @@ class FormBuilder
|
|||
// the element. Then we'll create the final textarea elements HTML for us.
|
||||
$options = $this->html->attributes($options);
|
||||
|
||||
return $this->toHtmlString('<textarea' . $options . '>' . e($value). '</textarea>');
|
||||
return $this->toHtmlString('<textarea' . $options . '>' . e($value, false). '</textarea>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -536,9 +590,9 @@ class FormBuilder
|
|||
// If the "size" attribute was not specified, we will just look for the regular
|
||||
// columns and rows attributes, using sane defaults if these do not exist on
|
||||
// the attributes array. We'll then return this entire options array back.
|
||||
$cols = array_get($options, 'cols', 50);
|
||||
$cols = Arr::get($options, 'cols', 50);
|
||||
|
||||
$rows = array_get($options, 'rows', 10);
|
||||
$rows = Arr::get($options, 'rows', 10);
|
||||
|
||||
return array_merge($options, compact('cols', 'rows'));
|
||||
}
|
||||
|
|
@ -562,9 +616,10 @@ class FormBuilder
|
|||
*
|
||||
* @param string $name
|
||||
* @param array $list
|
||||
* @param string $selected
|
||||
* @param string|bool $selected
|
||||
* @param array $selectAttributes
|
||||
* @param array $optionsAttributes
|
||||
* @param array $optgroupsAttributes
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
|
|
@ -573,7 +628,8 @@ class FormBuilder
|
|||
$list = [],
|
||||
$selected = null,
|
||||
array $selectAttributes = [],
|
||||
array $optionsAttributes = []
|
||||
array $optionsAttributes = [],
|
||||
array $optgroupsAttributes = []
|
||||
) {
|
||||
$this->type = 'select';
|
||||
|
||||
|
|
@ -599,8 +655,9 @@ class FormBuilder
|
|||
}
|
||||
|
||||
foreach ($list as $value => $display) {
|
||||
$optionAttributes = isset($optionsAttributes[$value]) ? $optionsAttributes[$value] : [];
|
||||
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes);
|
||||
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||
$optgroupAttributes = $optgroupsAttributes[$value] ?? [];
|
||||
$html[] = $this->getSelectOption($display, $value, $selected, $optionAttributes, $optgroupAttributes);
|
||||
}
|
||||
|
||||
// Once we have all of this HTML, we can join this into a single element after
|
||||
|
|
@ -675,13 +732,14 @@ class FormBuilder
|
|||
* @param string $value
|
||||
* @param string $selected
|
||||
* @param array $attributes
|
||||
* @param array $optgroupAttributes
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function getSelectOption($display, $value, $selected, array $attributes = [])
|
||||
public function getSelectOption($display, $value, $selected, array $attributes = [], array $optgroupAttributes = [])
|
||||
{
|
||||
if (is_array($display)) {
|
||||
return $this->optionGroup($display, $value, $selected, $attributes);
|
||||
if (is_iterable($display)) {
|
||||
return $this->optionGroup($display, $value, $selected, $optgroupAttributes, $attributes);
|
||||
}
|
||||
|
||||
return $this->option($display, $value, $selected, $attributes);
|
||||
|
|
@ -694,18 +752,24 @@ class FormBuilder
|
|||
* @param string $label
|
||||
* @param string $selected
|
||||
* @param array $attributes
|
||||
* @param array $optionsAttributes
|
||||
* @param integer $level
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
protected function optionGroup($list, $label, $selected, array $attributes = [])
|
||||
protected function optionGroup($list, $label, $selected, array $attributes = [], array $optionsAttributes = [], $level = 0)
|
||||
{
|
||||
$html = [];
|
||||
|
||||
$space = str_repeat(" ", $level);
|
||||
foreach ($list as $value => $display) {
|
||||
$html[] = $this->option($display, $value, $selected, $attributes);
|
||||
$optionAttributes = $optionsAttributes[$value] ?? [];
|
||||
if (is_iterable($display)) {
|
||||
$html[] = $this->optionGroup($display, $value, $selected, $attributes, $optionAttributes, $level+5);
|
||||
} else {
|
||||
$html[] = $this->option($space.$display, $value, $selected, $optionAttributes);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<optgroup label="' . e($label) . '">' . implode('', $html) . '</optgroup>');
|
||||
return $this->toHtmlString('<optgroup label="' . e($space.$label, false) . '"' . $this->html->attributes($attributes) . '>' . implode('', $html) . '</optgroup>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -722,9 +786,14 @@ class FormBuilder
|
|||
{
|
||||
$selected = $this->getSelectedValue($value, $selected);
|
||||
|
||||
$options = ['value' => $value, 'selected' => $selected] + $attributes;
|
||||
$options = array_merge(['value' => $value, 'selected' => $selected], $attributes);
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
$string = '<option' . $this->html->attributes($options) . '>';
|
||||
if ($display !== null) {
|
||||
$string .= e($display, false) . '</option>';
|
||||
}
|
||||
|
||||
return $this->toHtmlString($string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -744,7 +813,7 @@ class FormBuilder
|
|||
'value' => '',
|
||||
];
|
||||
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display) . '</option>');
|
||||
return $this->toHtmlString('<option' . $this->html->attributes($options) . '>' . e($display, false) . '</option>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -762,8 +831,10 @@ class FormBuilder
|
|||
} elseif ($selected instanceof Collection) {
|
||||
return $selected->contains($value) ? 'selected' : null;
|
||||
}
|
||||
|
||||
return ((string) $value == (string) $selected) ? 'selected' : null;
|
||||
if (is_int($value) && is_bool($selected)) {
|
||||
return (bool)$value === $selected;
|
||||
}
|
||||
return ((string) $value === (string) $selected) ? 'selected' : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -844,7 +915,7 @@ class FormBuilder
|
|||
return $this->getRadioCheckedState($name, $value, $checked);
|
||||
|
||||
default:
|
||||
return $this->getValueAttribute($name) == $value;
|
||||
return $this->compareValues($name, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -865,7 +936,7 @@ class FormBuilder
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->missingOldAndModel($name) && !$request) {
|
||||
if ($this->missingOldAndModel($name) && is_null($request)) {
|
||||
return $checked;
|
||||
}
|
||||
|
||||
|
|
@ -897,6 +968,20 @@ class FormBuilder
|
|||
return $checked;
|
||||
}
|
||||
|
||||
return $this->compareValues($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the provide value loosely compares to the value assigned to the field.
|
||||
* Use loose comparison because Laravel model casting may be in affect and therefore
|
||||
* 1 == true and 0 == false.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function compareValues($name, $value)
|
||||
{
|
||||
return $this->getValueAttribute($name) == $value;
|
||||
}
|
||||
|
||||
|
|
@ -941,6 +1026,24 @@ class FormBuilder
|
|||
return $this->input('image', $name, null, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a month input field.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function month($name, $value = null, $options = [])
|
||||
{
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format('Y-m');
|
||||
}
|
||||
|
||||
return $this->input('month', $name, $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a color input field.
|
||||
*
|
||||
|
|
@ -985,6 +1088,50 @@ class FormBuilder
|
|||
return $this->toHtmlString('<button' . $this->html->attributes($options) . '>' . $value . '</button>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a datalist box field.
|
||||
*
|
||||
* @param string $id
|
||||
* @param array $list
|
||||
*
|
||||
* @return \Illuminate\Support\HtmlString
|
||||
*/
|
||||
public function datalist($id, $list = [])
|
||||
{
|
||||
$this->type = 'datalist';
|
||||
|
||||
$attributes['id'] = $id;
|
||||
|
||||
$html = [];
|
||||
|
||||
if ($this->isAssociativeArray($list)) {
|
||||
foreach ($list as $value => $display) {
|
||||
$html[] = $this->option($display, $value, null, []);
|
||||
}
|
||||
} else {
|
||||
foreach ($list as $value) {
|
||||
$html[] = $this->option($value, $value, null, []);
|
||||
}
|
||||
}
|
||||
|
||||
$attributes = $this->html->attributes($attributes);
|
||||
|
||||
$list = implode('', $html);
|
||||
|
||||
return $this->toHtmlString("<datalist{$attributes}>{$list}</datalist>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if an array is associative.
|
||||
*
|
||||
* @param array $array
|
||||
* @return bool
|
||||
*/
|
||||
protected function isAssociativeArray($array)
|
||||
{
|
||||
return (array_values($array) !== $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the form action method.
|
||||
*
|
||||
|
|
@ -996,7 +1143,7 @@ class FormBuilder
|
|||
{
|
||||
$method = strtoupper($method);
|
||||
|
||||
return $method != 'GET' ? 'POST' : $method;
|
||||
return $method !== 'GET' ? 'POST' : $method;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1098,7 +1245,7 @@ class FormBuilder
|
|||
// If the method is something other than GET we will go ahead and attach the
|
||||
// CSRF token to the form, as this can't hurt and is convenient to simply
|
||||
// always have available on every form the developers creates for them.
|
||||
if ($method != 'GET') {
|
||||
if ($method !== 'GET') {
|
||||
$appendage .= $this->token();
|
||||
}
|
||||
|
||||
|
|
@ -1140,7 +1287,7 @@ class FormBuilder
|
|||
|
||||
$old = $this->old($name);
|
||||
|
||||
if (! is_null($old) && $name != '_method') {
|
||||
if (! is_null($old) && $name !== '_method') {
|
||||
return $old;
|
||||
}
|
||||
|
||||
|
|
@ -1152,14 +1299,14 @@ class FormBuilder
|
|||
&& is_null($old)
|
||||
&& is_null($value)
|
||||
&& !is_null($this->view->shared('errors'))
|
||||
&& count($this->view->shared('errors')) > 0
|
||||
&& count(php_sapi_name() === 'cli' ? [] : $this->view->shared('errors')) > 0
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$request = $this->request($name);
|
||||
if (!is_null($request)) {
|
||||
if (! is_null($request) && $name != '_method') {
|
||||
return $request;
|
||||
}
|
||||
|
||||
|
|
@ -1172,6 +1319,15 @@ class FormBuilder
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take Request in fill process
|
||||
* @param bool $consider
|
||||
*/
|
||||
public function considerRequest($consider = true)
|
||||
{
|
||||
$this->considerRequest = $consider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value from current Request
|
||||
* @param $name
|
||||
|
|
@ -1179,6 +1335,10 @@ class FormBuilder
|
|||
*/
|
||||
protected function request($name)
|
||||
{
|
||||
if (!$this->considerRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!isset($this->request)) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1243,7 +1403,7 @@ class FormBuilder
|
|||
*/
|
||||
public function oldInputIsEmpty()
|
||||
{
|
||||
return (isset($this->session) && count($this->session->getOldInput()) == 0);
|
||||
return (isset($this->session) && count((array) $this->session->getOldInput()) === 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class HtmlBuilder
|
|||
{
|
||||
$attributes['src'] = $this->url->asset($url, $secure);
|
||||
|
||||
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>' . PHP_EOL);
|
||||
return $this->toHtmlString('<script' . $this->attributes($attributes) . '></script>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,11 +94,11 @@ class HtmlBuilder
|
|||
{
|
||||
$defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
|
||||
|
||||
$attributes = $attributes + $defaults;
|
||||
$attributes = array_merge($defaults, $attributes);
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -132,11 +132,11 @@ class HtmlBuilder
|
|||
{
|
||||
$defaults = ['rel' => 'shortcut icon', 'type' => 'image/x-icon'];
|
||||
|
||||
$attributes = $attributes + $defaults;
|
||||
$attributes = array_merge($defaults, $attributes);
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>' . PHP_EOL);
|
||||
return $this->toHtmlString('<link' . $this->attributes($attributes) . '>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -162,7 +162,7 @@ class HtmlBuilder
|
|||
$title = $this->entities($title);
|
||||
}
|
||||
|
||||
return $this->toHtmlString('<a href="' . $url . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||
return $this->toHtmlString('<a href="' . $this->entities($url) . '"' . $this->attributes($attributes) . '>' . $title . '</a>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -357,7 +357,7 @@ class HtmlBuilder
|
|||
{
|
||||
$html = '';
|
||||
|
||||
if (count($list) == 0) {
|
||||
if (count($list) === 0) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
|
@ -387,7 +387,7 @@ class HtmlBuilder
|
|||
if (is_array($value)) {
|
||||
return $this->nestedListing($key, $type, $value);
|
||||
} else {
|
||||
return '<li>' . e($value) . '</li>';
|
||||
return '<li>' . e($value, false) . '</li>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -451,12 +451,16 @@ class HtmlBuilder
|
|||
}
|
||||
|
||||
// Treat boolean attributes as HTML properties
|
||||
if (is_bool($value) && $key != 'value') {
|
||||
if (is_bool($value) && $key !== 'value') {
|
||||
return $value ? $key : '';
|
||||
}
|
||||
|
||||
if (is_array($value) && $key === 'class') {
|
||||
return 'class="' . implode(' ', $value) . '"';
|
||||
}
|
||||
|
||||
if (! is_null($value)) {
|
||||
return $key . '="' . e($value) . '"';
|
||||
return $key . '="' . e($value, false) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -511,7 +515,7 @@ class HtmlBuilder
|
|||
|
||||
$attributes = array_merge($defaults, $attributes);
|
||||
|
||||
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
|
||||
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -525,8 +529,8 @@ class HtmlBuilder
|
|||
*/
|
||||
public function tag($tag, $content, array $attributes = [])
|
||||
{
|
||||
$content = is_array($content) ? implode(PHP_EOL, $content) : $content;
|
||||
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . PHP_EOL . $this->toHtmlString($content) . PHP_EOL . '</' . $tag . '>' . PHP_EOL);
|
||||
$content = is_array($content) ? implode('', $content) : $content;
|
||||
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . $this->toHtmlString($content) . '</' . $tag . '>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue