Get a string of attributes given the attributes as an array
@param array $attribs
@param $leading_space
@return string
339598
public static function attribs($attribs, $leading_space = true)
    {
        if (!Arr::iterable($attribs)) {
            return '';
        }
        
        $out = array();
        foreach ($attribs as $k => $v) {
            $v = (is_array($v)) ? join(' ', $v) : $v;
            $out[] = $k . '="' . str_replace('"', '\"', $v) . '"';
        }
        return (($leading_space) ? ' ' : '') . join(' ', $out);
    }
1054753
public function getMissingAttribs()
    {
        return array_combine(
            array_keys($this->missingAttribs),
            array_map(function ($ref) {
                return $ref['attrib'];
            }, array_values($this->missingAttribs))
        );
    }
201741
private function applyAttribs(Tokens $tokens, $index, array $attribs)
    {
        $toInsert = [];

        foreach ($attribs as $attrib) {
            if (null !== $attrib && '' !== $attrib->getContent()) {
                $toInsert[] = $attrib;
                $toInsert[] = new Token([T_WHITESPACE, ' ']);
            }
        }

        if (!empty($toInsert)) {
            $tokens->insertAt($index, $toInsert);
        }
    }
771707
public function attributable(array $attributes, array $defaults = []): string
    {
        return $this->attributes($this->decorate($attributes, $defaults));
    }
689042
function _getAttributesAsJson(attrs) {
  var rval = {};
  for(var i = 0; i < attrs.length; ++i) {
    var attr = attrs[i];
    if(attr.shortName && (
      attr.valueTagClass === asn1.Type.UTF8 ||
      attr.valueTagClass === asn1.Type.PRINTABLESTRING ||
      attr.valueTagClass === asn1.Type.IA5STRING)) {
      var value = attr.value;
      if(attr.valueTagClass === asn1.Type.UTF8) {
        value = forge.util.encodeUtf8(attr.value);
      }
      if(!(attr.shortName in rval)) {
        rval[attr.shortName] = value;
      } else if(forge.util.isArray(rval[attr.shortName])) {
        rval[attr.shortName].push(value);
      } else {
        rval[attr.shortName] = [rval[attr.shortName], value];
      }
    }
  }
  return rval;
}
706230
public static function getAttributesCollection($attributes, $padding=1) {
      /** one space to seperate namespace **/
      $attrs = str_repeat(" ", $padding);
      foreach ($attributes as $attr) {
        $attrs .= $attr->getKey() . "=" . '"' . $attr->getValue() . '" ';
      }

      return substr($attrs, 0, strlen($attrs) - 1);
    }
