function get_stream_cmml( $inline = false, $force_track = null ) { $dbr = wfGetDB( DB_SLAVE ); // set cmml name space if inline: $ns = ( $inline ) ? 'cmml:':''; $ns = ''; $encap = false;// if we should have a parent cmml tag if ( !$force_track ) { // check the request to get trac set: $mvcp = new MV_Component(); $mvcp->procMVDReqSet(); $tracks = $mvcp->mvd_tracks; if ( count( $mvcp->mvd_tracks ) > 1 )$encap = true; } else { $tracks = $force_track; $encap = false; } // get the stream title $streamTitle = new MV_Title( $this->stream_name . '/' . $this->req_time ); $wgTitle = Title::newFromText( $this->stream_name . '/' . $this->req_time, MV_NS_STREAM ); // do mvd_index query: $mvd_rows = MV_Index::getMVDInRange( $streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), $tracks, $getText = false, 'Speech_by,Bill,category' ); // get the stream stream req if ( $this->output_xml_header ) header( 'Content-Type: text/xml' ); // print the header: if ( !$inline )print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n"; // if(!$inline)print '<!DOCTYPE cmml SYSTEM "http://svn.annodex.net/standards/cmml_2_0.dtd">'."\n"; $tracks = array(); if ( count( $mvd_rows ) != 0 ) { global $wgOut; $MV_Overlay = new MV_Overlay(); foreach ( $mvd_rows as $mvd ) { if ( !isset( $tracks[$mvd->mvd_type] ) )$tracks[$mvd->mvd_type] = ''; $tracks[$mvd->mvd_type] .= ' <' . $ns . 'clip id="mvd_' . htmlentities( $mvd->id ) . '" start="npt:' . htmlentities( seconds2npt( $mvd->start_time ) ) . '" end="npt:' . htmlentities( seconds2npt( $mvd->end_time ) ) . '"> <' . $ns . 'img src="' . htmlentities( $streamTitle->getFullStreamImageURL( null, seconds2npt( $mvd->start_time ) ) ) . '"/>'; // output all metadata @@todo we should generalize the semantic properties. $tracks[$mvd->mvd_type] .= ( isset( $mvd->Speech_by ) && trim( $mvd->Speech_by ) != '' ) ? '<meta name="Speech_by" content="' . htmlentities ( $mvd->Speech_by ) . '"/>':''; $tracks[$mvd->mvd_type] .= ( isset( $mvd->Bill ) && trim( $mvd->Bill ) != '' ) ? '<meta name="Bill" content="' . htmlentities( $mvd->Bill ) . '"/>':''; // add in categories as "keywords" if ( count( $mvd->category ) != 0 ) { $tracks[$mvd->mvd_type] .= '<meta name="keywords" content="'; $coma = ''; foreach ( $mvd->category as $cat ) { $tracks[$mvd->mvd_type] .= $coma . htmlentities( $cat ); $coma = ','; } $tracks[$mvd->mvd_type] .= '"/>'; } $tracks[$mvd->mvd_type] .= '<' . $ns . 'body><![CDATA[ ' . $MV_Overlay->getMVDhtml( $mvd, $absolute_links = true ). ' ]]></' . $ns . 'body> </' . $ns . 'clip>'; // clear wgOutput } } if ( $encap )print '<cmml_set>'; // based on: http://trac.annodex.net/wiki/CmmlChanges foreach ( $tracks as $role => $body_string ) { $ns = htmlentities( $ns ); ?> <cmml lang="en" id="<?php echo htmlentities($role); ?> " role="<?php echo wfMsg($role); ?> " xmlns="http://svn.annodex.net/standards/cmml_2_0.dtd"> <<?php echo $ns; ?> head> <<?php echo $ns; ?> title> <?php echo wfMsg($role); ?> </<?php echo $ns; ?> title> <<?php echo $ns; ?> meta name="description" content="<?php echo htmlentities(wfMsg($role . '_desc')); ?> "></<?php echo $ns; ?> meta> </<?php echo $ns; ?> head> <?php echo $body_string; ?> </cmml> <? } if ( $encap )print '</cmml_set>'; }
function get_stream_cmml($inline=false, $force_track=null){ $dbr =& wfGetDB(DB_SLAVE); //set cmml name space if inline: $ns = ($inline)?'cmml:':''; $ns=''; $encap=false;//if we should have a parent cmml tag if(!$force_track){ //check the request to get trac set: $mvcp = new MV_Component(); $mvcp->procMVDReqSet(); $tracks = $mvcp->mvd_tracks; if(count($mvcp->mvd_tracks)>1)$encap=true; }else{ $tracks = $force_track; $encap=false; } //get the stream title $streamTitle = new MV_Title($this->stream_name.'/'.$this->req_time); $wgTitle = Title::newFromText($this->stream_name.'/'.$this->req_time, MV_NS_STREAM); //do mvd_index query: $mvd_res = MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), $tracks); //get the stream stream req if(!$inline)header('Content-Type: text/xml'); //print the header: if(!$inline)print '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n"; //if(!$inline)print '<!DOCTYPE cmml SYSTEM "http://svn.annodex.net/standards/cmml_2_0.dtd">'."\n"; $tracks=array(); if(count($dbr->numRows($mvd_res))!=0){ global $wgOut; $MV_Overlay = new MV_Overlay(); while($mvd = $dbr->fetchObject($mvd_res)){ if(!isset($tracks[$mvd->mvd_type]))$tracks[$mvd->mvd_type]=''; $tracks[$mvd->mvd_type].=' <'.$ns.'clip id="mvd_'.$mvd->id.'" start="ntp:'.seconds2ntp($mvd->start_time).'" end="ntp:'.seconds2ntp($mvd->end_time).'"> <'.$ns.'img src="'.htmlentities($streamTitle->getFullStreamImageURL(null, seconds2ntp($mvd->start_time))).'"/> <'.$ns.'body><![CDATA[ '. $MV_Overlay->getMVDhtml($mvd, $absolute_links=true).' ]]></'.$ns.'body> </'.$ns.'clip>'; //clear wgOutput } } if($encap)print '<cmml_set>'; //based on: http://trac.annodex.net/wiki/CmmlChanges foreach($tracks as $role=>$body_string){ ?> <cmml lang="en" id="<?=$role?>" role="<?=wfMsg($role)?>" xmlns="http://svn.annodex.net/standards/cmml_2_0.dtd"> <<?=$ns?>head> <<?=$ns?>title><?=wfMsg($role)?></<?=$ns?>title> <<?=$ns?>description><?=htmlentities(wfMsg($role.'_desc'))?></<?=$ns?>description> </<?=$ns?>head> <?=$body_string?> </cmml> <? } if($encap)print '</cmml_set>'; }
function update_index_page(&$article, &$text) { global $mvgIP, $mvIndexTableName; //check static or $this usage context //use mv title to split up the values: $mvTitle = new MV_Title($article->mTitle->getDBkey()); //print "Wiki title: " . $mvTitle->getWikiTitle(); //fist check if an mvd entry for this stream already exists: $mvd_row = MV_Index::getMVDbyTitle($mvTitle->getWikiTitle()); //set up the insert values: $insAry = array('mv_page_id' => $article->mTitle->getArticleID(), 'wiki_title' => $mvTitle->getWikiTitle(), 'mvd_type' => $mvTitle->getTypeMarker(), 'stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds()); $dbw =& wfGetDB(DB_WRITE); if (count($mvd_row) == 0) { return $dbw->insert($mvIndexTableName, $insAry); } else { $dbw->update($mvIndexTableName, $insAry, array('mv_page_id' => $mvd_row->mv_page_id)); } }
function get_overlay_context_from_title($contextTitle = null) { global $mvDefaultStreamViewLength, $wgTitle; if (!$contextTitle) { $contextTitle = $wgTitle; } $mvContextTitle = new MV_Title($contextTitle); $mvContextTitle->setStartEndIfEmpty(); $this->start_time = $mvContextTitle->getStartTimeSeconds(); $this->end_time = $mvContextTitle->getEndTimeSeconds(); $this->duration = $mvContextTitle->getDuration(); }
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 mvDoMetavidStreamPage(&$title, &$article) { $mvTitle = new MV_Title($title->mDbkeyform); if ($mvTitle->doesStreamExist()) { // @@TODO check if we have /name corresponding to a view or // /ss:ss:ss or /ss:ss:ss/ee:ee:ee corresponding to a time request // force metavid to be special // (@@todo clean up skin.php to enable better tab controls) // $title->mNamespace= NS_SPECIAL; // add a hit to the digest if enabled: // @@todo (maybe in the future use javascript to confirm they acutally "watched" the clip) global $mvEnableClipViewDigest, $wgRequest; // don't log views without end times (default stream view) if ($mvEnableClipViewDigest && $mvTitle->end_time != null && $wgRequest->getVal('tl') != '1') { $dbw = wfGetDB(DB_WRITE); $dbw->insert('mv_clipview_digest', array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds(), 'query_key' => $mvTitle->getStreamId() . $mvTitle->getStartTimeSeconds() . $mvTitle->getEndTimeSeconds(), 'view_date' => time())); // compensate for $mvDefaultClipRange around clips global $mvDefaultClipRange; $start_time = $mvTitle->getStartTimeSeconds() + $mvDefaultClipRange < 0 ? 0 : $mvTitle->getStartTimeSeconds() + $mvDefaultClipRange; $end_time = $mvTitle->getEndTimeSeconds() - $mvDefaultClipRange > $mvTitle->getDuration() ? 0 : $mvTitle->getEndTimeSeconds() - $mvDefaultClipRange; // also increment the mvd_page if we find a match: $dbw->update('mv_mvd_index', array('`view_count`=`view_count`+1'), array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $start_time, 'end_time' => $end_time)); // print $dbw->lastQuery(); // also update the mvd_page if directly requested: $dbw->update('mv_mvd_index', array('`view_count`=`view_count`+1'), array('stream_id' => $mvTitle->getStreamId(), 'start_time' => $mvTitle->getStartTimeSeconds(), 'end_time' => $mvTitle->getEndTimeSeconds())); // print $dbw->lastQuery(); } // @@todo check if the requested title is already just the stream name: $streamTitle = Title::newFromText($mvTitle->getStreamName(), MV_NS_STREAM); // print " new title: " . $streamTitle . "\n"; $article = new MV_StreamPage($streamTitle, $mvTitle); } else { mvMissingStreamPage($mvTitle->stream_name); } }