protected function WordPressItemMigration::replaceFlashEmbeds in WordPress Migrate 7.2
Replace a kml_flashembed tag with an HTML <object> tag.
[kml_flashembed movie="http://example.com/video/soundslider.swf" FVARS="size=0" height="368" width="420" /] <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="fm_soundslider_1640275925" class="flashmovie" width="420" height="368"> <param name="movie" value="http://example.com/video/soundslider.swf"" /> <param name="flashvars" value="size=0" /> <!--[if !IE]>--> <object type="application/x-shockwave-flash" data="http://example.com/video/soundslider.swf"" name="fm_soundslider_1640275925" width="420" height="368"> <param name="flashvars" value="size=0" /> <!--<![endif]-->
<!--[if !IE]>--> </object> <!--<![endif]--> </object>
Parameters
array $matches:
File
- ./
wordpress_item.inc, line 605 - Support for migrating posts and pages from a WordPress blog into Drupal.
Class
- WordPressItemMigration
- Intermediate Migration class, implementing behavior common across different types (post_type) of items.
Code
protected function replaceFlashEmbeds(array $matches) {
$attribute_matches = array();
$attribute_string = '';
preg_match_all('|(?P<name>\\w+)="(?P<value>.*?)"|', $matches[0], $attribute_matches);
foreach ($attribute_matches['name'] as $delta => $name) {
$value = $attribute_matches['value'][$delta];
switch (drupal_strtolower($name)) {
case 'movie':
// Sometimes they've got their own player in their ahead of the movie,
// strip it out
$url_position = strpos($value, 'http://');
if ($url_position) {
$movie = substr($value, $url_position);
// Strip parameters
$movie = substr($movie, 0, strpos($movie, '&'));
}
else {
$movie = $value;
}
break;
case 'fvars':
$flashvars = $value;
break;
default:
$attribute_string .= ' ' . $name . '="' . $value . '"';
break;
}
}
$result = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" class="flashmovie"' . $attribute_string . ">\n";
$result .= '<param name="movie" value="' . $movie . "\" />\n";
if (isset($flashvars)) {
$result .= '<param name="flashvars" value="' . $flashvars . "\" />\n";
}
$result .= "<!--[if !IE]>-->\n";
$result .= '<object type="application/x-shockwave-flash" data="' . $movie . '"' . $attribute_string . ">\n";
if (isset($flashvars)) {
$result .= '<param name="flashvars" value="' . $flashvars . "\" />\n";
}
$result .= "<!--<![endif]-->\n";
$result .= "<!--[if !IE]>--></object><!--<![endif]-->\n";
$result .= "</object>\n";
return $result;
}