function preparse_attributes($x) { # Creating a temporary new parser to run the attribute list in $np = new wiki2xml(); $np->inherit($this); $np->w = $x; $np->wl = strlen($x); # Replacing templates, and '<' and '>' in parameters $c = 0; $q = ""; while ($q != "" || $c < $np->wl && $np->w[$c] != '>' && $np->w[$c] != '/') { $y = $np->w[$c]; if ($np->nextis($c, "{{", false)) { $xx = ""; if ($np->p_template($c, $xx)) { continue; } else { $c++; } } else { if ($y == "'" || $y == '"') { if ($q == "") { $q = $y; } else { if ($y == $q) { $q = ""; } } $c++; } else { if ($q != "" && ($y == '<' || $y == '>')) { $y = htmlentities($y); $np->w = substr($np->w, 0, $c) . $y . substr($np->w, $c + 1); $np->wl += strlen($y) - 1; } else { $c++; } } } if ($c >= $np->wl) { return array(); } } $attrs = array(); $c = 0; # Seeking attributes while ($np->w[$c] != '>' && $np->w[$c] != '/') { $attr = ""; if (!$np->p_html_attr($c, $attr)) { break; } if ($attr != "") { $key = array_shift(explode("=", $attr, 2)); if (!isset($attrs[$key]) && substr($attr, -3, 3) != '=""') { $attrs[$key] = $attr; } } $np->skipblanks($c); if ($c >= $np->wl) { return array(); } } if (substr($np->w, $c) != ">" and substr($np->w, $c) != "/") { return array(); } return $attrs; }