function delete()
 {
     global $wgOut, $wgRequest, $wgUser;
     if (!$wgRequest->wasPosted()) {
         $wgOut->addHTML(wfMsg('mv_stream_delete_warrning', MV_Index::countMVDInRange($this->mvTitle->getStreamId())));
     }
     //update text button to delete stream rather than delete stream
     parent::delete();
 }
 function deleteDB()
 {
     $dbw =& wfGetDB(DB_WRITE);
     //remove any MVD index items:
     MV_Index::remove_by_stream_id($this->id);
     //remove any digest
     $dbw->delete('mv_clipview_digest', array('stream_id' => $this->id));
     //remove any images
     $dbw->delete('mv_stream_images', array('stream_id' => $this->id));
     //remove pointers to any files:
     $dbw->delete('mv_stream_files', array('stream_id' => $this->id));
 }
示例#3
0
 function generate($take_duration)
 {
     global $mvgIP;
     require_once $mvgIP . '/includes/MV_Index.php';
     $s = MV_Stream::newStreamByName($this->name);
     if (!$s->db_load_stream()) {
         return "An error occured while loading stream info please notify Administrator";
     }
     $stream_duration = $s->getDuration();
     if ($stream_duration === NULL) {
         return "Error: Stream Duration not set";
     }
     $sitting_id = $s->getSittingId();
     $editors = $this->getAssignedEditors($sitting_id);
     $readers = $this->getAssignedReaders($sitting_id);
     $reporters = $this->getAssignedReporters($sitting_id);
     $editors_count = count($editors);
     $readers_count = count($readers);
     $reporters_count = count($reporters);
     $html = '';
     if ($editors_count == 0) {
         $html .= "No Editors Assigned";
         return $html;
     }
     if ($readers_count == 0) {
         $html .= "No Readers Assigned";
         return $html;
     }
     if ($reporters_count == 0) {
         $html .= "No Reporters Assigned";
         return $html;
     }
     //delete all existing take transcripts
     $dbr =& wfGetDB(DB_SLAVE);
     $result =& MV_Index::getMVDInRange($s->getStreamId(), 0, $s->getDuration(), $this->mvd_tracks);
     while ($row = $dbr->fetchObject($result)) {
         $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
         $art = new Article($title);
         if ($art->exists()) {
             $art->doDelete("new takes generated", true);
         }
     }
     $num_editor = 0;
     $num_reader = 0;
     $num_reporter = 0;
     for ($i = 0; $i < $stream_duration; $i = $i + $take_duration) {
         $start_time = $i;
         $end_time = $i + $take_duration;
         $title_text = 'Take_en:' . $this->name . '/' . seconds2ntp($start_time) . '/' . seconds2ntp($end_time);
         $title = Title::newFromText($title_text, MV_NS_MVD);
         $editor = User::newFromId($editors[$num_editor]);
         $editor_name = $editor->getRealName();
         $reader = User::newFromId($readers[$num_editor]);
         $reader_name = $reader->getRealName();
         $reporter = User::newFromId($reporters[$num_editor]);
         $reporter_name = $reporter->getRealName();
         $article = new Article($title);
         $text = '[[Edited By::' . $editor_name . ']], ' . '[[Read By::' . $reader_name . ']], ' . '[[Reported By::' . $reporter_name . ']], ' . '[[Status::Incomplete]]';
         $article->doEdit($text, 'Automatically Generated', EDIT_NEW);
         if ($num_editor < $editors_count - 1) {
             $num_editor++;
         } else {
             $num_editor = 0;
         }
         if ($num_reader < $readers_count - 1) {
             $num_reader++;
         } else {
             $num_reader = 0;
         }
         if ($num_reporter < $reporters_count - 1) {
             $num_reporter++;
         } else {
             $num_reporter = 0;
         }
     }
     $html .= 'Takes Successfully Generated';
     return $html;
 }
