protected function doExtraAttributes($tag_name, $attr)
{
#
# Parse attributes caught by the $this->id_class_attr_catch_re expression
# and return the HTML-formatted list of attributes.
#
# Currently supported attributes are .class and #id.
#
if (empty($attr)) {
return "";
}
# Split on components
preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches);
$elements = $matches[0];
# handle classes and ids (only first id taken into account)
$classes = array();
$attributes = array();
$id = false;
foreach ($elements as $element) {
if ($element[0] == '.') {
$classes[] = substr($element, 1);
} elseif ($element[0] == '#') {
if ($id === false) {
$id = substr($element, 1);
}
} elseif (strpos($element, '=') > 0) {
$parts = explode('=', $element, 2);
$attributes[] = $parts[0] . '="' . $parts[1] . '"';
}
}
# compose attributes as string
$attr_str = "";
if (!empty($id)) {
$attr_str .= ' id="' . $id . '"';
}
if (!empty($classes)) {
$attr_str .= ' class="' . implode(" ", $classes) . '"';
}
if (!$this->no_markup && !empty($attributes)) {
$attr_str .= ' ' . implode(" ", $attributes);
}
return $attr_str;
}