function outPutItem($wikiTitle, $desc_html=''){ global $wgOut; $mvTitle = new MV_Title($wikiTitle); $mStreamTitle = Title::makeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/'.$mvTitle->getTimeRequest()); //only output media RSS item if its valid media: if(!$mvTitle->doesStreamExist())return ; //@@todo this should be cached $thumb_ref = $mvTitle->getStreamImageURL('320x240'); if($desc_html==''){ $article = new Article($wikiTitle); $wgOut->clearHTML(); $wgOut->addWikiText($article->getContent() ); $desc_html = $wgOut->getHTML(); $wgOut->clearHTML(); } $desc_xml ='<![CDATA[ <center class="mv_rss_view_only"> <a href="'.$mStreamTitle->getFullUrl().'"><img src="'.$thumb_ref.'" border="0" /></a> </center> <br />'. $desc_html. ']]>'; $stream_url = $mvTitle->getWebStreamURL(); $talkpage = $wikiTitle->getTalkPage(); $type_desc = ($mvTitle->getMvdTypeKey())?wfMsg($mvTitle->getMvdTypeKey()):''; $time_desc = ($mvTitle->getTimeDesc())?$mvTitle->getTimeDesc():''; ?> <item> <link><?=mvRSSFeed::xmlEncode($mStreamTitle->getFullUrl())?></link> <title><?=mvRSSFeed::xmlEncode( $mvTitle->getStreamNameText() . ' ' . $time_desc)?></title> <description><?=$desc_xml?></description> <enclosure type="video/ogg" url="<?=mvRSSFeed::xmlEncode($stream_url)?>"/> <comments><?=mvRSSFeed::xmlEncode($talkpage->getFullUrl())?></comments> <media:thumbnail url="<?=mvRSSFeed::xmlEncode($thumb_ref)?>"/> <? /*todo add in alternate streams HQ, lowQ archive.org etc: <media:group> <media:content blip:role="Source" expression="full" fileSize="2702848" height="240" isDefault="true" type="video/msvideo" url="http://blip.tv/file/get/Conceptdude-EroticDanceOfANiceBabe266.avi" width="360"></media:content> <media:content blip:role="web" expression="full" fileSize="3080396" height="240" isDefault="false" type="video/x-flv" url="http://blip.tv/file/get/Conceptdude-EroticDanceOfANiceBabe266.flv" width="360"></media:content> </media:group> */ ?> </item> <? }
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 parsePlaylist() { global $wgParser, $wgOut; //valid playlist in-line-attributes: $mvInlineAttr = array('wClip', 'mvClip', 'title', 'linkback', 'desc', 'desc', 'image'); //build a associative array of "clips" $seq_text = $this->getSequenceText(); $seq_lines = explode("\n", $seq_text); $parseBucket = $cur_attr = ''; $clip_inx = -1; foreach ($seq_lines as $line) { //actions start with | $e = strpos($line, '='); if ($e !== false) { $cur_attr = substr($line, 1, $e - 1); } if (in_array($cur_attr, $mvInlineAttr)) { if ($cur_attr == 'mvClip') { $clip_inx++; } //close the parse bucket (found a valid inline attr) if ($parseBucket != '' && $cur_attr != 'desc') { $output = $wgParser->parse($parseBucket, $parser->mTitle, $parser->mOptions, true, false); $parseBucket = ''; } } $start_pos = $e !== false ? $e + 1 : 0; if ($clip_inx != -1) { if (!isset($this->clips[$clip_inx])) { $this->clips[$clip_inx] = array(); } if (!isset($this->clips[$clip_inx][$cur_attr])) { $this->clips[$clip_inx][$cur_attr] = ''; } $this->clips[$clip_inx][$cur_attr] .= substr($line, $start_pos); } } //poluate data (this could go here or somewhere else) foreach ($this->clips as $inx => &$clip) { if (trim($clip['mvClip']) == '') { unset($this->clips[$inx]); continue; } if ($clip['mvClip']) { $sn = str_replace('?t=', '/', $clip['mvClip']); $streamTitle = new MV_Title($sn); $wgStreamTitle = Title::newFromText($sn, MV_NS_STREAM); if ($streamTitle->doesStreamExist()) { //mvClip is a substitue for src so assume its there: $clip['src'] = $streamTitle->getWebStreamURL(); //title if (!isset($clip['title'])) { $clip['title'] = ''; } if ($clip['title'] == '') { $clip['title'] = $streamTitle->getTitleDesc(); } if (!isset($clip['info'])) { $clip['info'] = ''; } if ($clip['info'] == '') { $clip['info'] = $wgStreamTitle->getFullURL(); } } //check if we should look up the image: if (!isset($clip['image'])) { $clip['image'] == ''; } if ($clip['image'] == '') { $clip['image'] = $streamTitle->getFullStreamImageURL(); } //check if desc was present: if (!isset($clip['desc'])) { $clip['desc'] = ''; } //for now just lookup all ... @@todo future expose diffrent language tracks if ($clip['desc'] == '') { $dbr =& wfGetDB(DB_SLAVE); $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds()); if (count($dbr->numRows($mvd_res)) != 0) { $MV_Overlay = new MV_Overlay(); $wgOut->clearHTML(); while ($mvd = $dbr->fetchObject($mvd_res)) { //output a link /line break $MV_Overlay->outputMVD($mvd); $wgOut->addHTML('<br>'); } $clip['desc'] = $wgOut->getHTML(); $wgOut->clearHTML(); } } } } //print_r($this->clips); }
function getResultsHTML() { global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser; $sk =& $wgUser->getSkin(); $o = ''; if ($this->outputContainer) { $o .= '<div id="mv_search_results_container">'; } //for each stream range: if (count($this->results) == 0) { $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; if ($this->outputContainer) { $o .= '</div>'; } return $o; } else { if ($this->outputInlineHeader) { $o .= '<h2> <span class="mw-headline">' . wfMsg('mv_media_matches') . '</span> </h2>'; $title = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); $o .= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), $this->get_httpd_filters_query()); } } //media pagging: $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), $this->num < $this->limit); $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n"; //add the rss link: $sTitle = Title::MakeTitle(NS_SPECIAL, 'MvExportSearch'); $o .= '<span style="float:right;">'; $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query()); $o .= '</span>'; //add the results bar: $o .= $this->getResultsBar(); //print_r($this->results); foreach ($this->results as $stream_id => &$stream_set) { $matches = 0; $stream_out = $mvTitle = ''; foreach ($stream_set as &$srange) { $cat_html = $mvd_out = ''; $range_match = 0; foreach ($srange['rows'] as $inx => &$mvd) { $matches++; $mvTitle = new MV_Title($mvd->wiki_title); //retrieve only the first article: //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); //$article = new Article($title); $bgcolor = MV_Overlay::getMvdBgColor($mvd); //output indent if not the first and count more than one if (count($srange['rows']) != 1 && $inx != 0) { $mvd_out .= ' '; } //'<img src="'. $mvgScriptPath . '/skins/images/film.png">' //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '. // '> '; $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' . $bgcolor . '" ' . ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="' . $mvTitle->getStreamImageURL('icon') . '">'; $mvd_out .= '</div>'; $mvd_out .= '<b>' . $mvTitle->getTimeDesc() . '</b> '; $mvd_cnt_links = ''; if (isset($mvd->spoken_by)) { $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by); $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle); $mvd_cnt_links .= '<br>'; } if ($this->outputSeqLinks == true) { $mvd_cnt_links .= ' <a href="javascript:mv_add_to_seq({mvclip:\'' . $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() . '\',' . 'src:\'' . $mvTitle->getWebStreamURL() . '\',' . 'img_url:\'' . $mvTitle->getStreamImageURL() . '\'})">' . '<img style="cursor:pointer;" ' . 'title="' . wfMsg('mv_seq_add_end') . '" ' . 'src="' . $mvgScriptPath . '/skins/mv_embed/images/application_side_expand.png">' . wfMsg('mv_seq_add_end') . '</a>'; } $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">' . '<img id="mv_img_ex_' . $mvd->id . '" src="' . $mvgScriptPath . '/skins/images/closed.png">' . '<span id="mv_watch_clip_' . $mvd->id . '">' . wfMsg('mv_watch_clip') . '</span>' . '<span style="display:none;" id="mv_close_clip_' . $mvd->id . '">' . wfMsg('mv_close_clip') . '</span>' . '</a>' . ' '; //output control links: //make stream title link: $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName()); //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" '); $mvd_cnt_links .= '<br>'; //$title = MakeTitle::() //don't inclue link to wiki page (too confusing) //$mvd_out .=' '; $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); $mvd_out .= '<span id="mvr_desc_' . $mvd->id . '">'; if (!isset($mvd->toplq)) { $mvd->toplq = false; } //output short desc send partial regEx: if (!$mvd->toplq) { $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms())); } else { if ($mvdTitle->exists() && !isset($mvd->text)) { //grab the article text: $curRevision = Revision::newFromTitle($mvdTitle); $wikiText = $curRevision->getText(); } else { $wikiText =& $mvd->text; } //@@todo parse category info if present $cat_html = ''; //run via parser to add in Category info: $parserOptions = ParserOptions::newFromUser($wgUser); $parserOptions->setEditSection(false); $parserOptions->setTidy(true); $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); $parserOutput = $wgParser->parse($wikiText, $title, $parserOptions); $cats = $parserOutput->getCategories(); foreach ($cats as $catkey => $title_str) { $catTitle = Title::MakeTitle(NS_CATEGORY, $catkey); $cat_html .= ' ' . $sk->makeKnownLinkObj($catTitle); } //add category pre-text: //if ($cat_html != '') //$mvd_out.= wfMsg('Categories') . ':' . $cat_html; $mvd_out .= $cat_html; $mvd_out .= count($srange['rows']) - 1 == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1); //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); //$cat_html = $sk->getCategories(); //empty out the categories //$wgOut->mCategoryLinks = array(); } $mvd_out .= '</span>'; $mvd_out .= '<br>' . $mvd_cnt_links; $mvd_out .= '<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>'; $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>'; } $stream_out .= $mvd_out; /*if(count($srange['rows'])!=1){ $stream_out .= ' ' . $cat_html . ' In range:' . seconds2ntp($srange['s']) . ' to ' . seconds2ntp($srange['e']) . wfMsg('mv_match_text', count($srange['rows'])).'<br />' . "\n"; $stream_out .= $mvd_out; }else{ $stream_out .= $mvd_out; }*/ } $nsary = $mvgContLang->getNamespaces(); //output stream name and mach count /*$o.='<br /><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' . $mvTitle->getStreamName() . '" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">'; */ $o .= '<h3>' . $mvTitle->getStreamNameText(); $o .= $matches == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', $matches); $o .= '</h3>'; $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>'; } if ($this->outputContainer) { $o .= '</div>'; } return $o; }