示例#4
0
 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_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 getHTML()
 {
     global $wgUser;
     $o = '';
     $sk = $wgUser->getSkin();
     $dbr = wfGetDB(DB_SLAVE);
     //if in overview mode don't print out the navigator:
     global $wgRequest;
     if ($wgRequest->getVal('view') == 'overview') {
         return '';
     }
     // get all annotative layers
     $stream_id = $this->mv_interface->article->mvTitle->getStreamId();
     $stream_name = $this->mv_interface->article->mvTitle->getStreamName();
     $stream_time_req = $this->mv_interface->article->mvTitle->getTimeRequest();
     $start_sec = $this->mv_interface->article->mvTitle->getStartTimeSeconds();
     $duration_sec = $this->mv_interface->article->mvTitle->getDuration();
     $end_sec = $this->mv_interface->article->mvTitle->getEndTimeSeconds();
     // print "start $start_sec end:$end_sec \n ";
     foreach (array('prev', 'next') as $pntype) {
         if ($o != '') {
             $o .= ' ';
         }
         if ($pntype == 'prev') {
             if ($start_sec == 0) {
                 continue;
             }
             $qstart = 0;
             $qend = $start_sec - 1;
             $orderby = 'end_time DESC';
         } elseif ($pntype == 'next') {
             $qstart = $end_sec + 1;
             $qend = $duration_sec;
             $orderby = 'start_time ASC';
         }
         // print "Qstart looking for $pntype:$qstart:  ".seconds2npt($qstart) ." Qend:$qend : " . seconds2npt($qend) . " \n";
         $mvd_rows = MV_Index::getMVDInRange($stream_id, $qstart, $qend, $mvd_type = 'anno_en', $getText = false, $smw_properties = array('Speech_by', 'Bill', 'category'), $options = array('LIMIT' => 1, 'ORDER BY' => $orderby));
         //print $dbr->lastQuery();
         //print_r($mvd_rows);
         //die;
         // print "SHOULD GET $pntype for $stream_time_req";
         reset($mvd_rows);
         if (count($mvd_rows) != 0) {
             $row = current($mvd_rows);
             // $prev_end = $row->end_time;
             $stime_req = seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time);
             $streamTitle = Title::newFromText($stream_name . '/' . $stime_req, MV_NS_STREAM);
             $tool_tip = '';
             // print_r($row);
             if (isset($row->Speech_by)) {
                 if (trim($row->Speech_by) != '') {
                     //check if the person has an icon:
                     $pimg = mv_get_person_img($row->Speech_by);
                     $o .= wfMsg('mv_' . $pntype . '_speech', $sk->makeKnownLinkObj($streamTitle, '<img title="' . str_replace('_', ' ', $row->Speech_by) . '" width="40" src="' . $pimg->getURL() . '">'));
                     //$o .= wfMsg( 'mv_' . $pntype . '_speech', $sk->makeKnownLinkObj( $streamTitle, str_replace( '_', ' ', $row->Speech_by ) ) );
                     // $tool_tip.=	 'Speech By: '. $row->Speech_by;
                 } elseif (trim($row->Bill) != '') {
                     $o .= wfMsg('mv_' . $pntype . '_bill', $sk->makeKnownLinkObj($streamTitle, str_replace('_', ' ', $row->Bill)));
                 } elseif (is_array($row->category) && count($row->category) != 0) {
                     $first_cat = current($row->category);
                     $o .= wfMsg('mv_' . $pntype . '_cat', $sk->makeKnownLinkObj($streamTitle, str_replace('_', ' ', $first_cat)));
                 }
             }
         }
     }
     return $o;
 }
 function onEdit(&$mvd_pages_cache, $mvd_id)
 {
     // force update local mvd_page_cache from db:
     $mvd_pages_cache[$mvd_id] = MV_Index::getMVDbyId($mvd_id);
     $stream_name = MV_Stream::getStreamNameFromId($this->mvd_pages[$mvd_id]->stream_id);
     $streamTitle = Title::newFromText($stream_name, MV_NS_STREAM);
     // clear the cache for the parent stream page:
     // print "clear parent stream: " . $streamTitle ."\n";
     Article::onArticleEdit($streamTitle);
 }
 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 do_update_wiki_page($wgTitle, $wikiText, $ns = null, $forceUpdate = false)
{
    global $botUserName;
    if (!is_object($wgTitle)) {
        //get the title and make sure the first letter is uper case
        $wgTitle = Title::makeTitle($ns, ucfirst($wgTitle));
    }
    if (trim($wgTitle->getDBKey()) == '') {
        print "empty title (no insert /update) \n";
        return;
    }
    //print "INSERT BODY: ".$wikiText;
    //make sure the text is utf8 encoded:
    $wikiText = utf8_encode($wikiText);
    $wgArticle = new Article($wgTitle);
    if (!mvDoMvPage($wgTitle, $wgArticle, false)) {
        print "bad title: " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . " no edit";
        if ($wgTitle->exists()) {
            print "remove article";
            $wgArticle->doDeleteArticle('bad title');
        }
        //some how mvdIndex and mvd pages got out of sync do a seperate check for the mvd:
        if (MV_Index::getMVDbyTitle($wgArticle->mTitle->getDBkey()) != null) {
            print ', rm mvd';
            MV_Index::remove_by_wiki_title($wgArticle->mTitle->getDBkey());
        }
        print "\n";
        return;
    }
    if ($wgTitle->getNamespace() == MV_NS_MVD && MV_Index::getMVDbyTitle($wgTitle->getDBkey()) == null) {
        //print "missing assoc mvd ...update \n";
    } else {
        if ($wgTitle->exists()) {
            //if last edit!=mvBot skip (don't overwite peoples improvments')
            $rev =& Revision::newFromTitle($wgTitle);
            if ($botUserName != $rev->getRawUserText() && !$forceUpdate) {
                print ' skiped page ' . $wgTitle->getNsText() . ':' . $wgTitle->getText() . ' edited by user:'******'#REDIRECT')) == '#REDIRECT' && !$forceUpdate) {
                print ' skiped page moved by user:'******':' . $wgTitle->getText() . " is identical (no update)\n";
                //if force update double check the mvd for consistancy?
                return;
            }
        }
    }
    //got here do the edit:
    $sum_txt = 'metavid bot insert';
    $wgArticle->doEdit($wikiText, $sum_txt);
    print "did edit on " . $wgTitle->getNsText() . ':' . $wgTitle->getDBkey() . "\n";
    //die;
}
 function get_aligned_time_title(&$pData, $preFix = 'Anno_en', $stream)
 {
     $dbr = wfGetDB(DB_SLAVE);
     $mvd_rows = MV_Index::getMVDInRange($stream->getStreamId(), $pData['wiki_start_time'] - 120, $pData['wiki_end_time'] + 120, $mvd_type = 'Anno_en', $getText = false, $smw_properties = 'Speech_by');
     $doSpeechInsert = true;
     foreach ($mvd_rows as $row) {
         if ($row->Speech_by) {
             if ($row->Speech_by == $pData['Spoken_by']) {
                 print "match update existing: {$row->Speech_by}  == " . $pData['Spoken_by'] . "\n";
                 $anno_title_str = $preFix . ':' . $stream->name . '/' . seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time);
                 return $anno_title_str;
             } else {
                 print "\nno existing speech match:{$row->Speech_by} != " . $pData['Spoken_by'] . "\n\n";
             }
         }
     }
     return false;
 }
