function resolveResourceNode(&$node)
 {
     global $wgUser, $wgParser;
     //print 'resolveResourceNode:' . $node->nodeName . " : " . $node->nodeValue . "\n";
     //don't process free flowing text
     //@@todo (we should probably throw it out)
     if ($node instanceof DOMText) {
         return $node;
     }
     $nodeAttr = $node->attributes;
     $node_uri = false;
     if (!is_null($nodeAttr)) {
         foreach ($nodeAttr as $atrr) {
             if ($atrr->nodeName == 'uri') {
                 $node_uri = $atrr->nodeValue;
             }
         }
     }
     //if no resource uri is provided just parse inner html and return
     if (!$node_uri) {
         $node->setAttribute('type', 'text/html');
         return $this->parseInnerWikiText($node);
     }
     $uriTitle = Title::newFromDBkey($node_uri);
     //figure out if how we should parse innerHTML:
     switch ($uriTitle->getNamespace()) {
         case NS_MAIN:
             //top level ref includes of pages in the main namespace not supported
             break;
         case MV_NS_SEQUENCE:
             //type sequence ..@@todo transclude the sequence into present sequence
             //@@todo we should
             //change the node type to "par" to group the sequence under a single element (helpfull for editor representation)
             /*$parElm = $node->ownerDocument->createElement('par');
             
             				$seqArticle = new MV_SequencePage( $uriTitle );
              				$seqArticle->getSequenceSMIL();*/
             break;
         case MV_NS_STREAM:
             global $mvDefaultVideoQualityKey, $mvDefaultFlashQualityKey;
             //we could include relevant timed text and relevant different source types.
             //make sure the stream exists:
             $mvTitle = new MV_Title($uriTitle);
             if (!$mvTitle->doesStreamExist()) {
                 $node->setAttribute('type', 'text/html');
                 $this->parseInnerWikiText($node, wfMsg('mv_resource_not_found', $uriTitle->getText()));
                 return $node;
             }
             //get urls for flash and ogg
             $stream_web_url = $mvTitle->getWebStreamURL($mvDefaultVideoQualityKey);
             $flash_stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey);
             if (!$stream_web_url && !$flash_stream_url) {
                 $node->setAttribute('type', 'text/html');
                 $this->parseInnerWikiText($node, wfMsg('mv_resource_not_found', $uriTitle->getText()));
                 return $node;
             }
             //by default set the ogg source
             //@@todo parse child nodes for stream request params?
             if ($stream_web_url) {
                 $node->setAttribute('type', htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey)));
                 $node->setAttribute('src', $stream_web_url);
                 $node->setAttribute('poster', $mvTitle->getStreamImageURL());
             }
             //add in flash as a fallback method:
             if ($flash_stream_url) {
                 $f = $node->ownerDocument->createDocumentFragment();
                 $f->appendXML('<source type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey)) . '" src="' . $flash_stream_url . '"></source>');
                 $node->appendChild($f);
             }
             break;
         case NS_TEMPLATE:
             //templates are of type text/html
             $node->setAttribute('type', 'text/html');
             //print "none type: ". $node->getAttribute('type');
             //if template look for template parameters:
             $templateText = '{{' . $uriTitle->getText();
             $addedParamFlag = false;
             $paramVars = array();
             while ($node->childNodes->length) {
                 if ($node->firstChild->nodeName == 'param') {
                     $param =& $node->firstChild;
                     //make sure we have a name:
                     if ($param->hasAttribute('name')) {
                         //we have parameters:
                         $templateText .= "|\n";
                         $templateText .= $param->getAttribute('name') . '=';
                         //try and get the value from the value attribute or innerHTML
                         if ($param->hasAttribute('value')) {
                             $templateText .= $param->getAttribute('value');
                             $paramVars[$param->getAttribute('name')] = $param->getAttribute('value');
                         } else {
                             //grab from inner html:
                             $inerHTML = '';
                             while ($param->childNodes->length) {
                                 $inerHTML .= $param->ownerDocument->saveXML($param->firstChild);
                                 $param->removeChild($param->firstChild);
                             }
                             $templateText .= $inerHTML;
                             $paramVars[$param->getAttribute('name')] = $inerHTML;
                         }
                     }
                     $addedParamFlag = true;
                 }
                 $node->removeChild($node->firstChild);
             }
             //close up the template wikiText call:
             $templateText .= $addedParamFlag ? "\n}}" : '}}';
             //$parserOutput = $wgParser->parse($templateText  ,$this->mTitle, ParserOptions::newFromUser( $wgUser ));
             //print "should parse: \n $templateText";
             $this->parseInnerWikiText($node, $templateText);
             //re-add the param nodes
             $phtml = '';
             foreach ($paramVars as $name => $val) {
                 $phtml .= '<param name="' . htmlentities($name) . '">' . htmlentities($val) . '</param>';
             }
             if ($phtml != '') {
                 $f = $node->ownerDocument->createDocumentFragment();
                 $f->appendXML($phtml);
                 $node->appendChild($f);
             }
             break;
         case NS_IMAGE:
         case NS_FILE:
             //lookup the file/stream
             global $mvDefaultVideoPlaybackRes;
             list($width, $height) = explode('x', $mvDefaultVideoPlaybackRes);
             //@@todo more flexibility with image grabbing
             // (probably should be handled via "figure" namespace which could allow arbitrary crop, resize, overlay)
             $img = wfFindFile($uriTitle);
             if (!$img) {
                 $node->setAttribute('type', 'text/html');
                 $this->parseInnerWikiText($node, wfMsg('mv_resource_not_found', $uriTitle->getText()));
                 return $node;
             }
             //print "resource found set: " . $img->getMimeType();
             //set type attribute:
             //get a default wide media;
             $thumbnail = $img->transform(array('width' => $width));
             if ($thumbnail->isError()) {
                 $this->parseInnerWikiText($node, $thumbnail->toHtml());
             } else {
                 $node->setAttribute('type', $img->getMimeType());
                 $node->setAttribute('src', $img->getURL());
                 //if type is ogg: (set dur and poster)
                 if ($img->getMimeType() == 'application/ogg') {
                     //set the durationHint to the real media duration:
                     $node->setAttribute('durationHint', $thumbnail->file->getLength());
                     //set up default dur to media length if not already set:
                     if (!$node->hasAttribute('dur')) {
                         $node->setAttribute('dur', $thumbnail->file->getLength());
                     }
                     //set the poster attribute:
                     if (!$node->hasAttribute('poster')) {
                         $node->setAttribute('poster', $thumbnail->getURL());
                     }
                 }
             }
             break;
         default:
             $node->setAttribute('type', 'text/html');
             $this->parseInnerWikiText($node, wfMsg('mv_resource_not_supported', $uriTitle->getNsText() . $uriTitle->getText()));
             break;
     }
     return $node;
 }
 function getEmbedVideoHtml($options = array())
 {
     global $mvDefaultFlashQualityKey, $mvDefaultVideoQualityKey, $mvDefaultMP4QualityKey;
     //init options if unset:
     $vid_id = isset($options['id']) ? $options['id'] : '';
     $size = isset($options['size']) ? $options['size'] : '';
     $force_server = isset($options['force_server']) ? $options['force_server'] : '';
     $autoplay = isset($options['autoplay']) ? $options['autoplay'] : false;
     $showmeta = isset($options['showmeta']) ? $options['showmeta'] : false;
     $tag = 'video';
     if ($size == '') {
         global $mvDefaultVideoPlaybackRes;
         $size = $mvDefaultVideoPlaybackRes;
         list($vWidth, $vHeight) = explode('x', $size);
     } else {
         list($vWidth, $vHeight, $na) = MV_StreamImage::getSizeType($size);
     }
     $stream_web_url = $this->getWebStreamURL($mvDefaultVideoQualityKey);
     $flash_stream_url = $this->getWebStreamURL($mvDefaultFlashQualityKey);
     $mp4_stream_url = $this->getWebStreamURL($mvDefaultMP4QualityKey);
     // print "looking for q: $mvDefaultFlashQualityKey ";
     // print "FOUND: $flash_stream_url";
     $roe_url = $this->getROEURL();
     //if no urls available return missing:
     if (!$stream_web_url && !$flash_stream_url && !$mp4_stream_url) {
         return wfMsgWikiHtml('mv_error_stream_missing');
     }
     if ($stream_web_url || $flash_stream_url || $mp4_stream_url) {
         $o = '';
         /*if($this->dispVideoPlayerTime){
         			$o.='<span id="mv_videoPlayerTime">'.$this->getStartTime().' to '.
         					htmlspecialchars( $this->getEndTime() ) .
         				'</span>';
         		}*/
         $o .= '<' . htmlspecialchars($tag) . ' ';
         $o .= $vid_id == '' ? '' : ' id="' . htmlspecialchars($vid_id) . '" ';
         $o .= 'poster="' . $this->getStreamImageURL($size, null, $force_server) . '" ' . 'roe="' . $roe_url . '" ';
         $o .= $showmeta ? 'show_meta_link="true" ' : 'show_meta_link="false" ';
         $o .= $autoplay ? ' autoplay="true" ' : '';
         $o .= 'style="width:' . htmlspecialchars($vWidth) . 'px;height:' . htmlspecialchars($vHeight) . 'px" ' . 'controls="true" embed_link="true" >';
         if ($stream_web_url) {
             $o .= '<source timeFormat="anx" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultVideoQualityKey)) . '" src="' . $stream_web_url . '"></source>';
         }
         if ($flash_stream_url) {
             $o .= '<source timeFormat="anx" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultFlashQualityKey)) . '" src="' . $flash_stream_url . '"></source>';
         }
         if ($mp4_stream_url) {
             $o .= '<source timeFormat="mp4" type="' . htmlspecialchars(MV_StreamFile::getTypeForQK($mvDefaultMP4QualityKey)) . '" src="' . $mp4_stream_url . '"></source>';
         }
         $o .= '</' . htmlspecialchars($tag) . '>';
         return $o;
     }
 }