Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replaced Flash embedding with HTML5 version in XmlRenderer.

  • Loading branch information...
commit a7b148b401c10a123b5f5dbd032f96c01a9b0748 1 parent 54ab4a5
@mermshaus authored
View
12 src/Kaloa/Renderer/Xml/Rule/YouTubeRule.php
@@ -18,16 +18,8 @@ public function render()
$id = $node->getAttribute('id');
$xml = <<<EOT
-<div class="blog_youtube_container" style="width: 400px; height: 300px;">
-<object type="application/x-shockwave-flash"
- class="blog_youtube"
- style="display: block; width: 100%; height: 100%;"
- data="http://www.youtube.com/v/$id"
->
- <param name="movie"
- value="http://www.youtube.com/v/$id&amp;hl=en&amp;fs=0"
- />
-</object>
+<div class="videoWrapper">
+<iframe src="http://www.youtube.com/embed/$id" frameborder="0"></iframe>
</div>
EOT;
View
18 src/Kaloa/Renderer/XmlRenderer.php
@@ -40,6 +40,17 @@ protected function decodeEntitiesFromXml($xmlString)
return $retVal;
}
+ /**
+ * http://www.php.net/manual/en/domdocument.savexml.php#95252
+ */
+ protected function xml2xhtml($xml)
+ {
+ return preg_replace_callback('#<(\w+)([^>]*)\s*/>#s', create_function('$m', '
+ $xhtml_tags = array("br", "hr", "input", "frame", "img", "area", "link", "col", "base", "basefont", "param");
+ return in_array($m[1], $xhtml_tags) ? "<$m[1]$m[2] />" : "<$m[1]$m[2]></$m[1]>";
+ '), $xml);
+ }
+
public function registerRule(AbstractRule $rule, $weight = 0)
{
if (!isset($this->rules[$weight])) {
@@ -81,7 +92,12 @@ public function render($xmlCode)
}
}
- return preg_replace('!<root[^>]*>(.*)</root>!s', '$1', $xmldoc->saveXML($xmldoc->documentElement));
+ $s = preg_replace('!<root[^>]*>(.*)</root>!s', '$1', $xmldoc->saveXML($xmldoc->documentElement));
+
+ // Handle self-closing tags
+ $s = $this->xml2xhtml($s);
+
+ return $s;
}
public function firePreSaveEvent($xmlCode)
Please sign in to comment.
Something went wrong with that request. Please try again.