コード例 #1
0
 function getLocalStreamPath($stream_id, $quality = '')
 {
     global $mvStreamTable, $mvLocalVideoLoc;
     //grab streamFile
     $stream =& mvGetMVStream(array('id' => $stream_id));
     $stream->db_load_stream();
     $streamFile = new MV_StreamFile($stream);
     return $streamFile->getLocalPath();
 }
コード例 #2
0
 function proccessReq(&$streamFiles)
 {
     global $wgRequest, $wgUser;
     //make sure the user can edit streams:
     //if(!$wgUser->isAllowed('mv_edit_stream'))return ;
     $this->mv_action = $wgRequest->getVal('mv_action');
     if ($this->mv_action == 'new_stream_file') {
         //@@todo a bit more input scrubbing:
         $newSf = new MV_StreamFile($this->mArticle->mvTitle->mvStream, $_POST['sf_new']);
         //check against existing stream files:
         $doAdd = true;
         foreach ($streamFiles as $sf) {
             if ($sf->file_desc_msg == $newSf->file_desc_msg) {
                 $this->status_error = wfMsg('mv_file_with_same_desc', $newSf->file_desc_msg);
                 $doAdd = false;
             }
         }
         if ($doAdd) {
             $newSf->writeStreamFileDB();
             $streamFiles[] = $newSf;
         }
     } else {
         if ($this->mv_action == 'edit_stream_files') {
             foreach ($streamFiles as $sf) {
                 if ($_POST['sf_' . $sf->id]) {
                     $sf->updateValues($_POST['sf_' . $sf->id]);
                     $sf->writeStreamFileDB();
                 }
             }
             $this->status_ok = wfMsg('mv_updated_stream_files');
         } else {
             if ($this->mv_action == 'rm_stream_file') {
                 $rmID = $wgRequest->getVal('rid');
                 foreach ($streamFiles as $inx => $sf) {
                     if ($sf->id == $rmID) {
                         $sf->deleteStreamFileDB();
                         $this->status_ok = wfMsg('mv_removed_file_stream', $sf->file_desc_msg);
                         unset($streamFiles[$inx]);
                     }
                 }
             } else {
                 if ($this->mv_action == 'add_existing_stream_file') {
                     //todo VALIDATE
                     global $mvStreamFilesTable;
                     $dbw =& wfGetDB(DB_WRITE);
                     $dbw->insert($mvStreamFilesTable, array('file_id' => $_POST['sf_new']['id'], 'stream_id' => $_POST['sf_new']['stream_id']), __METHOD__);
                     //$newSf = new MV_StreamFile($this->mArticle->mvTitle->mvStream);
                     //	$newSf->getStreamFileDB();
                     //$streamFiles[]=$newSf;
                 }
             }
         }
     }
 }
コード例 #3
0
 function proccessReq(&$streamFiles)
 {
     global $wgRequest, $wgUser;
     // make sure the user can edit streams:
     if (!$wgUser->isAllowed('mv_edit_stream')) {
         $this->status_error = wfMsg('add_stream_permission');
         return;
     }
     // confirm the edit token:
     if ($wgRequest->getVal('wpEditToken')) {
         if (!$wgUser->matchEditToken($wgRequest->getVal('wpEditToken'))) {
             $this->status_error = wfMsg('token_suffix_mismatch');
             return;
         }
     }
     $stream = $this->mArticle->mvTitle->mvStream;
     $this->mv_action = $wgRequest->getVal('mv_action');
     if ($this->mv_action == 'new_stream_file') {
         // @@todo a bit more input scrubbing:
         $newSf = new MV_StreamFile($stream, $_POST['sf_new']);
         // check against existing stream files:
         $doAdd = true;
         foreach ($streamFiles as $sf) {
             if ($sf->file_desc_msg == $newSf->file_desc_msg) {
                 $this->status_error = wfMsg('mv_file_with_same_desc', $newSf->file_desc_msg);
                 $doAdd = false;
             }
         }
         if ($doAdd) {
             $newSf->writeStreamFileDB();
             $streamFiles[] = $newSf;
         }
         //check if stream length is 0 then update that to the stream-file length
         if ($stream->getDuration() == 0) {
             $stream->duration = $newSf->getDuration();
             $stream->updateStreamDB();
         }
     } elseif ($this->mv_action == 'edit_stream_files') {
         $dur = 0;
         foreach ($streamFiles as $sf) {
             if ($_POST['sf_' . $sf->id]) {
                 $sf->updateValues($_POST['sf_' . $sf->id]);
                 $sf->writeStreamFileDB();
                 if ($sf->getDuration() > $dur) {
                 }
                 $dur = $sf->getDuration();
             }
         }
         //check if stream length is 0 then update that to the stream-file length
         if ($stream->getDuration() == 0) {
             $stream->duration = $dur;
             $stream->updateStreamDB();
         }
         $this->status_ok = wfMsg('mv_updated_stream_files');
     } elseif ($this->mv_action == 'rm_stream_file') {
         $rmID = $wgRequest->getVal('rid');
         foreach ($streamFiles as $inx => $sf) {
             if ($sf->id == $rmID) {
                 $sf->deleteStreamFileDB();
                 $this->status_ok = wfMsg('mv_removed_file_stream', $sf->file_desc_msg);
                 unset($streamFiles[$inx]);
             }
         }
     }
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 function getWebStreamURL($quality = null)
 {
     global $mvStreamFilesTable, $mvVideoArchivePaths, $mvDefaultVideoQualityKey;
     //@@todo mediawiki path for media (insted of hard link to $mvVideoArchive)
     //@@todo make sure file exisits
     if (!$quality) {
         $quality = $mvDefaultVideoQualityKey;
     }
     $anx_req = '';
     if ($this->getStartTime() != '' && $this->getEndTime() != '') {
         //undesa
         //was $anx_req  ='.anx?t='. $this->getStartTime() . '/' . $this->getEndTime();
         $anx_req = '?t=' . $this->getStartTime() . '/' . $this->getEndTime();
         //undesa
     }
     if ($this->doesStreamExist()) {
         //@@todo cache this / have a more organized store for StreamFiles in streamTitle
         //$dbr = & wfGetDB(DB_READ);
         //$result = $dbr->select($dbr->tableName($mvStreamFilesTable), array('path'), array (
         //	'stream_id' => $this->mvStream->id,
         //	'file_desc_msg'=>$quality
         //));
         //$streamFile  =$dbr->fetchObject($result);
         //make sure we have streamFiles (used to generate the link)
         $mvStreamFile = new MV_StreamFile($this->mvStream);
         //if link empty return false:
         if ($mvStreamFile->getFullURL() == '') {
             return false;
         }
         return $mvStreamFile->getFullURL() . $anx_req;
     } else {
         //@@todo throw ERROR
         return false;
     }
 }
コード例 #6
0
 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;
     }
 }