1123477
public function charset_selector($attrib)
    {
        // pass the following attributes to the form class
        $field_attrib = array('name' => '_charset');
        foreach ($attrib as $attr => $value) {
            if (in_array($attr, array('id', 'name', 'class', 'style', 'size', 'tabindex'))) {
                $field_attrib[$attr] = $value;
            }
        }

        $charsets = array(
            'UTF-8'        => 'UTF-8 ('.$this->app->gettext('unicode').')',
            'US-ASCII'     => 'ASCII ('.$this->app->gettext('english').')',
            'ISO-8859-1'   => 'ISO-8859-1 ('.$this->app->gettext('westerneuropean').')',
            'ISO-8859-2'   => 'ISO-8859-2 ('.$this->app->gettext('easterneuropean').')',
            'ISO-8859-4'   => 'ISO-8859-4 ('.$this->app->gettext('baltic').')',
            'ISO-8859-5'   => 'ISO-8859-5 ('.$this->app->gettext('cyrillic').')',
            'ISO-8859-6'   => 'ISO-8859-6 ('.$this->app->gettext('arabic').')',
            'ISO-8859-7'   => 'ISO-8859-7 ('.$this->app->gettext('greek').')',
            'ISO-8859-8'   => 'ISO-8859-8 ('.$this->app->gettext('hebrew').')',
            'ISO-8859-9'   => 'ISO-8859-9 ('.$this->app->gettext('turkish').')',
            'ISO-8859-10'   => 'ISO-8859-10 ('.$this->app->gettext('nordic').')',
            'ISO-8859-11'   => 'ISO-8859-11 ('.$this->app->gettext('thai').')',
            'ISO-8859-13'   => 'ISO-8859-13 ('.$this->app->gettext('baltic').')',
            'ISO-8859-14'   => 'ISO-8859-14 ('.$this->app->gettext('celtic').')',
            'ISO-8859-15'   => 'ISO-8859-15 ('.$this->app->gettext('westerneuropean').')',
            'ISO-8859-16'   => 'ISO-8859-16 ('.$this->app->gettext('southeasterneuropean').')',
            'WINDOWS-1250' => 'Windows-1250 ('.$this->app->gettext('easterneuropean').')',
            'WINDOWS-1251' => 'Windows-1251 ('.$this->app->gettext('cyrillic').')',
            'WINDOWS-1252' => 'Windows-1252 ('.$this->app->gettext('westerneuropean').')',
            'WINDOWS-1253' => 'Windows-1253 ('.$this->app->gettext('greek').')',
            'WINDOWS-1254' => 'Windows-1254 ('.$this->app->gettext('turkish').')',
            'WINDOWS-1255' => 'Windows-1255 ('.$this->app->gettext('hebrew').')',
            'WINDOWS-1256' => 'Windows-1256 ('.$this->app->gettext('arabic').')',
            'WINDOWS-1257' => 'Windows-1257 ('.$this->app->gettext('baltic').')',
            'WINDOWS-1258' => 'Windows-1258 ('.$this->app->gettext('vietnamese').')',
            'ISO-2022-JP'  => 'ISO-2022-JP ('.$this->app->gettext('japanese').')',
            'ISO-2022-KR'  => 'ISO-2022-KR ('.$this->app->gettext('korean').')',
            'ISO-2022-CN'  => 'ISO-2022-CN ('.$this->app->gettext('chinese').')',
            'EUC-JP'       => 'EUC-JP ('.$this->app->gettext('japanese').')',
            'EUC-KR'       => 'EUC-KR ('.$this->app->gettext('korean').')',
            'EUC-CN'       => 'EUC-CN ('.$this->app->gettext('chinese').')',
            'BIG5'         => 'BIG5 ('.$this->app->gettext('chinese').')',
            'GB2312'       => 'GB2312 ('.$this->app->gettext('chinese').')',
        );

        if ($post = rcube_utils::get_input_value('_charset', rcube_utils::INPUT_POST)) {
            $set = $post;
        }
        else if (!empty($attrib['selected'])) {
            $set = $attrib['selected'];
        }
        else {
            $set = $this->get_charset();
        }

        $set = strtoupper($set);
        if (!isset($charsets[$set]) && preg_match('/^[A-Z0-9-]+$/', $set)) {
            $charsets[$set] = $set;
        }

        $select = new html_select($field_attrib);
        $select->add(array_values($charsets), array_keys($charsets));

        return $select->show($set);
    }
247706
public function setAttrib($attribName, $attribDefinition = null)
    {
        $this->attribs[$attribName] = is_object($attribDefinition) && $attribDefinition instanceof \DataFilter\Attribute
            ? $attribDefinition
            : new \DataFilter\Attribute($attribName, $attribDefinition, $this);
        return $this->attribs[$attribName];
    }
566132
private function parseAttributes($columnName, array $attrs, $isCreate = true) {
        $return = $this->checkType($columnName, $attrs); // type

        if (strtolower($attrs['type']) === 'timestamp' && !isset($attrs['attrs']['default'])) {
            $attrs['attrs']['default'] = '"0000-00-00 00:00:00"';
        }

        if (isset($attrs['attrs']['size']))
            $return .= '(' . $attrs['attrs']['size'] . ')'; // size

        if (isset($attrs['attrs']['collation'])) {
            if (!isset($attrs['attrs']['charset']))
                $attrs['attrs']['charset'] = stristr($attrs['attrs']['collation'], '_', true);

            $return .= ' CHARACTER SET ' . $attrs['attrs']['charset'] . ' COLLATE ' . $attrs['attrs']['collation'];
        }

        $return .= (isset($attrs['attrs']['nullable']) && strtolower($attrs['attrs']['nullable']) == 'true') ? ' NULL' : ' NOT NULL'; // null

        if (isset($attrs['attrs']['default'])) { // auto increment
            if (strtolower($attrs['type']) === 'boolean') {
                if ($attrs['attrs']['default'] === 'true') {
                    $attrs['attrs']['default'] = 1;
                }
                else {
                    $attrs['attrs']['default'] = 0;
                }
            }

            $return .= (trim(strtolower($attrs['type'])) == 'timestamp') ? ' DEFAULT ' . $attrs['attrs']['default'] : ' DEFAULT "' . $attrs['attrs']['default'] . '"';
        }

        if (isset($attrs['attrs']['autoIncrement']) && $attrs['attrs']['autoIncrement'] == 'true') // auto increment
            $return .= ' AUTO_INCREMENT';
        if (!$isCreate) {
            if (!empty($attrs['attrs']['after']))
                $return .= ' AFTER `' . $attrs['attrs']['after'] . '`';
            else if (isset($attrs['attrs']['first']) && $attrs['attrs']['first'])
                $return .= ' FIRST';
        }
        if (isset($attrs['attrs']['onUpdate']) && $attrs['type'] !== 'ReferenceMany') // auto increment
            $return .= ' ON UPDATE ' . $attrs['attrs']['onUpdate'];

        return $return;
    }
