Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c55fda58b1 | ||
|
|
8ae4aa0627 | ||
|
|
4edbd282ba | ||
|
|
3166c19203 | ||
|
|
daae1062da | ||
|
|
55eb889aca | ||
|
|
e884f50d1c | ||
|
|
52e297e679 | ||
|
|
c3a3a44a37 | ||
|
|
19860865d1 | ||
|
|
6b023d8055 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
# Forms & HTML
|
||||
|
||||
[](https://travis-ci.org/LaravelCollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
[](https://packagist.org/packages/laravelcollective/html)
|
||||
|
||||
+4
-4
@@ -575,7 +575,7 @@ class FormBuilder {
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $selected
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
protected function getSelectedValue($value, $selected)
|
||||
{
|
||||
@@ -908,7 +908,7 @@ class FormBuilder {
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValueAttribute($name, $value = null)
|
||||
{
|
||||
@@ -931,7 +931,7 @@ class FormBuilder {
|
||||
* Get the model value that should be assigned to the field.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getModelValueAttribute($name)
|
||||
{
|
||||
@@ -949,7 +949,7 @@ class FormBuilder {
|
||||
* Get a value from the session's old input.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
* @return mixed
|
||||
*/
|
||||
public function old($name)
|
||||
{
|
||||
|
||||
+22
-3
@@ -96,6 +96,25 @@ class HtmlBuilder {
|
||||
|
||||
return '<img src="'.$this->url->asset($url, $secure).'"'.$this->attributes($attributes).'>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a link to a Favicon file.
|
||||
*
|
||||
* @param string $url
|
||||
* @param array $attributes
|
||||
* @param bool $secure
|
||||
* @return string
|
||||
*/
|
||||
public function favicon($url, $attributes = array(), $secure = null)
|
||||
{
|
||||
$defaults = array('rel' => 'shortcut icon', 'type' => 'image/x-icon');
|
||||
|
||||
$attributes = $attributes + $defaults;
|
||||
|
||||
$attributes['href'] = $this->url->asset($url, $secure);
|
||||
|
||||
return '<link'.$this->attributes($attributes).'>'.PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a HTML link.
|
||||
@@ -339,9 +358,6 @@ class HtmlBuilder {
|
||||
{
|
||||
$html = array();
|
||||
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
foreach ((array) $attributes as $key => $value)
|
||||
{
|
||||
$element = $this->attributeElement($key, $value);
|
||||
@@ -361,6 +377,9 @@ class HtmlBuilder {
|
||||
*/
|
||||
protected function attributeElement($key, $value)
|
||||
{
|
||||
// For numeric keys we will assume that the key and the value are the same
|
||||
// as this will convert HTML attributes such as "required" to a correct
|
||||
// form like required="required" instead of using incorrect numerics.
|
||||
if (is_numeric($key)) $key = $value;
|
||||
|
||||
if ( ! is_null($value)) return $key.'="'.e($value).'"';
|
||||
|
||||
@@ -61,7 +61,7 @@ class HtmlServiceProvider extends ServiceProvider {
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return array('html', 'form');
|
||||
return array('html', 'form', 'Collective\Html\HtmlBuilder', 'Collective\Html\FormBuilder');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase {
|
||||
$this->assertEquals('<meta content="website" property="og:type">'.PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
public function testFavicon()
|
||||
{
|
||||
$this->urlGenerator->forceRootUrl('http://foo.com');
|
||||
$target = $this->urlGenerator->to('bar.ico');
|
||||
$result = $this->htmlBuilder->favicon('http://foo.com/bar.ico');
|
||||
|
||||
$this->assertEquals('<link rel="shortcut icon" type="image/x-icon" href="'.$target.'">' . PHP_EOL, $result);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user