/**
* Search and Replace routine. Scans the body of a node and replaces every tag and its parameters with an object.
*/
function _flashvideo_replace_tags(&$node, $tag) {
$max_num_params = 4; // The maximum number of parameters allowed. All others will be ignored.
$body = ($node->body == '') ? $node->teaser : $node->body;
for($pos =
0;
(($pos =
$startpos =
strpos($body,
$tag,
$pos)) !==
FALSE);
$pos++
) { // Search for tags
// We need to check to see if this tag has "!" in front of it, if it does, then we will ignore this tag.
if(substr($body,
$pos -
1,
1) ==
'!') {
}
else {
$pos++; // So that it will skip over the "[".
$params = _flashvideo_parse_params($body, $pos); // Parse all the parameters.
$object = ($tag == '[thumbnail') ? flashvideo_get_thumbnail($node, $params) : flashvideo_get_video($node, $params);
$body =
substr_replace($body,
$object,
$startpos,
($pos -
$startpos));
// Replace this tag.
}
}
if($node->body == '')
$node->teaser = $body;
else
$node->body = $body;
}