1072949
public function getAttributes($names = null)
    {
        $values = [];
        foreach ($this->attributeNames() as $name) {
            $values[$name] = $this->{$name};
        }

        if (is_array($names)) {
            $values2 = [];
            foreach ($names as $name) {
                $values2[$name] = isset($values[$name]) ? $values[$name] : null;
            }
            return $values2;
        }
        return $values;
    }
972335
protected function getAttributesCSS(array $attr)
    {
        $output = [];
        foreach ($attr as $key => $values) {
            if (in_array($key, $this->attributesCss) && $values !== '') {
                $output[] = $key . '="' . $values . '"';
            }
        }
        $implode = implode(' ', $output);

        return $implode
            ? " $implode"
            : '';
    }
1134738
public static function element( $element, array $attribs = array(), $content = '' ) {
		return self::rawElement( $element, $attribs, strtr( $content, array(
			'&' => '&amp;',
			'<' => '&lt;',
		) ) );
	}
1314415
public function getAttr($obj, $attr, $args = [])
    {
        if (is_array($obj)) {
            if (isset($obj[$attr])) {
                if ($obj[$attr] instanceof \Closure) {
                    if (is_array($args)) {
                        array_unshift($args, $obj);
                    } else {
                        $args = [$obj];
                    }

                    return call_user_func_array($obj[$attr], $args);
                }

                return $obj[$attr];
            }

            return null;
        } elseif (is_object($obj)) {
            if (is_array($args)) {
                $callable = [$obj, $attr];

                return is_callable($callable) ?
                    call_user_func_array($callable, $args) : null;
            }
            $members = array_keys(get_object_vars($obj));
            $methods = get_class_methods(get_class($obj));
            if (in_array($attr, $members)) {
                return @$obj->$attr;
            } elseif (in_array('__get', $methods)) {
                return $obj->__get($attr);
            }
            $callable = [$obj, $attr];

            return is_callable($callable) ?
                call_user_func($callable) : null;
        }

        return null;
    }
152420
public static function parse_attrib_string($str)
    {
        $attrib = array();
        $html   = '<html>'
            . '<head><meta http-equiv="Content-Type" content="text/html; charset=' . RCUBE_CHARSET . '" /></head>'
            . '<body><div ' . rtrim($str, '/ ') . ' /></body>'
            . '</html>';

        $document = new DOMDocument('1.0', RCUBE_CHARSET);
        @$document->loadHTML($html);

        if ($node = $document->getElementsByTagName('div')->item(0)) {
            foreach ($node->attributes as $name => $attr) {
                $attrib[strtolower($name)] = $attr->nodeValue;
            }
        }

        return $attrib;
    }
934312
public function getAttributes()
    {

        // initialize the array with the attributes
        $attributes = array();

        // prepare the pattern to filter the attributes
        $pattern = sprintf('%s-*', $this->getSerial());

        // prepare the array with the attributes
        foreach ($this as $key => $value) {
            if (fnmatch($pattern, $key)) {
                $attributes[$key] = $value;
            }
        }

        // return the attributes
        return $attributes;
    }
1371036
public function setCustomHtmlAttribs(array $attribs)
        {
            foreach ($attribs as $key => $value) {
                $this->setCustomHtmlAttrib($key, $value);
            }
            return $this;
        }
582030
protected function parseAttr($attrs, &$result, $visible = true)
    {
        $array = [];

        foreach ($attrs as $key => $val) {
            if (is_array($val)) {
                if ($visible) {
                    $array[] = $key;
                }

                $result[$key] = $val;
            } elseif (strpos($val, '.')) {
                list($key, $name) = explode('.', $val);

                if ($visible) {
                    $array[] = $key;
                }

                $result[$key][] = $name;
            } else {
                $array[] = $val;
            }
        }

        return $array;
    }