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>';
	}
예제 #2
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;
 }
    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 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>';
	}
예제 #5
0
 function removeStream($removeMVDs = true)
 {
     $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.
         $mvd_rows = MV_Index::getMVDInRange($this->getStreamId());
         foreach ($mvd_rows as $row) {
             $title = Title::newFromText($row->wiki_title, MV_NS_MVD);
             $article = new Article($title);
             $article->doDelete('parent stream removed');
         }
     }
     //remove the stream db entries and images:
     $this->deleteDB();
     return true;
 }
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);
    }
}
예제 #7
0
 function load_transcripts()
 {
     // global $mvgIP;
     // require_once($mvgIP . '/includes/MV_Index.php');
     $dbr = wfGetDB(DB_SLAVE);
     global $wgRequest;
     $mvd_rows =& MV_Index::getMVDInRange($this->mv_interface->article->mvTitle->getStreamId(), $this->mv_interface->article->mvTitle->getStartTimeSeconds(), $this->mv_interface->article->mvTitle->getEndTimeSeconds(), $this->mvd_tracks);
     foreach ($mvd_rows as $row) {
         $this->mvd_pages[$row->id] = $row;
     }
     // print_r($mvd_rows);
 }
 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);
 }
예제 #9
0
 function do_edit_submit($titleKey, $mvd_id, $returnEncapsulated = false)
 {
     global $wgOut, $wgScriptPath, $wgUser, $wgTitle, $wgRequest;
     if ($mvd_id == 'new') {
         $titleKey = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], '/')) . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new'];
         $pos2 = strpos($_REQUEST['title'], '/');
         $pos1 = strpos($_REQUEST['title'], ':');
         //$nameKey ='mp_names'.substr($_REQUEST['title'],$pos1,$pos2).$_REQUEST['mv_start_hr_new'].'/'.$_REQUEST['mv_end_hr_new'];
         $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_new'] . '/' . $_REQUEST['mv_end_hr_new'];
     } else {
         $nameKey = 'mp_names:' . $_REQUEST['wgTitle'] . '/' . $_REQUEST['mv_start_hr_' . $mvd_id] . '/' . $_REQUEST['mv_end_hr_' . $mvd_id];
     }
     $type = substr($_REQUEST['title'], 0, strpos($_REQUEST['title'], ':'));
     //set up the title /article
     $wgTitle = Title::newFromText($titleKey, MV_NS_MVD);
     $Article = new Article($wgTitle);
     if ($type != 'Anno_en') {
         $tit = Title::newFromText($nameKey, MV_NS_MVD);
         $art = new Article($tit);
         if (!$art->exists()) {
             $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_NEW);
             //$art->doPurge();
         } else {
             $art->doEdit($_REQUEST['smw_Spoken_By'], 'MP names DO NOT EDIT', EDIT_UPDATE);
             //$art->doPurge();
         }
     }
     //xxxx
     //add all semantic form based attributes/relations to the posted body text
     foreach ($_POST as $key => $val) {
         $do_swm_include = true;
         if (substr($key, 0, 4) == 'smw_') {
             //try attribute
             $swmTitle = Title::newFromText(substr($key, 4), SMW_NS_PROPERTY);
             if ($swmTitle->exists()) {
                 //make sure the person is not empty:
                 if (trim($val) != '') {
                     //@@todo update for other smw types:
                     //$wgRequest->data['wpTextbox1'] = trim($_REQUEST['wpTextbox1']);
                     if ($key == 'smw_Spoken_By') {
                         //update the request wpTextBox:
                         $wgRequest->data['wpTextbox1'] .= "[[" . $swmTitle->getText() . ':=' . $val . ']]';
                     } else {
                         if ($key == 'smw_Edited_By') {
                             $user = User::newFromId($val);
                             $user->addWatch($wgTitle);
                             $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] ';
                         } else {
                             if ($key == 'smw_Read_By') {
                                 $user = User::newFromId($val);
                                 $user->addWatch($wgTitle);
                                 $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] ';
                             } else {
                                 if ($key == 'smw_Reported_By') {
                                     $user = User::newFromId($val);
                                     $user->addWatch($wgTitle);
                                     $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $user->getRealName() . ']] ';
                                 } else {
                                     if ($key == 'smw_Status') {
                                         $wgRequest->data['wpTextbox1'] .= " [[" . $swmTitle->getText() . ':=' . $val . ']] ';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     /*
     global $reportersTable;
     if (isset($wgRequest->data['smw_Reported_By']))
     {
     	$name = $wgRequest->data['smw_Reported_By'];
     	$sql = 'SELECT * FROM '.$reportersTable.' WHERE name="'.$name.'"';
     	$dbr =& wfGetDB(DB_SLAVE);
     	$result = $dbr->query($sql);
     	$row = $dbr->fetchObject($result);
     	$number = $row->order_number;
     	if ($row->next == 'next')
     		{
     			$dbw =& wfGetDB(DB_WRITE);
     			$sql = 'UPDATE '.$reportersTable.' SET next="" WHERE name="'.$name.'"';
     			$result = $dbw->query($sql);
     			$sql = 'SELECT * FROM '.$reportersTable.' WHERE order_number='."$number+1";
     			$result = $dbr->query($sql);
     			$row = $dbr->numRows($result);
     			if ($row > 0)
     			{
     				$sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number='."$number+1";
     			}
     			else
     			{
     					$sql = 'UPDATE '.$reportersTable.' SET next="next" WHERE order_number=1';
     			}
     			$result = $dbw->query($sql);
     		}
     	
     }	
     */
     $editPageAjax = new MV_EditPageAjax($Article);
     $editPageAjax->mvd_id = $mvd_id;
     //undesa
     global $mvgIP;
     $pages_start = array();
     $pages_end = array();
     $overlap = false;
     $start_hour = substr($_REQUEST['mv_start_hr_new'], 0, 1);
     $start_min = substr($_REQUEST['mv_start_hr_new'], 2, 2);
     $start_sec = substr($_REQUEST['mv_start_hr_new'], 5, 2);
     $start_time_in_sec = $start_hour * 3600 + $start_min * 60 + $start_sec;
     $end_hour = substr($_REQUEST['mv_end_hr_new'], 0, 1);
     $end_min = substr($_REQUEST['mv_end_hr_new'], 2, 2);
     $end_sec = substr($_REQUEST['mv_end_hr_new'], 5, 2);
     $end_time_in_sec = $end_hour * 3600 + $end_min * 60 + $end_sec;
     $streamTitle = new MV_Title($_REQUEST['title']);
     //$transcript_title = new MV_Title($titleKey);
     //$start = $transcript_title->getStartTimeSeconds();
     //$end = $transcript_title->getEndTimeSeconds();
     require_once $mvgIP . '/includes/MV_Index.php';
     $dbr =& wfGetDB(DB_SLAVE);
     $result =& MV_Index::getMVDInRange($streamTitle->getStreamId(), $streamTitle->getStartTimeSeconds(), $streamTitle->getEndTimeSeconds(), 'Ht_en');
     if ($dbr->numRows($result) == 0) {
         $pages_start = array();
         $pages_end = array();
     } else {
         while (($row = $dbr->fetchObject($result)) && $overlap == false) {
             $pages_start[$row->id] = $row->start_time;
             $pages_end[$row->id] = $row->end_time;
             if ($row->start_time <= $start_time_in_sec && $start_time_in_sec <= $row->end_time || $row->start_time <= $end_time_in_sec && $end_time_in_sec <= $row->end_time) {
                 $overlap = true;
             }
         }
     }
     $val = $wgRequest->getVal('overlap');
     if ($overlap == true && !isset($_POST['wpPreview']) && $val == 'no') {
         return "alert(\"The transcript you are trying to save" . $val . " overlaps with another\");" . $wgOut->getHTML();
     }
     //undesa
     //if preview just return the parsed preview
     //@@todo refactor to use as much EditPage code as possible
     // use the "livePreview" functionality of Edit page.
     if (isset($_POST['wpPreview'])) {
         //$out = $editPageAjax->getPreviewText();
         //$wgOut->addHTML($out);
         $mvTitle = new MV_Title($_REQUEST['title']);
         $parserOutput = $this->parse_format_text($wgRequest->data['wpTextbox1'], $mvTitle);
         $wgOut->addParserOutput($parserOutput);
         return $wgOut->getHTML() . '<div style="clear:both;"><hr></div>';
     }
     if ($editPageAjax->edit($wgRequest->data['wpTextbox1']) == false) {
         if ($mvd_id == 'new') {
             //get context info to position timeline element:
             $rt = isset($_REQUEST['wgTitle']) ? $_REQUEST['wgTitle'] : null;
             $this->get_overlay_context_from_title($rt);
             //get updated mvd_id:
             $dbr =& wfGetDB(DB_SLAVE);
             $result =& MV_Index::getMVDbyTitle($titleKey, 'mv_page_id');
             $mvd_id = $result->id;
             $result2 =& MV_Index::getMVDbyTitle($nameKey, 'mv_page_id');
             //purge cache for parent stream
             MV_MVD::onEdit($this->mvd_pages, $mvd_id);
             //MV_MVD::onEdit($this->mvd_pages, $result2->id);
             //return Encapsulated (since its a new mvd)
             $returnEncapsulated = true;
         } else {
             //purge cache for parent stream
             MV_MVD::onEdit($this->mvd_pages, $mvd_id);
         }
         if ($returnEncapsulated) {
             if ($_REQUEST['saveandcreate'] == 'true') {
                 $time_range = seconds2ntp($end_time_in_sec + 1) . '/' . seconds2ntp($end_time_in_sec + 600);
                 $time_str = 'mv_disp_add_mvd("ht_en","' . $time_range . '")';
                 return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id), 'saveandcreate' => $time_str));
             } else {
                 return php2jsObj(array('status' => 'ok', 'mvd_id' => $mvd_id, 'titleKey' => $titleKey, 'fd_mvd' => $this->get_fd_mvd_request($titleKey, $mvd_id, 'enclosed'), 'tl_mvd' => $this->get_tl_mvd_request($titleKey, $mvd_id)));
             }
         } else {
             return $this->get_fd_mvd_request($titleKey, $mvd_id);
         }
         //return "page saved successfully?";
     } else {
         //return "edit failed/ or preview? ";
         //$wgOut should have edit form with reported conflict, error or whatever
         return $wgOut->getHTML();
     }
 }
 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 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;
 }
예제 #12
0
 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;
 }