示例#11
0
function mv_pl_wt($mvd_id)
{
    global $wgRequest;
    $mvd = MV_Index::getMVDbyId($mvd_id);
    $mvTitle = new MV_Title($mvd->wiki_title);
    return $mvTitle->getEmbedVideoHtml(array('id' => 'vid_' . $mvd_id, 'size' => $wgRequest->getVal('size'), 'autoplay' => true));
}
 function edit($textbox1_override = null)
 {
     global $wgOut, $wgUser, $wgRequest;
     $fname = 'MV_EditPage::edit';
     wfProfileIn($fname);
     wfDebug("{$fname}: enter\n");
     // this is not an article
     $wgOut->setArticleFlag(false);
     $this->importFormData($wgRequest);
     if ($textbox1_override) {
         $this->textbox1 = $textbox1_override;
     }
     $this->firsttime = false;
     if ($this->live) {
         $this->livePreview();
         wfProfileOut($fname);
         return;
     }
     $permErrors = $this->mTitle->getUserPermissionsErrors('edit', $wgUser);
     if (!$this->mTitle->exists()) {
         $permErrors += array_diff($this->mTitle->getUserPermissionsErrors('create', $wgUser), $permErrors);
     }
     # Ignore some permissions errors.
     $remove = array();
     foreach ($permErrors as $error) {
         if ($this->preview || $this->diff && ($error[0] == 'blockedtext' || $error[0] == 'autoblockedtext')) {
             // Don't worry about blocks when previewing/diffing
             $remove[] = $error;
         }
         if ($error[0] == 'readonlytext') {
             if ($this->edit) {
                 $this->formtype = 'preview';
             } elseif ($this->save || $this->preview || $this->diff) {
                 $remove[] = $error;
             }
         }
     }
     # array_diff returns elements in $permErrors that are not in $remove.
     $permErrors = array_diff($permErrors, $remove);
     if (!empty($permErrors)) {
         wfDebug("{$fname}: User can't edit\n");
         // limt rows for ajax:
         $non_ajax_rows = $wgUser->getIntOption('rows');
         $wgUser->setOption('rows', 5);
         $sk = $wgUser->getSkin();
         $cancel = '<a href="javascript:mv_disp_mvd(\'' . $this->mTitle->getDBkey() . '\',\'' . $this->mvd_id . '\');">' . wfMsgExt('cancel', array('parseinline')) . '</a>';
         // get the stream parent:
         $mvd = MV_Index::getMVDbyId($this->mvd_id);
         $stream_name = MV_Stream::getStreamNameFromId($mvd->stream_id);
         $lTitle = SpecialPage::getTitleFor('Userlogin');
         $loginLink = $lTitle->getFullURL('returnto=' . MWNamespace::getCanonicalName(MV_NS_STREAM) . ':' . $stream_name);
         $wgOut->addHTML(wfMsg('mv_user_cant_edit', $loginLink, $cancel));
         $wgOut->readOnlyPage($this->mArticle->getContent(), true, $permErrors);
         $wgUser->setOption('rows', $non_ajax_rows);
         wfProfileOut($fname);
         return;
     } else {
         if ($this->save) {
             $this->formtype = 'save';
         } elseif ($this->preview) {
             $this->formtype = 'preview';
         } elseif ($this->diff) {
             $this->formtype = 'diff';
         } else {
             # First time through
             $this->firsttime = true;
             if ($this->previewOnOpen()) {
                 $this->formtype = 'preview';
             } else {
                 $this->extractMetaDataFromArticle();
                 $this->formtype = 'initial';
             }
         }
     }
     wfProfileIn("{$fname}-business-end");
     $this->isConflict = false;
     // css / js subpages of user pages get a special treatment
     $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
     $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
     /* Notice that we can't use isDeleted, because it returns true if article is ever deleted
      * no matter it's current state
      */
     $this->deletedSinceEdit = false;
     if ($this->edittime != '') {
         /* Note that we rely on logging table, which hasn't been always there,
          * but that doesn't matter, because this only applies to brand new
          * deletes. This is done on every preview and save request. Move it further down
          * to only perform it on saves
          */
         if ($this->mTitle->isDeleted()) {
             $this->lastDelete = $this->getLastDelete();
             if (!is_null($this->lastDelete)) {
                 $deletetime = $this->lastDelete->log_timestamp;
                 if ($deletetime - $this->starttime > 0) {
                     $this->deletedSinceEdit = true;
                 }
             }
         }
     }
     # Show applicable editing introductions
     if ($this->formtype == 'initial' || $this->firsttime) {
         $this->showIntro();
     }
     if ($this->mTitle->isTalkPage()) {
         $wgOut->addWikiMsg('talkpagetext');
     }
     # Attempt submission here.  This will check for edit conflicts,
     # and redundantly check for locked database, blocked IPs, etc.
     # that edit() already checked just in case someone tries to sneak
     # in the back door with a hand-edited submission URL.
     // set up commit transaction
     // $dbw = wfGetDB( DB_MASTER );
     // $dbw->begin();
     if ('save' == $this->formtype) {
         if (!$this->attemptSave()) {
             wfProfileOut("{$fname}-business-end");
             wfProfileOut($fname);
             return;
         }
     }
     // $dbw->commit();
     # First time through: get contents, set time for conflict
     # checking, etc.
     if ('initial' == $this->formtype || $this->firsttime) {
         if ($this->initialiseForm() === false) {
             $this->noSuchSectionPage();
             wfProfileOut("{$fname}-business-end");
             wfProfileOut($fname);
             return;
         }
         if (!$this->mTitle->getArticleId()) {
             wfRunHooks('EditFormPreloadText', array(&$this->textbox1, &$this->mTitle));
         }
     }
     $this->showEditForm();
     wfProfileOut("{$fname}-business-end");
     wfProfileOut($fname);
 }
 function expand_wt($mvd_id, $terms_ary)
 {
     global $wgOut, $mvgIP;
     global $mvDefaultSearchVideoPlaybackRes;
     $mvd = MV_Index::getMVDbyId($mvd_id);
     if (count($mvd) != 0) {
         $mvTitle = new MV_Title($mvd->wiki_title);
         // validate title and load stream ref:
         if ($mvTitle->validRequestTitle()) {
             list($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes);
             $embedHTML = '<span style="float:left;width:' . htmlspecialchars($vWidth + 20) . 'px">' . $mvTitle->getEmbedVideoHtml(array('id' => 'vid_' . $mvd_id, 'size' => $mvDefaultSearchVideoPlaybackRes, 'autoplay' => true)) . '</span>';
             $wgOut->clearHTML();
             $MvOverlay = new MV_Overlay();
             $MvOverlay->outputMVD($mvd, $mvTitle);
             $pageHTML = '<span style="padding-top:10px;float:left;width:450px">' . $wgOut->getHTML() . '</span>';
             // return page html:
             return $embedHTML . $pageHTML . '<div style="clear: both;"/>';
         } else {
             return wfMsg('mvBadMVDtitle');
         }
     } else {
         return wfMsg('mv_error_mvd_not_found');
     }
     // $title = Title::MakeTitle(MV_NS_MVD, $wiki_title);
     // $article = new Article($title);
     // output table with embed left, and content right
     // return $wgOut->parse($article->getContent());
 }
示例#14
0
 function removeStream($removeMVDs = true)
 {
     global $mvIndexTableName;
     $dbw =& wfGetDB(DB_WRITE);
     $dbr =& wfGetDB(DB_SLAVE);
     if ($removeMVDs) {
         //delete metadata pages:
         //@@todo figure out a way to do this quickly/group sql queries.
         $res = MV_Index::getMVDInRange($this->getStreamId());
         if ($dbr->numRows($res) != 0) {
             while ($row = $dbr->fetchObject($res)) {
                 $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
                 $article = new Article($title);
                 $article->doDelete('parent stream removed');
             }
         }
     }
     return true;
 }
    function getItemOutput($row, $opt = array())
    {
        global $wgUser;
        $sk = $wgUser->getSkin();
        //set defaults:
        $person_ht = $bill_ht = $category_ht = $o = '';
        if (!isset($row->start_time)) {
            $row->start_time = 0;
        }
        if (!isset($row->end_time)) {
            $row->end_time = 60 * 20;
        }
        $mvd_out_html = '';
        $mvd_rows = MV_Index::getMVDInRange($row->stream_id, $row->start_time, $row->end_time, $mvd_type = 'anno_en', $getText = true, $smw_properties = array('Speech_by', 'Bill', 'category'), $options = array('limit' => 1));
        if (count($mvd_rows) != 0) {
            reset($mvd_rows);
            $mvd_row = current($mvd_rows);
            if (isset($opt['use_mvd_time']) && $opt['use_mvd_time']) {
                $row->start_time = $mvd_row->start_time;
                $row->end_time = $mvd_row->end_time;
            }
            // print_r($mvd_rows);
            // print "type of: " . gettype($mvd_row);
            if (isset($mvd_row->Speech_by)) {
                if (trim($mvd_row->Speech_by) != '') {
                    $ptitle = Title::MakeTitle(NS_MAIN, $mvd_row->Speech_by);
                    $mvd_out_html .= '<span class="keywords">' . $sk->makeKnownLinkObj($ptitle, $ptitle->getText()) . '</span><br />';
                }
            }
            if (isset($mvd_row->Bill)) {
                if (trim($mvd_row->Bill) != '') {
                    $btitle = Title::MakeTitle(NS_MAIN, $mvd_row->Bill);
                    $mvd_out_html .= '<span class="keywords">Bill: ' . $sk->makeKnownLinkObj($btitle) . '
 						</span><br />';
                }
            }
            global $wgContLang;
            $mvdNStxt = $wgContLang->getNsText(MV_NS_MVD);
            //grab categories if no bill or speech
            if ($this->params['display_cat'] || $mvd_out_html == '') {
                $dbr = wfGetDB(DB_READ);
                $cl_res = $dbr->select('categorylinks', 'cl_to', array('cl_sortkey' => $mvdNStxt . ':' . str_replace('_', ' ', $mvd_row->wiki_title)), 'getTopClips::Categories', 'LIMIT 0, 5');
                if ($dbr->numRows($cl_res) != 0) {
                    $mvd_out_html .= '<span class="keywords">Categories: ';
                    $coma = '';
                    while ($cl_row = $dbr->fetchObject($cl_res)) {
                        $cTitle = Title::MakeTitle(NS_CATEGORY, $cl_row->cl_to);
                        $mvd_out_html .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText());
                        $coma = ', ';
                    }
                    $mvd_out_html .= '</span><br />';
                }
            }
        } else {
            //we have not meta
            //if( isset($opt['remove_no_meta']) && $opt['remove_no_meta'])
            //return false;
        }
        // first make link and stream title:
        $mvStream = MV_Stream::newStreamByID($row->stream_id);
        if (!$mvStream->doesStreamExist()) {
            return false;
        }
        //limit our output range to < 20 min
        if ($row->end_time - $row->start_time > 20 * 60) {
            $row->end_time = $row->start_time + 20 * 60;
        }
        $nt = $mvStream->getStreamName() . '/' . seconds2npt($row->start_time) . '/' . seconds2npt($row->end_time);
        $mvTitle = new MV_Title($nt, MV_NS_STREAM);
        $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range = '0'));
        // output the image:
        $o .= $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small') . '"/>', 'tl=1');
        $title_span = '';
        if (isset($mvStream->date_start_time)) {
            $parts = split('_', $mvStream->getStreamName());
            if (count($parts) >= 3) {
                $title_span = ucfirst($parts[0] . ' ');
            } else {
                $title_span = $mvStream->getStreamName();
            }
            $title_span .= date('F jS, Y', $mvStream->date_start_time);
        } else {
            $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc();
        }
        $o .= '<span class="title">' . $sk->makeKnownLinkObj($mvStreamTitle, $title_span, 'tl=1') . '</span>';
        //add mvd_annotative output:
        $o .= $mvd_out_html;
        return $o;
    }
function do_process_text($stream, $force)
{
    $dbr = wfGetDB(DB_SLAVE);
    if ($force) {
        global $botUserName;
        // get wiki stream id:
        $wikiStream = new MV_Stream(array('name' => $stream->name));
        // first remove all bot edited pages:
        $mvd_res = MV_Index::getMVDInRange($wikiStream->getStreamId(), null, null, 'Ht_en');
        while ($row = $dbr->fetchObject($mvd_res)) {
            $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
            $current = Revision::newFromTitle($title);
            if ($current->getUserText() == $botUserName) {
                $article = new Article($title);
                $article->doDelete('mvbot removal');
                print "removed {$row->wiki_title} \n";
            } else {
                print "skiped {$roe->wiki_title} (last edit by: " . $current->getUserText() . ")\n";
            }
        }
    }
    /* for now use the stream search table (in the future should put in our orphaned person data)
     * should be able to do quick checks against the index. */
    $sql = "SELECT (`time`+" . CC_OFFSET . ") as time, `value` " . "FROM `metavid`.`stream_attr_time_text`\n\t\t\t\t\t\tWHERE `stream_fk`=" . $stream->id . "\n\t\t\t\t\t\tAND `time` >= " . $stream->adj_start_time . "\n\t\t\t\t\t\tAND `time` <= " . $stream->adj_end_time . "\n\t\t\t\tORDER BY `time` ASC ";
    // $sql = "SELECT * FROM `metavid`.`stream_search` WHERE `stream_fk`={$stream->id}";
    $page_res = $dbr->query($sql);
    if ($dbr->numRows($page_res) == 0) {
        echo 'No pages for stream' . $stream->name . "\n";
    }
    $pages = array();
    while ($page = $dbr->fetchObject($page_res)) {
        $pages[] = $page;
    }
    print "Checking " . count($pages) . " text pages\n";
    $i = $j = 0;
    foreach ($pages as $inx => $page) {
        // status updates:
        if ($i == 50) {
            print "on {$j} of " . count($pages) . "\n";
            $i = 0;
        }
        $i++;
        $j++;
        $start_time = $page->time - $stream->adj_start_time;
        if (seconds2npt($start_time) < 0) {
            $start_time = '0:00:00';
        }
        if ($inx + 1 == count($pages)) {
            $end_time = $stream->adj_end_time - $stream->adj_start_time;
        } else {
            $end_time = $pages[$inx + 1]->time - $stream->adj_start_time;
        }
        if ($end_time - $start_time > 40) {
            $end_time = $start_time + 40;
        }
        // skip if end_time <1
        if ($end_time < 0) {
            continue;
        }
        // now pull up the person for the given stream time:`metavid`.`people`.`name_clean`
        $sql = "SELECT * , abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} ) AS `distance` " . "FROM `metavid`.`people_attr_stream_time` " . "LEFT JOIN `metavid`.`people` ON `metavid`.`people_attr_stream_time`.`people_fk` = `metavid`.`people`.`id` " . "WHERE `metavid`.`people_attr_stream_time`.`stream_fk` ={$stream->id} " . "AND  (`metavid`.`people_attr_stream_time`.`time`-{$page->time})>-4 " . "AND abs( `metavid`.`people_attr_stream_time`.`time` -{$page->time} )< 90 " . "ORDER BY `distance` ASC " . "LIMIT 1 ";
        $person_res = $dbr->query($sql);
        $page_title = $stream->name . '/' . seconds2npt($start_time) . '/' . seconds2npt($end_time);
        // print $page_title . "\n";
        $page_body = '';
        if ($dbr->numRows($person_res) != 0) {
            $person = $dbr->fetchObject($person_res);
            $person_name = utf8_encode($person->name_clean);
            $page_body .= "\n[[Spoken By::{$person_name}]] ";
        }
        $page_body .= trim(str_replace("\n", ' ', strtolower($page->value)));
        // print $page_title . "\n";
        // die;
        // print $page_body . "\n\n";
        do_update_wiki_page('Ht_en:' . $page_title, $page_body, MV_NS_MVD);
    }
}
    function outPutItem($wikiTitle, $desc_html = '')
    {
        global $wgOut, $wgUser;
        $sk = $wgUser->getSkin();
        $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->getFullStreamImageURL('320x240', null, '', true);
        if ($desc_html == '') {
            $article = new Article($wikiTitle);
            $wgOut->clearHTML();
            $wgOut->addWikiText($article->getContent());
            $desc_html = $wgOut->getHTML();
            $wgOut->clearHTML();
        }
        //get the parent meta if allowed:
        global $mvGetParentMeta;
        $pmvd = false;
        if ($mvGetParentMeta && strtolower($mvTitle->getMvdTypeKey()) == 'ht_en') {
            $pmvd = MV_Index::getParentAnnotativeLayers($mvTitle);
            if ($pmvd->wiki_title) {
                $pMvTitle = new MV_Title($pmvd->wiki_title);
                $pAnnoStreamTitle = Title::MakeTitle(MV_NS_STREAM, $pMvTitle->getNearStreamName(0));
            }
        }
        $desc_xml = '<![CDATA[
			<center class="mv_rss_view_only">
				<a href="' . htmlspecialchars($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>
		<?php 
        echo mvRSSFeed::xmlEncode($mStreamTitle->getFullUrl());
        ?>
</link>
<title><?php 
        echo mvRSSFeed::xmlEncode($mvTitle->getStreamNameText() . ' ' . $time_desc);
        ?>
</title>
<description>
<?php 
        echo $desc_xml;
        ?>
</description>
<?php 
        global $mvDefaultVideoQualityKey, $mvVidQualityMsgKeyType, $mvDefaultVideoHighQualityKey, $mvDefaultFlashQualityKey;
        //check a few different types in order of prefrence:
        if ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoHighQualityKey)) {
            $mk = $mvDefaultVideoHighQualityKey;
        } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoQualityKey)) {
            $mk = $mvDefaultVideoQualityKey;
        } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey)) {
            $mk = $mvDefaultFlashQualityKey;
        }
        if ($stream_url) {
            echo '<enclosure name="' . wfMsg($mk) . '" type="video/ogg" ' . 'url="' . mvRSSFeed::xmlEncode($stream_url) . '"/>';
        }
        ?>

<comments>
<?php 
        echo mvRSSFeed::xmlEncode($talkpage->getFullUrl());
        ?>
</comments>
<?php 
        $person = '';
        if ($pmvd && $pmvd->Speech_by) {
            $personTitle = Title::newFromText($pmvd->Speech_by);
            ?>
<media:person label="<?php 
            echo $personTitle->getText();
            ?>
" url="<?php 
            echo mvRSSFeed::xmlEncode($personTitle->getFullURL());
            ?>
" />
<?php 
        }
        //handle any parent clip tag info:
        if ($pmvd) {
            ?>
<media:parent_clip url="<?php 
            echo mvRSSFeed::xmlEncode($pAnnoStreamTitle->getFullUrl());
            ?>
" />
<?php 
            if ($pmvd->Bill) {
                $bTitle = Title::newFromText($pmvd->Bill);
                ?>
<media:bill label="<?php 
                echo $bTitle->getText();
                ?>
" url="<?php 
                echo mvRSSFeed::xmlEncode($bTitle->getFullURL());
                ?>
" />
<?php 
            }
            if ($pmvd->category) {
                foreach ($pmvd->category as $cat_titlekey) {
                    $cTitle = $cTitle = Title::MakeTitle(NS_CATEGORY, $cat_titlekey);
                    ?>
<media:category label="<?php 
                    echo $cTitle->getText();
                    ?>
" url="<?php 
                    echo mvRSSFeed::xmlEncode($cTitle->getFullUrl());
                    ?>
" />
<?php 
                }
            }
        }
        ?>
<media:thumbnail
	url="<?php 
        echo mvRSSFeed::xmlEncode($thumb_ref);
        ?>
" />
<media:roe_embed
	url="<?php 
        echo mvRSSFeed::xmlEncode($mvTitle->getROEURL());
        ?>
" />
<media:group>
<?php 
        global $mvDefaultFlashQualityKey, $mvVidQualityMsgKeyType, $mvDefaultFlashQualityKey;
        //add in media group:
        $vid_types = array($mvDefaultVideoQualityKey, 'mv_ogg_high_quality', $mvDefaultFlashQualityKey);
        foreach ($vid_types as $vid_key) {
            $stream_url = $mvTitle->getWebStreamURL($vid_key);
            if ($stream_url !== false && isset($mvVidQualityMsgKeyType[$vid_key])) {
                ?>
	<media:content
		blip:role="<?php 
                echo mvRSSFeed::xmlEncode($vid_key);
                ?>
"
		expression="full"
		type="<?php 
                echo mvRSSFeed::xmlEncode($mvVidQualityMsgKeyType[$vid_key]);
                ?>
"
		url="<?php 
                echo htmlentities($stream_url);
                ?>
"></media:content>
		<?php 
            }
        }
        ?>
</media:group>
</item>
<?
	}
示例#18
0
function mvDeleteHook(&$article, &$user, &$reason)
{
    global $mvgIP;
    //print 'mvDeleteHook'."\n";
    //only need to update the mvd index when in the mvd namespace:
    if ($article->mTitle->getNamespace() == MV_NS_MVD) {
        //remove article with that title:
        MV_Index::remove_by_wiki_title($article->mTitle->getDBkey());
    } else {
        if ($article->mTitle->getNamespace() == MV_NS_STREAM) {
            MV_Index::remove_by_stream_id($article->mvTitle->mvStream->getStreamId());
            $article->mvTitle->mvStream->deleteDB();
        }
    }
    return true;
    // always return true, in order not to stop MW's hook processing!
}