From: <var...@us...> - 2009-01-01 19:52:32
|
Revision: 6360 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6360&view=rev Author: vargenau Date: 2009-01-01 19:52:28 +0000 (Thu, 01 Jan 2009) Log Message: ----------- Use parse_attributes function from stdlib Modified Paths: -------------- trunk/lib/plugin/MediawikiTable.php Modified: trunk/lib/plugin/MediawikiTable.php =================================================================== --- trunk/lib/plugin/MediawikiTable.php 2009-01-01 19:50:23 UTC (rev 6359) +++ trunk/lib/plugin/MediawikiTable.php 2009-01-01 19:52:28 UTC (rev 6360) @@ -90,7 +90,7 @@ } if (($lines[0][0] != '|') and ($lines[0][0] != '!')) { $line = array_shift($lines); - $attrs = $this->_parse_attr($line); + $attrs = parse_attributes($line); foreach ($attrs as $key => $value) { if (in_array ($key, array("id", "class", "title", "style", "bgcolor", "frame", "rules", "border", @@ -126,7 +126,7 @@ } } $row = HTML::tr(); - $attrs = $this->_parse_attr(substr($line,2)); + $attrs = parse_attributes(substr($line,2)); foreach ($attrs as $key => $value) { if (in_array ($key, array("id", "class", "title", "style", "bgcolor", "align", "valign"))) { @@ -144,7 +144,7 @@ $pospipe = strpos($line, "|"); $posbracket = strpos($line, "["); if (($pospipe !== false) && (($posbracket === false) || ($posbracket > $pospipe))) { - $attrs = $this->_parse_attr(substr($line, 0, $pospipe)); + $attrs = parse_attributes(substr($line, 0, $pospipe)); foreach ($attrs as $key => $value) { if (in_array ($key, array("id", "class", "title", "style", "align", "lang"))) { @@ -188,7 +188,7 @@ $pospipe = strpos($line, "|"); $posbracket = strpos($line, "["); if (($pospipe !== false) && (($posbracket === false) || ($posbracket > $pospipe))) { - $attrs = $this->_parse_attr(substr($line, 0, $pospipe)); + $attrs = parse_attributes(substr($line, 0, $pospipe)); foreach ($attrs as $key => $value) { if (in_array ($key, array("id", "class", "title", "style", "colspan", "rowspan", "width", "height", @@ -219,23 +219,6 @@ } return $table; } - - function _parse_attr($line) { - // We allow attributes with or without quotes (") - // border=1, cellpadding="5" - // style="font-family: sans-serif; border-top:1px solid #dddddd;" - // What will not work is style with comma inside, e. g. - // style="font-family: Verdana, Arial, Helvetica, sans-serif" - $attr_chunks = preg_split("/\s*,\s*/", strtolower($line)); - $options = array(); - foreach ($attr_chunks as $attr_pair) { - if (empty($attr_pair)) continue; - $key_val = preg_split("/\s*=\s*/", $attr_pair); - if (!empty($key_val[1])) - $options[trim($key_val[0])] = trim(str_replace("\"", "", $key_val[1])); - } - return $options; - } } // For emacs users This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |