protected function parseAttributes($str, $offset)
{
if ($str === '') {
return array();
}
$pattern = '/([\\w\\.\\-]+)\\s*=\\s*(\'.*?\'|".*?"|<%.*?%>)/msS';
$attributes = array();
$n = preg_match_all($pattern, $str, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
for ($i = 0; $i < $n; ++$i) {
$match =& $matches[$i];
$name = strtolower($match[1][0]);
if (isset($attributes[$name])) {
throw new TConfigurationException('template_property_duplicated', $name);
}
$value = $match[2][0];
if (substr($name, -8, 8) === 'template') {
if ($value[0] === '\'' || $value[0] === '"') {
$attributes[$name] = $this->parseTemplateProperty(substr($value, 1, strlen($value) - 2), $match[2][1] + 1);
} else {
$attributes[$name] = $this->parseTemplateProperty($value, $match[2][1]);
}
} else {
if ($value[0] === '\'' || $value[0] === '"') {
$attributes[$name] = $this->parseAttribute(substr($value, 1, strlen($value) - 2));
} else {
$attributes[$name] = $this->parseAttribute($value);
}
}
}
return $attributes;
}