public function doParseTag(&$name, &$data)
{
$field = null;
switch (strtolower($name)) {
case 'input':
$type = null;
if (preg_match('#type="(.+)"#mUsi', $data, $match)) {
$type = $match[1];
}
if (!$type) {
$type = self::$fallback;
}
if ($type === 'submit') {
return '<' . $name . ' ' . $data . '>';
}
$field = $this->factory->getField($type);
break;
case 'form':
case 'textarea':
case 'select':
case 'option':
case 'options':
case 'custom':
case 'multiple':
$field = $this->factory->getObject($name);
break;
case '/textarea':
return '</textarea>';
break;
case '/select':
return '</select>';
break;
case '/option':
return "</option>";
break;
case '/form':
return '</form>';
break;
default:
if (!$data) {
return "<{$name}>";
} else {
return "<{$name} {$data}>";
}
break;
}
if (null !== $field) {
$data = preg_replace_callback('#="([^"]+)"#mUsi', function ($matches) {
return '="' . urlencode($matches[1]) . '"';
}, $data);
$attributes = explode(' ', $data);
foreach ($attributes as $attribute) {
if (preg_match("#([^=]+)(=\"(.+)\"|)#muSi", $attribute, $match)) {
$field->push($match[1], isset($match[3]) ? html_entity_decode(urldecode($match[3])) : null);
}
}
return $field;
} else {
return '';
}
}