attributes() public method

Build an HTML attribute string from an array.
public attributes ( array $attributes ) : string
$attributes array
return string
 /**
  * Create <div> tag for a reCAPTCHA widget
  *
  * @param  array $options
  *
  * @return string
  */
 public function widget(array $options = [])
 {
     $options['sitekey'] = $this->siteKey;
     if (isset($options['class'])) {
         $options['class'] .= ' ' . $this->recaptchaClass;
     } else {
         $options['class'] = $this->recaptchaClass;
     }
     $this->renameOptions($options);
     return '<div' . $this->html->attributes($options) . '></div>' . PHP_EOL;
 }
 /**
  * Create a button element.
  *
  * @param  string  $value
  * @param  array   $options
  * @return string
  */
 public function button($value = null, $options = array())
 {
     if (!array_key_exists('type', $options)) {
         $options['type'] = 'button';
     }
     return '<button' . $this->html->attributes($options) . '>' . $value . '</button>';
 }
Beispiel #3
0
 /**
  * Return an array of style tags.
  *
  * @param        $collection
  * @param  array $filters
  * @param  array $attributes
  * @return array
  */
 public function styles($collection, array $filters = [], array $attributes = [])
 {
     return array_map(function ($path) use($attributes) {
         $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];
         $attributes = $attributes + $defaults;
         $attributes['href'] = $path;
         return '<link' . $this->html->attributes($attributes) . '>';
     }, $this->paths($collection, $filters));
 }
Beispiel #4
0
 /**
  * Compile table headers and to support responsive extension.
  *
  * @return array
  */
 private function compileTableHeaders()
 {
     $th = [];
     foreach ($this->collection->toArray() as $row) {
         $thAttr = $this->html->attributes(array_only($row, ['class', 'id', 'width', 'style', 'data-class', 'data-hide']));
         $th[] = '<th ' . $thAttr . '>' . $row['title'] . '</th>';
     }
     return $th;
 }
Beispiel #5
0
 /**
  * Create a button element.
  *
  * @param  string  $value
  * @param  array   $options
  * @param  bool    $escape
  *
  * @return \Illuminate\Support\HtmlString
  */
 public function button($value = null, $options = [], $escape = true)
 {
     if (!array_key_exists('type', $options)) {
         $options['type'] = 'button';
     }
     if ($escape) {
         $value = $this->html->entities($value);
     }
     return $this->toHtmlString('<button' . $this->html->attributes($options) . '>' . $value . '</button>');
 }
 public function attributes($attributes)
 {
     $name_prefix = keyVal('name_prefix', $attributes, $this->name_prefix);
     if ($name_prefix && is_array($attributes) && array_key_exists('name', $attributes)) {
         $attributes['name'] = $name_prefix . '[' . $attributes['name'] . ']';
     }
     if (is_array($attributes)) {
         unset($attributes['name_prefix']);
     }
     /** Automate using BS4 tether Tooltips */
     if (is_array($attributes) && array_key_exists('tooltip', $attributes)) {
         $attributes['data-toggle'] = 'tooltip';
         $attributes['title'] = html_encode($attributes['tooltip']);
         unset($attributes['tooltip']);
     }
     unset($attributes['']);
     unset($attributes[null]);
     unset($attributes[0]);
     return parent::attributes($attributes);
 }
Beispiel #7
0
 /**
  * Build an HTML attribute string from an array.
  *
  * @param array $attributes
  * @return string 
  * @static 
  */
 public static function attributes($attributes)
 {
     return \Collective\Html\HtmlBuilder::attributes($attributes);
 }
 /**
  * Get a form group.
  *
  * @param  string $name
  * @param  string $element
  *
  * @return string
  */
 public function getFormGroup($name = null, $element)
 {
     $options = $this->getFormGroupOptions($name);
     return '<div' . $this->html->attributes($options) . '>' . $element . '</div>';
 }
Beispiel #9
0
 /**
  * Converts the defined attributes into HTML.
  *
  * @param  array  $attributes
  * @return string
  */
 public function attributes($attributes = array())
 {
     return $this->html->attributes($attributes);
 }
Beispiel #10
0
 /**
  * Get a form group.
  *
  * @param  string  $name
  * @param  string  $element
  * @return string
  */
 public function getFormGroup($name = null, $element, $extra = null)
 {
     $options = $this->getFormGroupOptions($name);
     $element = substr($element, 0, strlen($element) - 6) . $extra . substr($element, -6);
     return '<div' . $this->html->attributes($options) . '>' . $element . '</div>';
 }
 /**
  * Generate DataTable's table html
  *
  * @param  array $attributes
  * @return string
  */
 public function table(array $attributes = [])
 {
     $this->tableAttributes = $attributes ?: $this->tableAttributes;
     return '<table' . $this->html->attributes($this->tableAttributes) . '></table>';
 }
Beispiel #12
0
 /**
  * Generate DataTable's table html.
  *
  * @param  array $attributes
  * @return string
  */
 public function table(array $attributes = [])
 {
     $this->tableAttributes = array_merge($this->tableAttributes, $attributes);
     return '<table ' . $this->html->attributes($this->tableAttributes) . '></table>';
 }
Beispiel #13
0
 /**
  * Return a source tag.
  *
  * @return string
  */
 public function source()
 {
     $this->addAttribute('srcset', $this->srcset() ?: $this->path() . ' 2x, ' . $this->path() . ' 1x');
     $attributes = $this->html->attributes($this->getAttributes());
     if ($srcset = $this->srcset()) {
         $attributes['srcset'] = $srcset;
     }
     return "<source {$attributes}>";
 }